diff --git a/README.md b/README.md
index 588ce309..9127e57d 100644
--- a/README.md
+++ b/README.md
@@ -376,7 +376,7 @@ Use `--url`/`-u` to get a list of downloadable resource URLs extracted from the
| Site | URL | Videos? | Images? | Audios? |
| :--: | :-- | :-----: | :-----: | :-----: |
| **YouTube** | |✓| | |
-| **Twitter** | |✓|✓| |
+| **X (Twitter)** | |✓|✓| |
| VK | |✓|✓| |
| Vine | |✓| | |
| Vimeo | |✓| | |
diff --git a/src/you_get/common.py b/src/you_get/common.py
index ad3d3278..d14eb980 100755
--- a/src/you_get/common.py
+++ b/src/you_get/common.py
@@ -113,6 +113,7 @@ SITES = {
'veoh' : 'veoh',
'vine' : 'vine',
'vk' : 'vk',
+ 'x' : 'twitter',
'xiaokaxiu' : 'yixia',
'xiaojiadianvideo' : 'fc2video',
'ximalaya' : 'ximalaya',
@@ -1856,9 +1857,12 @@ def url_to_module(url):
)
else:
try:
- location = get_location(url) # t.co isn't happy with fake_headers
+ try:
+ location = get_location(url) # t.co isn't happy with fake_headers
+ except:
+ location = get_location(url, headers=fake_headers)
except:
- location = get_location(url, headers=fake_headers)
+ location = get_location(url, headers=fake_headers, get_method='GET')
if location and location != url and not location.startswith('/'):
return url_to_module(location)
diff --git a/src/you_get/extractors/bilibili.py b/src/you_get/extractors/bilibili.py
index b4e241c5..ea67f92f 100644
--- a/src/you_get/extractors/bilibili.py
+++ b/src/you_get/extractors/bilibili.py
@@ -335,7 +335,7 @@ class Bilibili(VideoExtractor):
'src': [[baseurl]], 'size': size}
# get danmaku
- self.danmaku = get_content('http://comment.bilibili.com/%s.xml' % cid)
+ self.danmaku = get_content('https://comment.bilibili.com/%s.xml' % cid, headers=self.bilibili_headers(referer=self.url))
# bangumi
elif sort == 'bangumi':
@@ -414,7 +414,7 @@ class Bilibili(VideoExtractor):
'src': [[baseurl], [audio_baseurl]], 'size': size}
# get danmaku
- self.danmaku = get_content('http://comment.bilibili.com/%s.xml' % cid)
+ self.danmaku = get_content('https://comment.bilibili.com/%s.xml' % cid, headers=self.bilibili_headers(referer=self.url))
# vc video
elif sort == 'vc':
@@ -596,7 +596,7 @@ class Bilibili(VideoExtractor):
'src': [[baseurl]], 'size': size}
# get danmaku
- self.danmaku = get_content('http://comment.bilibili.com/%s.xml' % cid)
+ self.danmaku = get_content('https://comment.bilibili.com/%s.xml' % cid, headers=self.bilibili_headers(referer=self.url))
def extract(self, **kwargs):
# set UA and referer for downloading
diff --git a/src/you_get/extractors/twitter.py b/src/you_get/extractors/twitter.py
index d995fc58..b0125c67 100644
--- a/src/you_get/extractors/twitter.py
+++ b/src/you_get/extractors/twitter.py
@@ -34,9 +34,9 @@ def twitter_download(url, output_dir='.', merge=True, info_only=False, **kwargs)
**kwargs)
return
- m = re.match('^https?://(mobile\.)?twitter\.com/([^/]+)/status/(\d+)', url)
+ m = re.match('^https?://(mobile\.)?(x|twitter)\.com/([^/]+)/status/(\d+)', url)
assert m
- screen_name, item_id = m.group(2), m.group(3)
+ screen_name, item_id = m.group(3), m.group(4)
page_title = "{} [{}]".format(screen_name, item_id)
# FIXME: this API won't work for protected or nsfw contents
@@ -77,6 +77,6 @@ def twitter_download(url, output_dir='.', merge=True, info_only=False, **kwargs)
# TODO: should we deal with quoted tweets?
-site_info = "Twitter.com"
+site_info = "X.com"
download = twitter_download
download_playlist = playlist_not_supported('twitter')