From 070846b608e455b597a24b7e36e5940abd004cd0 Mon Sep 17 00:00:00 2001 From: bopol Date: Sat, 14 Mar 2020 23:01:47 +0100 Subject: [PATCH 1/3] [twitter] add support for public nitter instances list of instances: https://github.com/zedeus/nitter/wiki/Instances info about nitter: https://github.com/zedeus/nitter basically, it's a privacy-friendly twitter web client, the url is the same except the beginning part --- youtube_dl/extractor/twitter.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/youtube_dl/extractor/twitter.py b/youtube_dl/extractor/twitter.py index 01468981c..9dd81439a 100644 --- a/youtube_dl/extractor/twitter.py +++ b/youtube_dl/extractor/twitter.py @@ -30,7 +30,8 @@ from .periscope import ( class TwitterBaseIE(InfoExtractor): _API_BASE = 'https://api.twitter.com/1.1/' - _BASE_REGEX = r'https?://(?:(?:www|m(?:obile)?)\.)?twitter\.com/' + _BASE_REGEX = r'https?://((?:(?:www|m(?:obile)?)\.)?twitter\.com|' \ + 'nitter\.(net|42l\.fr|snopyta\.org|nixnet\.services|pussthecat\.org|mastodont\.cat|13ad\.de)|tw\.openalgeria\.org)/' _GUEST_TOKEN = None def _extract_variant_formats(self, variant, video_id): From 54eadd2d7954c6fb58e106824a318cf843974b1e Mon Sep 17 00:00:00 2001 From: bopol Date: Fri, 27 Mar 2020 19:16:22 +0100 Subject: [PATCH 2/3] [twitter] pass flake8 verification --- youtube_dl/extractor/twitter.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/youtube_dl/extractor/twitter.py b/youtube_dl/extractor/twitter.py index 9dd81439a..e9258eaba 100644 --- a/youtube_dl/extractor/twitter.py +++ b/youtube_dl/extractor/twitter.py @@ -30,8 +30,7 @@ from .periscope import ( class TwitterBaseIE(InfoExtractor): _API_BASE = 'https://api.twitter.com/1.1/' - _BASE_REGEX = r'https?://((?:(?:www|m(?:obile)?)\.)?twitter\.com|' \ - 'nitter\.(net|42l\.fr|snopyta\.org|nixnet\.services|pussthecat\.org|mastodont\.cat|13ad\.de)|tw\.openalgeria\.org)/' + _BASE_REGEX = r'https?://((?:(?:www|m(?:obile)?)\.)?twitter\.com|nitter\.(net|42l\.fr|snopyta\.org|nixnet\.services|pussthecat\.org|mastodont\.cat|13ad\.de)|tw\.openalgeria\.org)/' _GUEST_TOKEN = None def _extract_variant_formats(self, variant, video_id): From 8598dd833ab84a66dbd0533e326ceea7bc977220 Mon Sep 17 00:00:00 2001 From: bopol Date: Fri, 27 Mar 2020 20:41:29 +0100 Subject: [PATCH 3/3] [twitter] add tests for nitter --- youtube_dl/extractor/twitter.py | 40 +++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/youtube_dl/extractor/twitter.py b/youtube_dl/extractor/twitter.py index e9258eaba..901f25ab5 100644 --- a/youtube_dl/extractor/twitter.py +++ b/youtube_dl/extractor/twitter.py @@ -203,6 +203,21 @@ class TwitterIE(TwitterBaseIE): 'upload_date': '20150913', 'age_limit': 18, }, + }, { + 'url': 'https://nitter.net/freethenipple/status/643211948184596480', + 'info_dict': { + 'id': '643211948184596480', + 'ext': 'mp4', + 'title': 'FREE THE NIPPLE - FTN supporters on Hollywood Blvd today!', + 'thumbnail': r're:^https?://.*\.jpg', + 'description': 'FTN supporters on Hollywood Blvd today! http://t.co/c7jHH749xJ', + 'uploader': 'FREE THE NIPPLE', + 'uploader_id': 'freethenipple', + 'duration': 12.922, + 'timestamp': 1442188653, + 'upload_date': '20150913', + 'age_limit': 18, + }, }, { 'url': 'https://twitter.com/giphz/status/657991469417025536/photo/1', 'md5': 'f36dcd5fb92bf7057f155e7d927eeb42', @@ -229,6 +244,18 @@ class TwitterIE(TwitterBaseIE): 'timestamp': 1447395772, 'upload_date': '20151113', }, + }, { + 'url': 'https://nitter.net/starwars/status/665052190608723968', + 'info_dict': { + 'id': '665052190608723968', + 'ext': 'mp4', + 'title': 'Star Wars - A new beginning is coming December 18. Watch the official 60 second #TV spot for #StarWars: #TheForceAwakens.', + 'description': 'A new beginning is coming December 18. Watch the official 60 second #TV spot for #StarWars: #TheForceAwakens. https://t.co/OkSqT2fjWJ', + 'uploader_id': 'starwars', + 'uploader': 'Star Wars', + 'timestamp': 1447395772, + 'upload_date': '20151113', + }, }, { 'url': 'https://twitter.com/BTNBrentYarina/status/705235433198714880', 'info_dict': { @@ -273,6 +300,19 @@ class TwitterIE(TwitterBaseIE): 'upload_date': '20140615', }, 'add_ie': ['Vine'], + }, { + 'url': 'https://nitter.42l.fr/Filmdrunk/status/713801302971588609', + 'md5': '89a15ed345d13b86e9a5a5e051fa308a', + 'info_dict': { + 'id': 'MIOxnrUteUd', + 'ext': 'mp4', + 'title': 'Dr.Pepperの飲み方 #japanese #バカ #ドクペ #電動ガン', + 'uploader': 'TAKUMA', + 'uploader_id': '1004126642786242560', + 'timestamp': 1402826626, + 'upload_date': '20140615', + }, + 'add_ie': ['Vine'], }, { 'url': 'https://twitter.com/captainamerica/status/719944021058060289', 'info_dict': {