mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-27 14:14:54 +01:00
[twitter/t.co] update supportedsites, failover replace, tco:id feature
This commit is contained in:
parent
9e20a9c447
commit
a537ab1a09
|
@ -540,6 +540,7 @@ # Supported sites
|
||||||
- **natgeo:video**
|
- **natgeo:video**
|
||||||
- **NationalGeographicTV**
|
- **NationalGeographicTV**
|
||||||
- **Naver**
|
- **Naver**
|
||||||
|
- **Naver:live**
|
||||||
- **NBA**
|
- **NBA**
|
||||||
- **NBC**
|
- **NBC**
|
||||||
- **NBCNews**
|
- **NBCNews**
|
||||||
|
@ -976,6 +977,7 @@ # Supported sites
|
||||||
- **twitter:amplify**
|
- **twitter:amplify**
|
||||||
- **twitter:broadcast**
|
- **twitter:broadcast**
|
||||||
- **twitter:card**
|
- **twitter:card**
|
||||||
|
- **twitter:shortener**
|
||||||
- **udemy**
|
- **udemy**
|
||||||
- **udemy:course**
|
- **udemy:course**
|
||||||
- **UDNEmbed**: 聯合影音
|
- **UDNEmbed**: 聯合影音
|
||||||
|
|
|
@ -612,8 +612,17 @@ def _real_extract(self, url):
|
||||||
|
|
||||||
class TwitterShortenerIE(TwitterBaseIE):
|
class TwitterShortenerIE(TwitterBaseIE):
|
||||||
IE_NAME = 'twitter:shortener'
|
IE_NAME = 'twitter:shortener'
|
||||||
_VALID_URL = r'https?://t.co/'
|
_VALID_URL = r'https?://t.co/(?P<id>[^?]+)|tco:(?P<eid>[^?]+)'
|
||||||
|
_BASE_URL = 'https://t.co/'
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
new_url = self._request_webpage(url, None, headers={'User-Agent': 'curl'}).geturl()
|
mobj = re.match(self._VALID_URL, url)
|
||||||
|
eid, id = mobj.group('eid', 'id')
|
||||||
|
if eid:
|
||||||
|
id = eid
|
||||||
|
url = self._BASE_URL + id
|
||||||
|
new_url = self._request_webpage(url, id, headers={'User-Agent': 'curl'}).geturl()
|
||||||
|
__UNSAFE_LINK = "https://twitter.com/safety/unsafe_link_warning?unsafe_link="
|
||||||
|
if new_url.startswith(__UNSAFE_LINK):
|
||||||
|
new_url = new_url.replace(__UNSAFE_LINK, "")
|
||||||
return self.url_result(new_url)
|
return self.url_result(new_url)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user