From 96d54d9692ef02c7c4d0f1a55f90d0fcc6fd27e4 Mon Sep 17 00:00:00 2001 From: MateusAquino Date: Thu, 31 Dec 2020 12:48:18 -0300 Subject: [PATCH] Allow amplify_video urls in regex --- src/controllers/Recognitions.js | 2 +- src/recognition/index.js | 1 - src/recognition/utils/twitter.js | 6 ++++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/controllers/Recognitions.js b/src/controllers/Recognitions.js index b2e128e..23fe9cb 100644 --- a/src/controllers/Recognitions.js +++ b/src/controllers/Recognitions.js @@ -1,4 +1,4 @@ -const statusHashRgx = /video\/([^\/]+)(?:\/[^\/]+){3}\/([^\/?]+)/; +const statusHashRgx = /video\/([^\/]+)(?:\/[^\/]+){2,3}\/([^\/?]+)/; const Recognitions = require('../models/Recognitions'); class RecognitionsController { diff --git a/src/recognition/index.js b/src/recognition/index.js index 49b99ac..b7de36f 100644 --- a/src/recognition/index.js +++ b/src/recognition/index.js @@ -16,7 +16,6 @@ main = async () => { return twitter.replyTo(id, screenName, `twitter.com/me/status/${setRecognized}`); // Download Media - console.log('------ New Identification in progress... (twid: ' + tweet.id_str + ') ------') let tempFile = await download(mediaURL); if (tempFile === false) return console.log('Couldn\'t download media'); diff --git a/src/recognition/utils/twitter.js b/src/recognition/utils/twitter.js index c5e93bf..24f8696 100644 --- a/src/recognition/utils/twitter.js +++ b/src/recognition/utils/twitter.js @@ -123,10 +123,12 @@ class Twitter { const mediaURL = tweet.extended_entities.media[0].video_info.variants[0].url; for (let media of tweet.extended_entities.media[0].video_info.variants) if (media.content_type === 'video/mp4') { - console.log('x - '+media.url) + console.log('------ New Identification in progress... (twid: '+id+') ------'); + console.log('Media URL: ' + media.url) return media.url; } - console.log('y - '+mediaURL) + console.log('------ New Identification in progress... (twid: '+id+') ------'); + console.log('Media URL (fallback): ' + mediaURL) return mediaURL; }