]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/tokentube.py
4 from .common
import InfoExtractor
16 class TokentubeIE(InfoExtractor
):
17 _VALID_URL
= r
'https?://(?:www\.)?tokentube\.net/(?:view\?[vl]=|[vl]/)(?P<id>\d+)'
19 'url': 'https://tokentube.net/l/3236632011/Praise-A-Thon-Pastori-Chrisin-ja-Pastori-Bennyn-kanssa-27-8-2021',
23 'title': 'Praise-A-Thon Pastori Chrisin ja Pastori Bennyn kanssa 27.8.2021',
25 'uploader': 'Pastori Chris - Rapsodia.fi',
26 'upload_date': '20210827',
29 'skip_download': True,
32 'url': 'https://tokentube.net/v/3950239124/Linux-Ubuntu-Studio-perus-k%C3%A4ytt%C3%B6',
33 'md5': '0e1f00421f501f5eada9890d38fcfb56',
37 'title': 'Linux Ubuntu Studio perus käyttö',
38 'description': 'md5:46077d0daaba1974f2dc381257f9d64c',
39 'uploader': 'jyrilehtonen',
40 'upload_date': '20210825',
43 'url': 'https://tokentube.net/view?v=3582463289',
47 'title': 'Police for Freedom - toiminta aloitetaan Suomessa ❤️??',
48 'description': 'md5:37ebf1cb44264e0bf23ed98b337ee63e',
49 'uploader': 'Voitontie',
50 'upload_date': '20210428',
54 def _real_extract(self
, url
):
55 video_id
= self
._match
_id
(url
)
56 webpage
= self
._download
_webpage
(url
, video_id
)
58 title
= self
._html
_search
_regex
(r
'<h1\s*class=["\']title
-text
["\']>(.+?)</h1>', webpage, 'title')
60 data_json = self._html_search_regex(r'({["\']html5["\'].+?}}}+)', webpage, 'data json')
61 data_json = self._parse_json(js_to_json(data_json), video_id, fatal=False)
63 sources = data_json.get('sources') or self._parse_json(
64 self._html_search_regex(r'updateSrc\(([^\)]+)\)', webpage, 'sources'),
65 video_id, transform_source=js_to_json)
68 'url': format.get('src'),
69 'format_id': format.get('label'),
70 'height': format.get('res'),
71 } for format in sources]
73 view_count = parse_count(self._html_search_regex(
74 r'<p\s*class=["\']views_counter
["\']>\s*([\d\.,]+)\s*<span>views?</span></p>',
75 webpage, 'view_count', fatal=False))
77 like_count = parse_count(self._html_search_regex(
78 r'<div\s*class="sh_button\s
*likes_count
">\s*(\d+)\s*</div>',
79 webpage, 'like count', fatal=False))
81 dislike_count = parse_count(self._html_search_regex(
82 r'<div\s*class="sh_button\s
*dislikes_count
">\s*(\d+)\s*</div>',
83 webpage, 'dislike count', fatal=False))
85 upload_date = unified_strdate(self._html_search_regex(
86 r'<span\s*class="p
-date
">Published\s*on\s+([^<]+)',
87 webpage, 'upload date', fatal=False))
89 uploader = self._html_search_regex(
90 r'<a\s*class="place
-left
"[^>]+>(.+?)</a>',
91 webpage, 'uploader', fatal=False)
93 description = (clean_html(get_element_by_class('p-d-txt', webpage))
94 or self._html_search_meta(('og:description', 'description', 'twitter:description'), webpage))
96 description = remove_end(description, 'Category')
102 'view_count': view_count,
103 'like_count': like_count,
104 'dislike_count': dislike_count,
105 'upload_date': upload_date,
106 'description': description,
107 'uploader': uploader,
111 class TokentubeChannelIE(InfoExtractor):
113 IE_NAME = 'Tokentube:channel'
114 _VALID_URL = r'https?://(?:www\.)?tokentube\.net/channel/(?P<id>\d+)/[^/]+(?:/videos)?'
116 'url': 'https://tokentube.net/channel/3697658904/TokenTube',
120 'playlist_mincount': 7,
122 'url': 'https://tokentube.net/channel/3353234420/Linux/videos',
126 'playlist_mincount': 20,
128 'url': 'https://tokentube.net/channel/3475834195/Voitontie',
132 'playlist_mincount': 150,
135 def _fetch_page(self, channel_id, page):
137 videos_info = self._download_webpage(
138 f'https://tokentube.net/videos?p=0&m=1&sort=recent&u={channel_id}&page={page}',
139 channel_id, headers={'X-Requested-With': 'XMLHttpRequest'},
140 note=f'Downloading page {page}', fatal=False)
141 if '</i> Sorry, no results were found.' not in videos_info:
142 for path, media_id in re.findall(
143 r'<a[^>]+\bhref=["\']([^
"\']+/[lv]/(\d+)/\S+)["\'][^
>]+>',
145 yield self.url_result(path, ie=TokentubeIE.ie_key(), video_id=media_id)
147 def _real_extract(self, url):
148 channel_id = self._match_id(url)
150 entries = OnDemandPagedList(functools.partial(
151 self._fetch_page, channel_id), self._PAGE_SIZE)
153 return self.playlist_result(entries, channel_id)