]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/tokentube.py
2 from __future__
import unicode_literals
7 from .common
import InfoExtractor
19 class TokentubeIE(InfoExtractor
):
20 _VALID_URL
= r
'https?://(?:www\.)?tokentube\.net/(?:view\?[vl]=|[vl]/)(?P<id>\d+)'
22 'url': 'https://tokentube.net/l/3236632011/Praise-A-Thon-Pastori-Chrisin-ja-Pastori-Bennyn-kanssa-27-8-2021',
26 'title': 'Praise-A-Thon Pastori Chrisin ja Pastori Bennyn kanssa 27.8.2021',
28 'uploader': 'Pastori Chris - Rapsodia.fi',
29 'upload_date': '20210827',
32 'skip_download': True,
35 'url': 'https://tokentube.net/v/3950239124/Linux-Ubuntu-Studio-perus-k%C3%A4ytt%C3%B6',
36 'md5': '0e1f00421f501f5eada9890d38fcfb56',
40 'title': 'Linux Ubuntu Studio perus käyttö',
41 'description': 'md5:46077d0daaba1974f2dc381257f9d64c',
42 'uploader': 'jyrilehtonen',
43 'upload_date': '20210825',
46 'url': 'https://tokentube.net/view?v=3582463289',
50 'title': 'Police for Freedom - toiminta aloitetaan Suomessa ❤️??',
51 'description': 'md5:37ebf1cb44264e0bf23ed98b337ee63e',
52 'uploader': 'Voitontie',
53 'upload_date': '20210428',
57 def _real_extract(self
, url
):
58 video_id
= self
._match
_id
(url
)
59 webpage
= self
._download
_webpage
(url
, video_id
)
61 title
= self
._html
_search
_regex
(r
'<h1\s*class=["\']title
-text
["\']>(.+?)</h1>', webpage, 'title')
63 data_json = self._html_search_regex(r'({["\']html5["\'].+?}}}+)', webpage, 'data json')
64 data_json = self._parse_json(js_to_json(data_json), video_id, fatal=False)
66 sources = data_json.get('sources') or self._parse_json(
67 self._html_search_regex(r'updateSrc\(([^\)]+)\)', webpage, 'sources'),
68 video_id, transform_source=js_to_json)
71 'url': format.get('src'),
72 'format_id': format.get('label'),
73 'height': format.get('res'),
74 } for format in sources]
76 view_count = parse_count(self._html_search_regex(
77 r'<p\s*class=["\']views_counter
["\']>\s*([\d\.,]+)\s*<span>views?</span></p>',
78 webpage, 'view_count', fatal=False))
80 like_count = parse_count(self._html_search_regex(
81 r'<div\s*class="sh_button\s
*likes_count
">\s*(\d+)\s*</div>',
82 webpage, 'like count', fatal=False))
84 dislike_count = parse_count(self._html_search_regex(
85 r'<div\s*class="sh_button\s
*dislikes_count
">\s*(\d+)\s*</div>',
86 webpage, 'dislike count', fatal=False))
88 upload_date = unified_strdate(self._html_search_regex(
89 r'<span\s*class="p
-date
">Published\s*on\s+([^<]+)',
90 webpage, 'upload date', fatal=False))
92 uploader = self._html_search_regex(
93 r'<a\s*class="place
-left
"[^>]+>(.+?)</a>',
94 webpage, 'uploader', fatal=False)
96 description = (clean_html(get_element_by_class('p-d-txt', webpage))
97 or self._html_search_meta(('og:description', 'description', 'twitter:description'), webpage))
99 description = remove_end(description, 'Category')
101 self._sort_formats(formats)
107 'view_count': view_count,
108 'like_count': like_count,
109 'dislike_count': dislike_count,
110 'upload_date': upload_date,
111 'description': description,
112 'uploader': uploader,
116 class TokentubeChannelIE(InfoExtractor):
118 IE_NAME = 'Tokentube:channel'
119 _VALID_URL = r'https?://(?:www\.)?tokentube\.net/channel/(?P<id>\d+)/[^/]+(?:/videos)?'
121 'url': 'https://tokentube.net/channel/3697658904/TokenTube',
125 'playlist_mincount': 7,
127 'url': 'https://tokentube.net/channel/3353234420/Linux/videos',
131 'playlist_mincount': 20,
133 'url': 'https://tokentube.net/channel/3475834195/Voitontie',
137 'playlist_mincount': 150,
140 def _fetch_page(self, channel_id, page):
142 videos_info = self._download_webpage(
143 f'https://tokentube.net/videos?p=0&m=1&sort=recent&u={channel_id}&page={page}',
144 channel_id, headers={'X-Requested-With': 'XMLHttpRequest'},
145 note=f'Downloading page {page}', fatal=False)
146 if '</i> Sorry, no results were found.' not in videos_info:
147 for path, media_id in re.findall(
148 r'<a[^>]+\bhref=["\']([^
"\']+/[lv]/(\d+)/\S+)["\'][^
>]+>',
150 yield self.url_result(path, ie=TokentubeIE.ie_key(), video_id=media_id)
152 def _real_extract(self, url):
153 channel_id = self._match_id(url)
155 entries = OnDemandPagedList(functools.partial(
156 self._fetch_page, channel_id), self._PAGE_SIZE)
158 return self.playlist_result(entries, channel_id)