[tiktok] Add support for new URL schema (closes #20573)
This commit is contained in:
parent
d562cac9dc
commit
7c2ecbc1cc
|
@ -65,8 +65,15 @@ class TikTokBaseIE(InfoExtractor):
|
||||||
|
|
||||||
|
|
||||||
class TikTokIE(TikTokBaseIE):
|
class TikTokIE(TikTokBaseIE):
|
||||||
_VALID_URL = r'https?://(?:m\.)?tiktok\.com/v/(?P<id>\d+)'
|
_VALID_URL = r'''(?x)
|
||||||
_TEST = {
|
https?://
|
||||||
|
(?:
|
||||||
|
(?:m\.)?tiktok\.com/v|
|
||||||
|
(?:www\.)?tiktok\.com/share/video
|
||||||
|
)
|
||||||
|
/(?P<id>\d+)
|
||||||
|
'''
|
||||||
|
_TESTS = [{
|
||||||
'url': 'https://m.tiktok.com/v/6606727368545406213.html',
|
'url': 'https://m.tiktok.com/v/6606727368545406213.html',
|
||||||
'md5': 'd584b572e92fcd48888051f238022420',
|
'md5': 'd584b572e92fcd48888051f238022420',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
|
@ -81,25 +88,39 @@ class TikTokIE(TikTokBaseIE):
|
||||||
'comment_count': int,
|
'comment_count': int,
|
||||||
'repost_count': int,
|
'repost_count': int,
|
||||||
}
|
}
|
||||||
}
|
}, {
|
||||||
|
'url': 'https://www.tiktok.com/share/video/6606727368545406213',
|
||||||
|
'only_matching': True,
|
||||||
|
}]
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
webpage = self._download_webpage(url, video_id)
|
webpage = self._download_webpage(
|
||||||
|
'https://m.tiktok.com/v/%s.html' % video_id, video_id)
|
||||||
data = self._parse_json(self._search_regex(
|
data = self._parse_json(self._search_regex(
|
||||||
r'\bdata\s*=\s*({.+?})\s*;', webpage, 'data'), video_id)
|
r'\bdata\s*=\s*({.+?})\s*;', webpage, 'data'), video_id)
|
||||||
return self._extract_aweme(data)
|
return self._extract_aweme(data)
|
||||||
|
|
||||||
|
|
||||||
class TikTokUserIE(TikTokBaseIE):
|
class TikTokUserIE(TikTokBaseIE):
|
||||||
_VALID_URL = r'https?://(?:m\.)?tiktok\.com/h5/share/usr/(?P<id>\d+)'
|
_VALID_URL = r'''(?x)
|
||||||
_TEST = {
|
https?://
|
||||||
|
(?:
|
||||||
|
(?:m\.)?tiktok\.com/h5/share/usr|
|
||||||
|
(?:www\.)?tiktok\.com/share/user
|
||||||
|
)
|
||||||
|
/(?P<id>\d+)
|
||||||
|
'''
|
||||||
|
_TESTS = [{
|
||||||
'url': 'https://m.tiktok.com/h5/share/usr/188294915489964032.html',
|
'url': 'https://m.tiktok.com/h5/share/usr/188294915489964032.html',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '188294915489964032',
|
'id': '188294915489964032',
|
||||||
},
|
},
|
||||||
'playlist_mincount': 24,
|
'playlist_mincount': 24,
|
||||||
}
|
}, {
|
||||||
|
'url': 'https://www.tiktok.com/share/user/188294915489964032',
|
||||||
|
'only_matching': True,
|
||||||
|
}]
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
user_id = self._match_id(url)
|
user_id = self._match_id(url)
|
||||||
|
|
Loading…
Reference in New Issue