before_code
stringlengths
14
465k
reviewer_comment
stringlengths
16
64.5k
after_code
stringlengths
9
467k
diff_context
stringlengths
0
97k
file_path
stringlengths
5
226
comment_line
int32
0
26
language
stringclasses
37 values
quality_score
float32
0.07
1
comment_type
stringclasses
9 values
comment_length
int32
16
64.5k
before_lines
int32
1
17.2k
after_lines
int32
1
12.1k
is_negative
bool
2 classes
pr_title
stringlengths
1
308
pr_number
int32
1
299k
repo_name
stringclasses
533 values
repo_stars
int64
321
419k
repo_language
stringclasses
27 values
reviewer_username
stringlengths
0
39
author_username
stringlengths
2
39
def _search_results(self, query): def get_video_data(metadata): for search_result in metadata.get('results', []): video_id_ind, video_type = self._TYPES.get(str_or_none(traverse_obj(search_result, ('content_type', 'raw'))), (None, None)) video_id = traverse_obj(se...
```py for page_number in itertools.count(1): ... note='Downloading search results page %d%s' % (page_number, format_field(total_pages, template=' of ~%d'), ... QUERY_DATA['page']['current'] = page_number total_pages = ... if total_pages <= page_number: # Not sure why this is needed t...
self._download_json(f'{_API_BASE_URL}stack/{list_id}', list_id)), list_id) class RokfinChannelIE(RokfinPlaylistBaseIE): IE_NAME = 'rokfin:channel' IE_DESC = 'Rokfin Channels' _VALID_URL = r'https?://(?:www\.)?rokfin\.com/(?!((feed/?)|(discover/?)|(channels/?))$)(?P<id>[^/]+)/?$' _TESTS = [...
@@ -254,3 +257,64 @@ def _real_extract(self, url): return self.playlist_result( self._entries(channel_id, channel_name, self._TABS[tab]), f'{channel_id}-{tab}', f'{channel_name} - {tab.title()}', str_or_none(channel_info.get('description'))) + + +# E.g.: rkfnsearch5:"\"zelenko\"" or r...
yt_dlp/extractor/rokfin.py
26
Python
0.786
style
367
44
51
false
[Rokfin] Search & login
2,992
yt-dlp/yt-dlp
132,642
Python
pukkandan
P-reducible
yield self.url_result(url=f'{self._BASE_URL}/{video_type}/{video_id}') if not query: return if not self._service_url or not self._service_access_key: self._service_url, self._service_access_key = self._get_access_credentials() QUERY_DATA = {'query': query,...
```suggestion js = '\n'.join( self._download_webpage( f'https://rokfin.com/{path}', self._SEARCH_KEY, note='Downloading JavaScript file', fatal=False) or '', for path in re.findall(r'<script\s[^>]*src\s*=\s*"(/static/js/[^">]+)', notfound_err_page)) ...
'url': 'https://rokfin.com/TheConvoCouch', 'playlist_mincount': 100, 'info_dict': { 'id': '12071-new', 'title': 'TheConvoCouch - New', 'description': 'md5:bb622b1bca100209b91cd685f7847f06', }, }] _TABS = { 'new': 'posts', 'top'...
@@ -254,3 +257,64 @@ def _real_extract(self, url): return self.playlist_result( self._entries(channel_id, channel_name, self._TABS[tab]), f'{channel_id}-{tab}', f'{channel_name} - {tab.title()}', str_or_none(channel_info.get('description'))) + + +# E.g.: rkfnsearch5:"\"zelenko\"" or r...
yt_dlp/extractor/rokfin.py
26
Python
0.786
suggestion
323
36
51
false
[Rokfin] Search & login
2,992
yt-dlp/yt-dlp
132,642
Python
pukkandan
P-reducible
self._service_url, self._SEARCH_KEY, headers={'authorization': self._service_access_key}, data=json.dumps(QUERY_DATA).encode('utf-8'), encoding='utf-8', note='Downloading search results page %d%s' % (QUERY_DATA['page']['current'], (' of ~%d') % (total_pages,) if total_pag...
1. Why iter through `r're1|re2'` when u can just run 2 `search_regex` on re1 and re2, especially since the code path is split 2. When empty string shouldn't match, use `+`
_TABS = { 'new': 'posts', 'top': 'top', 'videos': 'video', 'podcasts': 'audio', 'streams': 'stream', 'stacks': 'stack', } def _real_initialize(self): self._validate_extractor_args() def _validate_extractor_args(self): requested_tabs = sel...
@@ -254,3 +257,64 @@ def _real_extract(self, url): return self.playlist_result( self._entries(channel_id, channel_name, self._TABS[tab]), f'{channel_id}-{tab}', f'{channel_name} - {tab.title()}', str_or_none(channel_info.get('description'))) + + +# E.g.: rkfnsearch5:"\"zelenko\"" or r...
yt_dlp/extractor/rokfin.py
26
Python
0.571
suggestion
172
27
51
false
[Rokfin] Search & login
2,992
yt-dlp/yt-dlp
132,642
Python
pukkandan
P-reducible
# coding: utf-8 import itertools from datetime import datetime import re import json import urllib.parse import random from .common import InfoExtractor, SearchInfoExtractor from ..utils import ( determine_ext, ExtractorError, float_or_none, format_field, int_or_none, str_or_none, traverse_o...
https://stackoverflow.com/a/20763446
import itertools import json import re import urllib.parse from datetime import datetime from .common import InfoExtractor, SearchInfoExtractor from ..utils import ( ExtractorError, determine_ext, float_or_none, format_field, int_or_none, str_or_none, traverse_obj, try_get, unescape...
@@ -1,8 +1,11 @@ # coding: utf-8 import itertools from datetime import datetime - -from .common import InfoExtractor +import re +import json +import urllib.parse +import random
yt_dlp/extractor/rokfin.py
7
Python
0.214
bug
36
32
32
false
[Rokfin] Search & login
2,992
yt-dlp/yt-dlp
132,642
Python
pukkandan
P-reducible
f'{channel_id}-{tab}', f'{channel_name} - {tab.title()}', str_or_none(channel_info.get('description'))) # E.g.: rkfnsearch5:"\"zelenko\"" or rkfnsearch5:"\"mollie james\"" class RokfinSearchIE(SearchInfoExtractor): IE_DESC = 'Rokfin Search' _TYPES = { 'video': (('id', 'raw'), 'post'), ...
```suggestion self._access_url, self._access_key = self._downloader.cache.load( self.ie_key(), 'auth') or self._get_access_credentials() ``` PS: We are in the search class. No need to put `search_engine` everywhere!
import itertools import json import re import urllib.parse from datetime import datetime from .common import InfoExtractor, SearchInfoExtractor from ..utils import ( ExtractorError, determine_ext, float_or_none, format_field, int_or_none, str_or_none, traverse_obj, try_get, unescape...
@@ -254,3 +422,91 @@ def _real_extract(self, url): return self.playlist_result( self._entries(channel_id, channel_name, self._TABS[tab]), f'{channel_id}-{tab}', f'{channel_name} - {tab.title()}', str_or_none(channel_info.get('description'))) + + +# E.g.: rkfnsearch5:"\"zelenko\"" or r...
yt_dlp/extractor/rokfin.py
26
Python
0.786
security
239
51
411
false
[Rokfin] Search & login
2,992
yt-dlp/yt-dlp
132,642
Python
pukkandan
P-reducible
class RokfinSearchIE(SearchInfoExtractor): IE_DESC = 'Rokfin Search' _TYPES = { 'video': (('id', 'raw'), 'post'), 'audio': (('id', 'raw'), 'post'), 'stream': (("content_id", 'raw'), 'stream'), 'dead_stream': (('content_id', 'raw'), 'stream'), 'stack': (('content_id', 'raw...
```suggestion for search_result in metadata.get('results') or []: ```
import itertools import json import re import urllib.parse from datetime import datetime from .common import InfoExtractor, SearchInfoExtractor from ..utils import ( ExtractorError, determine_ext, float_or_none, format_field, int_or_none, str_or_none, traverse_obj, try_get, unescape...
@@ -254,3 +422,91 @@ def _real_extract(self, url): return self.playlist_result( self._entries(channel_id, channel_name, self._TABS[tab]), f'{channel_id}-{tab}', f'{channel_name} - {tab.title()}', str_or_none(channel_info.get('description'))) + + +# E.g.: rkfnsearch5:"\"zelenko\"" or r...
yt_dlp/extractor/rokfin.py
26
Python
0.571
suggestion
85
51
411
false
[Rokfin] Search & login
2,992
yt-dlp/yt-dlp
132,642
Python
pukkandan
P-reducible
_search_engine_access_url = None _search_engine_access_key = None def _real_initialize(self): self._search_engine_access_url = self._downloader.cache.load(self._CACHE_SECTION_NAME, 'url') self._search_engine_access_key = self._downloader.cache.load(self._CACHE_SECTION_NAME, 'key') i...
```suggestion total_pages = None for page_number in itertools.count(1): search_results = self._run_search_query( data={'query': query, 'page': {'size': 100, 'current': page_number}}, ```
import itertools import json import re import urllib.parse from datetime import datetime from .common import InfoExtractor, SearchInfoExtractor from ..utils import ( ExtractorError, determine_ext, float_or_none, format_field, int_or_none, str_or_none, traverse_obj, try_get, unescape...
@@ -254,3 +422,91 @@ def _real_extract(self, url): return self.playlist_result( self._entries(channel_id, channel_name, self._TABS[tab]), f'{channel_id}-{tab}', f'{channel_name} - {tab.title()}', str_or_none(channel_info.get('description'))) + + +# E.g.: rkfnsearch5:"\"zelenko\"" or r...
yt_dlp/extractor/rokfin.py
26
Python
0.786
suggestion
235
51
411
false
[Rokfin] Search & login
2,992
yt-dlp/yt-dlp
132,642
Python
pukkandan
P-reducible
def _real_initialize(self): self._search_engine_access_url = self._downloader.cache.load(self._CACHE_SECTION_NAME, 'url') self._search_engine_access_key = self._downloader.cache.load(self._CACHE_SECTION_NAME, 'key') if not self._search_engine_access_url or not self._search_engine_access_key...
```suggestion note='Downloading search results page %d%s' % (page_number, f' of ~{total_pages}' if total_pages and total_pages >= page_number else '')) ``` OR ```suggestion note='Downloading search results page %d%s' % (page_number, format_field(total_pages, template=' of ~%d'))) `...
import itertools import json import re import urllib.parse from datetime import datetime from .common import InfoExtractor, SearchInfoExtractor from ..utils import ( ExtractorError, determine_ext, float_or_none, format_field, int_or_none, str_or_none, traverse_obj, try_get, unescape...
@@ -254,3 +422,91 @@ def _real_extract(self, url): return self.playlist_result( self._entries(channel_id, channel_name, self._TABS[tab]), f'{channel_id}-{tab}', f'{channel_name} - {tab.title()}', str_or_none(channel_info.get('description'))) + + +# E.g.: rkfnsearch5:"\"zelenko\"" or r...
yt_dlp/extractor/rokfin.py
26
Python
0.857
suggestion
404
51
411
false
[Rokfin] Search & login
2,992
yt-dlp/yt-dlp
132,642
Python
pukkandan
P-reducible
for page_number in itertools.count(1): query_data['page']['current'] = page_number search_results = self._run_search_query( data=query_data, note='Downloading search results page %d%s' % (page_number, format_field(total_pages, template=' of ~%d') if total_...
DRY You can instead do: ```py for attempt in range(2): search_results = self._download_json(..., errnote=False, ...) if search_results: return search_results if not attempt: ... = self._get_search_engine_access_credentials() raise ExtractorError(...) ```
import itertools import json import re import urllib.parse from datetime import datetime from .common import InfoExtractor, SearchInfoExtractor from ..utils import ( ExtractorError, determine_ext, float_or_none, format_field, int_or_none, str_or_none, traverse_obj, try_get, unescape...
@@ -254,3 +422,91 @@ def _real_extract(self, url): return self.playlist_result( self._entries(channel_id, channel_name, self._TABS[tab]), f'{channel_id}-{tab}', f'{channel_name} - {tab.title()}', str_or_none(channel_info.get('description'))) + + +# E.g.: rkfnsearch5:"\"zelenko\"" or r...
yt_dlp/extractor/rokfin.py
26
Python
1
security
294
50
411
false
[Rokfin] Search & login
2,992
yt-dlp/yt-dlp
132,642
Python
pukkandan
P-reducible
video_id_ind, video_type = self._TYPES.get(traverse_obj(search_result, ('content_type', 'raw')), (None, None)) video_id = traverse_obj(search_result, video_id_ind, expected_type=int_or_none) if not video_id or not video_type: self.write_debug(msg=f'ski...
```suggestion search_results = self._download_json( self._search_engine_access_url, self._SEARCH_KEY, note=note, errnote=False, fatal=False, encoding='utf-8', data=json.dumps(data).encode('utf-8'), headers={'authorization': self._access_key}) ``` also, is `encoding='utf-8'` needed?
import itertools import json import re import urllib.parse from datetime import datetime from .common import InfoExtractor, SearchInfoExtractor from ..utils import ( ExtractorError, determine_ext, float_or_none, format_field, int_or_none, str_or_none, traverse_obj, try_get, unescape...
@@ -254,3 +422,91 @@ def _real_extract(self, url): return self.playlist_result( self._entries(channel_id, channel_name, self._TABS[tab]), f'{channel_id}-{tab}', f'{channel_name} - {tab.title()}', str_or_none(channel_info.get('description'))) + + +# E.g.: rkfnsearch5:"\"zelenko\"" or r...
yt_dlp/extractor/rokfin.py
26
Python
0.786
security
319
51
411
false
[Rokfin] Search & login
2,992
yt-dlp/yt-dlp
132,642
Python
pukkandan
P-reducible
total_pages = traverse_obj(search_results, ('meta', 'page', 'total_pages'), expected_type=int_or_none) yield from get_video_data(search_results) if not search_results.get('results'): return def _run_search_query(self, data, note, errnote): data_bytes = js...
```suggestion for js_file_path in re.finditer(r'<script[^>]+src\s*=\s*"(?P<path>/static/js/[^">]+)"', notfound_err_page): ```
import itertools import json import re import urllib.parse from datetime import datetime from .common import InfoExtractor, SearchInfoExtractor from ..utils import ( ExtractorError, determine_ext, float_or_none, format_field, int_or_none, str_or_none, traverse_obj, try_get, unescape...
@@ -254,3 +422,91 @@ def _real_extract(self, url): return self.playlist_result( self._entries(channel_id, channel_name, self._TABS[tab]), f'{channel_id}-{tab}', f'{channel_name} - {tab.title()}', str_or_none(channel_info.get('description'))) + + +# E.g.: rkfnsearch5:"\"zelenko\"" or r...
yt_dlp/extractor/rokfin.py
26
Python
0.714
suggestion
135
44
411
false
[Rokfin] Search & login
2,992
yt-dlp/yt-dlp
132,642
Python
pukkandan
P-reducible
return def _run_search_query(self, data, note, errnote): data_bytes = json.dumps(data).encode('utf-8') search_results = self._download_json( self._search_engine_access_url, self._SEARCH_KEY, note=note, errnote=errnote, fatal=False, encoding='utf-8', data=data...
```suggestion js_content = self._download_webpage( self._BASE_URL + js_file_path.group('path'), video_id, note='Downloading JavaScript file', fatal=False) or '' ``` set `video_id` to `None` in real_initialize, but must be provided when running from real_extract
import itertools import json import re import urllib.parse from datetime import datetime from .common import InfoExtractor, SearchInfoExtractor from ..utils import ( ExtractorError, determine_ext, float_or_none, format_field, int_or_none, str_or_none, traverse_obj, try_get, unescape...
@@ -254,3 +422,91 @@ def _real_extract(self, url): return self.playlist_result( self._entries(channel_id, channel_name, self._TABS[tab]), f'{channel_id}-{tab}', f'{channel_name} - {tab.title()}', str_or_none(channel_info.get('description'))) + + +# E.g.: rkfnsearch5:"\"zelenko\"" or r...
yt_dlp/extractor/rokfin.py
26
Python
0.857
refactor
310
41
411
false
[Rokfin] Search & login
2,992
yt-dlp/yt-dlp
132,642
Python
pukkandan
P-reducible
search_results = self._download_json( self._search_engine_access_url, self._SEARCH_KEY, note=note, errnote=errnote, fatal=False, encoding='utf-8', data=data_bytes, headers={'authorization': self._search_engine_access_key}) if search_results is not False: return search...
```suggestion name='Search engine URL', default=None, group='url') ``` default implies non-fatal. same below
import itertools import json import re import urllib.parse from datetime import datetime from .common import InfoExtractor, SearchInfoExtractor from ..utils import ( ExtractorError, determine_ext, float_or_none, format_field, int_or_none, str_or_none, traverse_obj, try_get, unescape...
@@ -254,3 +422,91 @@ def _real_extract(self, url): return self.playlist_result( self._entries(channel_id, channel_name, self._TABS[tab]), f'{channel_id}-{tab}', f'{channel_name} - {tab.title()}', str_or_none(channel_info.get('description'))) + + +# E.g.: rkfnsearch5:"\"zelenko\"" or r...
yt_dlp/extractor/rokfin.py
26
Python
0.714
suggestion
131
37
411
false
[Rokfin] Search & login
2,992
yt-dlp/yt-dlp
132,642
Python
pukkandan
P-reducible
return search_results self.write_debug('updating access credentials') self._search_engine_access_url = self._search_engine_access_key = None self._downloader.cache.store(self._CACHE_SECTION_NAME, 'url', None) self._downloader.cache.store(self._CACHE_SECTION_NAME, 'key', None)...
```suggestion r'REACT_APP_SEARCH_KEY\s*:\s*"(?P<key>[^"]+)"', js_content, ``` why does everyone use * when the match must not be empty 😫
import itertools import json import re import urllib.parse from datetime import datetime from .common import InfoExtractor, SearchInfoExtractor from ..utils import ( ExtractorError, determine_ext, float_or_none, format_field, int_or_none, str_or_none, traverse_obj, try_get, unescape...
@@ -254,3 +422,91 @@ def _real_extract(self, url): return self.playlist_result( self._entries(channel_id, channel_name, self._TABS[tab]), f'{channel_id}-{tab}', f'{channel_name} - {tab.title()}', str_or_none(channel_info.get('description'))) + + +# E.g.: rkfnsearch5:"\"zelenko\"" or r...
yt_dlp/extractor/rokfin.py
26
Python
0.786
suggestion
160
33
411
false
[Rokfin] Search & login
2,992
yt-dlp/yt-dlp
132,642
Python
pukkandan
P-reducible
data_bytes = json.dumps(data).encode('utf-8') search_results = self._download_json( self._search_engine_access_url, self._SEARCH_KEY, note=note, errnote=errnote, fatal=False, encoding='utf-8', data=data_bytes, headers={'authorization': self._search_engine_access_key}) if ...
```suggestion r'REACT_APP_ENDPOINT_BASE\s*:\s*"(?P<url>[^"]+)"', js_content, ```
import itertools import json import re import urllib.parse from datetime import datetime from .common import InfoExtractor, SearchInfoExtractor from ..utils import ( ExtractorError, determine_ext, float_or_none, format_field, int_or_none, str_or_none, traverse_obj, try_get, unescape...
@@ -254,3 +422,91 @@ def _real_extract(self, url): return self.playlist_result( self._entries(channel_id, channel_name, self._TABS[tab]), f'{channel_id}-{tab}', f'{channel_name} - {tab.title()}', str_or_none(channel_info.get('description'))) + + +# E.g.: rkfnsearch5:"\"zelenko\"" or r...
yt_dlp/extractor/rokfin.py
26
Python
0.714
suggestion
102
38
411
false
[Rokfin] Search & login
2,992
yt-dlp/yt-dlp
132,642
Python
pukkandan
P-reducible
self._search_engine_access_url = self._search_engine_access_key = None self._downloader.cache.store(self._CACHE_SECTION_NAME, 'url', None) self._downloader.cache.store(self._CACHE_SECTION_NAME, 'key', None) self._search_engine_access_url, self._search_engine_access_key = self._get_search...
```suggestion search_engine_access_key = f'Bearer {search_engine_access_key}' if search_engine_access_key else None ```
import itertools import json import re import urllib.parse from datetime import datetime from .common import InfoExtractor, SearchInfoExtractor from ..utils import ( ExtractorError, determine_ext, float_or_none, format_field, int_or_none, str_or_none, traverse_obj, try_get, unescape...
@@ -254,3 +422,91 @@ def _real_extract(self, url): return self.playlist_result( self._entries(channel_id, channel_name, self._TABS[tab]), f'{channel_id}-{tab}', f'{channel_name} - {tab.title()}', str_or_none(channel_info.get('description'))) + + +# E.g.: rkfnsearch5:"\"zelenko\"" or r...
yt_dlp/extractor/rokfin.py
26
Python
0.714
suggestion
137
31
411
false
[Rokfin] Search & login
2,992
yt-dlp/yt-dlp
132,642
Python
pukkandan
P-reducible
return self._download_json( self._search_engine_access_url, self._SEARCH_KEY, note=note, errnote=errnote, fatal=False, encoding='utf-8', data=data_bytes, headers={'authorization': self._search_engine_access_key}) or {} def _get_search_engine_access_credentials(self): notfoun...
```suggestion return search_engine_access_url, search_engine_access_key ```
import itertools import json import re import urllib.parse from datetime import datetime from .common import InfoExtractor, SearchInfoExtractor from ..utils import ( ExtractorError, determine_ext, float_or_none, format_field, int_or_none, str_or_none, traverse_obj, try_get, unescape...
@@ -254,3 +422,91 @@ def _real_extract(self, url): return self.playlist_result( self._entries(channel_id, channel_name, self._TABS[tab]), f'{channel_id}-{tab}', f'{channel_name} - {tab.title()}', str_or_none(channel_info.get('description'))) + + +# E.g.: rkfnsearch5:"\"zelenko\"" or r...
yt_dlp/extractor/rokfin.py
26
Python
0.571
suggestion
93
27
411
false
[Rokfin] Search & login
2,992
yt-dlp/yt-dlp
132,642
Python
pukkandan
P-reducible
self._search_engine_access_url = self._search_engine_access_key = None self._downloader.cache.store(self._CACHE_SECTION_NAME, 'url', None) self._downloader.cache.store(self._CACHE_SECTION_NAME, 'key', None) self._search_engine_access_url, self._search_engine_access_key = self._get_search...
You never replied to my previous comment about grouping the regex together
import itertools import json import re import urllib.parse from datetime import datetime from .common import InfoExtractor, SearchInfoExtractor from ..utils import ( ExtractorError, determine_ext, float_or_none, format_field, int_or_none, str_or_none, traverse_obj, try_get, unescape...
@@ -254,3 +422,91 @@ def _real_extract(self, url): return self.playlist_result( self._entries(channel_id, channel_name, self._TABS[tab]), f'{channel_id}-{tab}', f'{channel_name} - {tab.title()}', str_or_none(channel_info.get('description'))) + + +# E.g.: rkfnsearch5:"\"zelenko\"" or r...
yt_dlp/extractor/rokfin.py
26
Python
0.214
suggestion
74
31
411
false
[Rokfin] Search & login
2,992
yt-dlp/yt-dlp
132,642
Python
pukkandan
P-reducible
if is_last or (page_n > pages_total if pages_total else is_last is not False): return def _real_extract(self, url): channel_name = self._match_id(url) channel_info = self._download_json(f'{_API_BASE_URL}user/{channel_name}', channel_name) channel_id = channel_inf...
```suggestion class RokfinSearchIE(SearchInfoExtractor): IE_NAME = 'rokfin:search' IE_DESC = 'Rokfin Search' _SEARCH_KEY = 'rkfnsearch' _TYPES = { 'video': (('id', 'raw'), 'post'), 'audio': (('id', 'raw'), 'post'), 'stream': (("content_id", 'raw'), 'stream'), '...
import itertools import json import re import urllib.parse from datetime import datetime from .common import InfoExtractor, SearchInfoExtractor from ..utils import ( ExtractorError, determine_ext, float_or_none, format_field, int_or_none, str_or_none, traverse_obj, try_get, unescape...
@@ -254,3 +418,82 @@ def _real_extract(self, url): return self.playlist_result( self._entries(channel_id, channel_name, self._TABS[tab]), f'{channel_id}-{tab}', f'{channel_name} - {tab.title()}', str_or_none(channel_info.get('description'))) + + +# E.g.: rkfnsearch5:"\"zelenko\"" or r...
yt_dlp/extractor/rokfin.py
26
Python
1
refactor
432
51
411
false
[Rokfin] Search & login
2,992
yt-dlp/yt-dlp
132,642
Python
pukkandan
P-reducible
'author_id': comment.get('userId'), 'parent': 'root', 'like_count': int_or_none(comment.get('numLikes')), 'dislike_count': int_or_none(comment.get('numDislikes')), 'timestamp': unified_timestamp(comment.get('postedAt')) ...
```suggestion # https://openid.net/specs/openid-connect-core-1_0.html#CodeFlowAuth (Sec. 3.1) ```
'dislike_count': int_or_none(comment.get('numDislikes')), 'timestamp': unified_timestamp(comment.get('postedAt')) } pages_total = int_or_none(raw_comments.get('totalPages')) or None is_last = raw_comments.get('last') if not raw...
@@ -160,6 +169,157 @@ def _get_comments(self, video_id): if not raw_comments.get('content') or is_last or (page_n > pages_total if pages_total else is_last is not False): return + def _perform_login(self, username, password): + LOGIN_PAGE_URL = 'https://secure.rokfin.com/auth/r...
yt_dlp/extractor/rokfin.py
26
Python
0.714
security
107
51
51
false
[Rokfin] Search & login
2,992
yt-dlp/yt-dlp
132,642
Python
pukkandan
P-reducible
pages_total = int_or_none(raw_comments.get('totalPages')) or None is_last = raw_comments.get('last') if not raw_comments.get('content') or is_last or (page_n > pages_total if pages_total else is_last is not False): return def _perform_login(self, username, passwo...
unless you have a good reason, dont clear cookies
return def _perform_login(self, username, password): # https://openid.net/specs/openid-connect-core-1_0.html#CodeFlowAuth (Sec. 3.1) login_page = self._download_webpage( f'{self._AUTH_BASE}/auth?client_id=web&redirect_uri=https%3A%2F%2Frokfin.com%2Ffeed&response_mode=fra...
@@ -160,6 +169,157 @@ def _get_comments(self, video_id): if not raw_comments.get('content') or is_last or (page_n > pages_total if pages_total else is_last is not False): return + def _perform_login(self, username, password): + LOGIN_PAGE_URL = 'https://secure.rokfin.com/auth/r...
yt_dlp/extractor/rokfin.py
26
Python
0.071
suggestion
49
51
51
false
[Rokfin] Search & login
2,992
yt-dlp/yt-dlp
132,642
Python
pukkandan
P-reducible
pages_total = int_or_none(raw_comments.get('totalPages')) or None is_last = raw_comments.get('last') if not raw_comments.get('content') or is_last or (page_n > pages_total if pages_total else is_last is not False): return def _perform_login(self, username, passw...
seems unnecessary. The next `_download_webpage` will raise appropriate error
if not raw_comments.get('content') or is_last or (page_n > pages_total if pages_total else is_last is not False): return def _perform_login(self, username, password): # https://openid.net/specs/openid-connect-core-1_0.html#CodeFlowAuth (Sec. 3.1) login_page = self._downl...
@@ -160,6 +169,157 @@ def _get_comments(self, video_id): if not raw_comments.get('content') or is_last or (page_n > pages_total if pages_total else is_last is not False): return + def _perform_login(self, username, password): + LOGIN_PAGE_URL = 'https://secure.rokfin.com/auth/r...
yt_dlp/extractor/rokfin.py
26
Python
0.5
suggestion
76
51
51
false
[Rokfin] Search & login
2,992
yt-dlp/yt-dlp
132,642
Python
pukkandan
P-reducible
self._clear_cookies() return # Step 2 & 3: authentication resp_body = self._download_webpage( authentication_point_url, None, note='logging in', fatal=False, expected_status=404, encoding='utf-8', data=urlencode_postdata({'username': username, 'password':...
```suggestion access_mgmt_tokens = self._get_OAuth_tokens() if not access_mgmt_tokens: self._logout() return ```
'redirect_uri': 'https://rokfin.com/silent-check-sso.html', 'response_mode': 'fragment', 'response_type': 'code', 'scope': 'openid', }) self._access_mgmt_tokens = self._download_json( f'{self._AUTH_BASE}/token', None, ...
@@ -160,6 +169,157 @@ def _get_comments(self, video_id): if not raw_comments.get('content') or is_last or (page_n > pages_total if pages_total else is_last is not False): return + def _perform_login(self, username, password): + LOGIN_PAGE_URL = 'https://secure.rokfin.com/auth/r...
yt_dlp/extractor/rokfin.py
26
Python
0.714
security
157
51
51
false
[Rokfin] Search & login
2,992
yt-dlp/yt-dlp
132,642
Python
pukkandan
P-reducible
login_page = self._download_webpage(LOGIN_PAGE_URL, None, note='loading login page', fatal=False) if not login_page: return authentication_point_url = unescapeHTML(re.search(AUTHENTICATION_URL_REGEX_STEP_1, login_page).group('authentication_point_url')) if authentication_poin...
is there a reason logout is needed?
urlh = self._request_webpage( f'{self._AUTH_BASE}/auth', None, note='granting user authorization', errnote='user authorization rejected by Rokfin', query={ 'client_id': 'web', 'prompt': 'none', 'redirect_uri': 'https://rokfin.co...
@@ -160,6 +169,157 @@ def _get_comments(self, video_id): if not raw_comments.get('content') or is_last or (page_n > pages_total if pages_total else is_last is not False): return + def _perform_login(self, username, password): + LOGIN_PAGE_URL = 'https://secure.rokfin.com/auth/r...
yt_dlp/extractor/rokfin.py
26
Python
0.071
question
35
51
51
false
[Rokfin] Search & login
2,992
yt-dlp/yt-dlp
132,642
Python
pukkandan
P-reducible
for page_n in itertools.count(): raw_comments = self._download_json( f'{_API_BASE_URL}comment?postId={video_id[5:]}&page={page_n}&size=50', video_id, note=f'Downloading viewer comments page {page_n + 1}{format_field(pages_total, template=" of %s")}', f...
only used once, can be inlined
video_id, note=f'Downloading viewer comments page {page_n + 1}{format_field(pages_total, template=" of %s")}', fatal=False) or {} for comment in raw_comments.get('content') or []: yield { 'text': str_or_none(comment.get('comment')), ...
@@ -160,6 +169,157 @@ def _get_comments(self, video_id): if not raw_comments.get('content') or is_last or (page_n > pages_total if pages_total else is_last is not False): return + def _perform_login(self, username, password): + LOGIN_PAGE_URL = 'https://secure.rokfin.com/auth/r...
yt_dlp/extractor/rokfin.py
26
Python
0.143
suggestion
30
51
51
false
[Rokfin] Search & login
2,992
yt-dlp/yt-dlp
132,642
Python
pukkandan
P-reducible
return # Validation phase (step 8) skipped, i.e. # # (1) this extractor does not implement client-side ID-token validation; # (2) Rokfin does not supply Subject Identifier. self._access_mgmt_tokens = access_mgmt_tokens def _logout(self): LOGOUT_URL = 'h...
Why are you looking at ALL cookies in the jar?
def _get_auth_token(self): return try_get(self._access_mgmt_tokens, lambda x: ' '.join([x['token_type'], x['access_token']])) def _download_json_using_access_token(self, url_or_request, video_id, headers={}, query={}): assert 'authorization' not in headers headers = headers.copy() ...
@@ -160,6 +169,157 @@ def _get_comments(self, video_id): if not raw_comments.get('content') or is_last or (page_n > pages_total if pages_total else is_last is not False): return + def _perform_login(self, username, password): + LOGIN_PAGE_URL = 'https://secure.rokfin.com/auth/r...
yt_dlp/extractor/rokfin.py
26
Python
0.071
question
46
51
51
false
[Rokfin] Search & login
2,992
yt-dlp/yt-dlp
132,642
Python
pukkandan
P-reducible
# Validation phase (step 8) skipped, i.e. # # (1) this extractor does not implement client-side ID-token validation; # (2) Rokfin does not supply Subject Identifier. self._access_mgmt_tokens = access_mgmt_tokens def _logout(self): LOGOUT_URL = 'https://secure.rokfin...
expired cookies dont stay in the cookiejar. So u just need to check if the cookies exist
def _download_json_using_access_token(self, url_or_request, video_id, headers={}, query={}): assert 'authorization' not in headers headers = headers.copy() auth_token = self._get_auth_token() refresh_token = self._access_mgmt_tokens.get('refresh_token') if auth_token: ...
@@ -160,6 +169,157 @@ def _get_comments(self, video_id): if not raw_comments.get('content') or is_last or (page_n > pages_total if pages_total else is_last is not False): return + def _perform_login(self, username, password): + LOGIN_PAGE_URL = 'https://secure.rokfin.com/auth/r...
yt_dlp/extractor/rokfin.py
26
Python
0.214
suggestion
88
51
51
false
[Rokfin] Search & login
2,992
yt-dlp/yt-dlp
132,642
Python
pukkandan
P-reducible
# Validation phase (step 8) skipped, i.e. # # (1) this extractor does not implement client-side ID-token validation; # (2) Rokfin does not supply Subject Identifier. self._access_mgmt_tokens = access_mgmt_tokens def _logout(self): LOGOUT_URL = 'https://secure.rokfin...
I think this is what u want: ```suggestion return bool(traverse_obj( self._get_cookies('https://www.rokfin.com'), 'KEYCLOAK_IDENTITY', 'KEYCLOAK_IDENTITY_LEGACY', 'KEYCLOAK_SESSION', 'KEYCLOAK_SESSION_LEGACY')) ```
def _download_json_using_access_token(self, url_or_request, video_id, headers={}, query={}): assert 'authorization' not in headers headers = headers.copy() auth_token = self._get_auth_token() refresh_token = self._access_mgmt_tokens.get('refresh_token') if auth_token: ...
@@ -160,6 +169,157 @@ def _get_comments(self, video_id): if not raw_comments.get('content') or is_last or (page_n > pages_total if pages_total else is_last is not False): return + def _perform_login(self, username, password): + LOGIN_PAGE_URL = 'https://secure.rokfin.com/auth/r...
yt_dlp/extractor/rokfin.py
26
Python
0.786
suggestion
251
51
51
false
[Rokfin] Search & login
2,992
yt-dlp/yt-dlp
132,642
Python
pukkandan
P-reducible
self._download_webpage_handle(LOGOUT_URL, None, note='logging out', fatal=False, encoding='utf-8') if self._authentication_active(): self.write_debug('logout failed') self._clear_cookies() self._access_mgmt_tokens = None # No token revocation takes place during logout...
```suggestion json_string, urlh = self._download_webpage_handle(url_or_request, video_id), headers=headers, query=query, expected_status=401) ``` you don't need to add to each line you are logged in. It can be surmised from earlier messages
if not auth_token or urlh.code != 401 or refresh_token is None: return self._parse_json(json_string, video_id) self._access_mgmt_tokens = self._download_json( f'{self._AUTH_BASE}/token', video_id, note='User authorization expired or canceled by Rokfin. Re-authorizing...
@@ -160,6 +169,157 @@ def _get_comments(self, video_id): if not raw_comments.get('content') or is_last or (page_n > pages_total if pages_total else is_last is not False): return + def _perform_login(self, username, password): + LOGIN_PAGE_URL = 'https://secure.rokfin.com/auth/r...
yt_dlp/extractor/rokfin.py
26
Python
0.929
suggestion
264
51
51
false
[Rokfin] Search & login
2,992
yt-dlp/yt-dlp
132,642
Python
pukkandan
P-reducible
authorization_hdr_val = try_get(self._access_mgmt_tokens, lambda tokens: tokens['token_type'] + ' ' + tokens['access_token']) if authorization_hdr_val: headers['authorization'] = authorization_hdr_val json_string, urlh = self._download_webpage_handle( url_or_request, vide...
Have you observed re-logins helping with this site? If not, this is just overcomplicating things
_TYPES = { 'video': 'post', 'audio': 'post', 'stream': 'stream', 'dead_stream': 'stream', 'stack': 'stack', } def _get_video_data(self, metadata): for content in metadata.get('content') or []: media_type = self._TYPES.get(content.get('mediaType'))...
@@ -160,6 +169,157 @@ def _get_comments(self, video_id): if not raw_comments.get('content') or is_last or (page_n > pages_total if pages_total else is_last is not False): return + def _perform_login(self, username, password): + LOGIN_PAGE_URL = 'https://secure.rokfin.com/auth/r...
yt_dlp/extractor/rokfin.py
26
Python
0.214
question
96
51
51
false
[Rokfin] Search & login
2,992
yt-dlp/yt-dlp
132,642
Python
pukkandan
P-reducible
self._download_json( self._TOKEN_DISTRIBUTION_POINT_URL_STEP_6_7, video_id, note='Restoring lost authorization', errnote='Failed to restore authorization', fatal=False, data=urlencode_postdata({'grant_type': 'refresh_token', 'refresh_token': self._access_mgmt_...
```suggestion # From https://www.rokfin.com/static/js/2.*.chunk.js ```
class RokfinStackIE(RokfinPlaylistBaseIE): IE_NAME = 'rokfin:stack' IE_DESC = 'Rokfin Stacks' _VALID_URL = r'https?://(?:www\.)?rokfin\.com/stack/(?P<id>[^/]+)' _TESTS = [{ 'url': 'https://www.rokfin.com/stack/271/Tulsi-Gabbard-Portsmouth-Townhall-FULL--Feb-9-2020', 'playlist_count': 8...
@@ -160,6 +169,157 @@ def _get_comments(self, video_id): if not raw_comments.get('content') or is_last or (page_n > pages_total if pages_total else is_last is not False): return + def _perform_login(self, username, password): + LOGIN_PAGE_URL = 'https://secure.rokfin.com/auth/r...
yt_dlp/extractor/rokfin.py
26
Python
0.571
suggestion
80
51
51
false
[Rokfin] Search & login
2,992
yt-dlp/yt-dlp
132,642
Python
pukkandan
P-reducible
return self._download_json( url_or_request, video_id, note='Downloading JSON metadata' + (' [logged in]' if 'authorization' in headers else ''), errnote='Unable to download JSON metadata' + (' [logged in]' if 'authorization' in headers else ''), headers=headers, query=query) ...
1. why is this non-fatal? 2. If you don't need the webpage content, use _request_webpage 3. _request/download_webpage accepts a `query` param. No need of the messy URL manipulations above
}] def _real_extract(self, url): list_id = self._match_id(url) return self.playlist_result(self._get_video_data( self._download_json(f'{_API_BASE_URL}stack/{list_id}', list_id)), list_id) class RokfinChannelIE(RokfinPlaylistBaseIE): IE_NAME = 'rokfin:channel' IE_DESC = 'Ro...
@@ -160,6 +169,157 @@ def _get_comments(self, video_id): if not raw_comments.get('content') or is_last or (page_n > pages_total if pages_total else is_last is not False): return + def _perform_login(self, username, password): + LOGIN_PAGE_URL = 'https://secure.rokfin.com/auth/r...
yt_dlp/extractor/rokfin.py
26
Python
0.571
suggestion
189
51
51
false
[Rokfin] Search & login
2,992
yt-dlp/yt-dlp
132,642
Python
pukkandan
P-reducible
# https://openid.net/specs/openid-connect-core-1_0.html#CodeFlowAuth (Sec. 3.1.1) # Steps 4 & 5 authorize yt-dlp to act on user's behalf. # random_str() came from https://www.rokfin.com/static/js/2.*.chunk.js def random_str(): rnd_lst = [random.choice('0123456789abcdef') fo...
shouldn't this be a warning/error?
IE_NAME = 'rokfin:channel' IE_DESC = 'Rokfin Channels' _VALID_URL = r'https?://(?:www\.)?rokfin\.com/(?!((feed/?)|(discover/?)|(channels/?))$)(?P<id>[^/]+)/?$' _TESTS = [{ 'url': 'https://rokfin.com/TheConvoCouch', 'playlist_mincount': 100, 'info_dict': { 'id': '12071...
@@ -160,6 +169,157 @@ def _get_comments(self, video_id): if not raw_comments.get('content') or is_last or (page_n > pages_total if pages_total else is_last is not False): return + def _perform_login(self, username, password): + LOGIN_PAGE_URL = 'https://secure.rokfin.com/auth/r...
yt_dlp/extractor/rokfin.py
26
Python
0.286
question
34
51
51
false
[Rokfin] Search & login
2,992
yt-dlp/yt-dlp
132,642
Python
pukkandan
P-reducible
rnd_lst[8] = rnd_lst[13] = rnd_lst[18] = rnd_lst[23] = '-' return ''.join(rnd_lst) user_consent_url_step_4_5 = PARTIAL_USER_CONSENT_URL_STEP_4_5._replace(query=urllib.parse.urlencode((lambda d: d.update(state=random_str(), nonce=random_str()) or d)(dict(urllib.parse.parse_qsl(PARTIAL_US...
dont leave debugging code in...
'description': 'md5:bb622b1bca100209b91cd685f7847f06', }, }] _TABS = { 'new': 'posts', 'top': 'top', 'videos': 'video', 'podcasts': 'audio', 'streams': 'stream', 'stacks': 'stack', } def _real_initialize(self): self._validate_...
@@ -160,6 +169,157 @@ def _get_comments(self, video_id): if not raw_comments.get('content') or is_last or (page_n > pages_total if pages_total else is_last is not False): return + def _perform_login(self, username, password): + LOGIN_PAGE_URL = 'https://secure.rokfin.com/auth/r...
yt_dlp/extractor/rokfin.py
26
Python
0.214
bug
31
51
51
false
[Rokfin] Search & login
2,992
yt-dlp/yt-dlp
132,642
Python
pukkandan
P-reducible
tab = self._configuration_arg('tab', default=['new'])[0] return self.playlist_result( self._entries(channel_id, channel_name, self._TABS[tab]), f'{channel_id}-{tab}', f'{channel_name} - {tab.title()}', str_or_none(channel_info.get('description'))) class RokfinSearchIE(SearchIn...
if this is meant to be the equivalent of typing `"zelenko"` in the site, it should be ```suggestion _TESTS = [{ 'url': 'rkfnsearch5:"zelenko"', 'playlist_count': 5, 'info_dict': { 'id': '"zelenko"', 'title': '"zelenko"', } }] ```
yield from self._get_video_data(metadata) pages_total = int_or_none(metadata.get('totalPages')) or None is_last = metadata.get('last') if is_last or (page_n > pages_total if pages_total else is_last is not False): return def _real_extract(self, url):...
@@ -254,3 +324,85 @@ def _real_extract(self, url): return self.playlist_result( self._entries(channel_id, channel_name, self._TABS[tab]), f'{channel_id}-{tab}', f'{channel_name} - {tab.title()}', str_or_none(channel_info.get('description'))) + + +class RokfinSearchIE(SearchInfoExtract...
yt_dlp/extractor/rokfin.py
26
Python
0.857
suggestion
303
51
51
false
[Rokfin] Search & login
2,992
yt-dlp/yt-dlp
132,642
Python
pukkandan
P-reducible
'author': str_or_none(comment.get('name')), 'id': comment.get('commentId'), 'author_id': comment.get('userId'), 'parent': 'root', 'like_count': int_or_none(comment.get('numLikes')), 'dislike_count': i...
1. line too long 2. Is expected=True even when not wrong password?
'author_id': comment.get('userId'), 'parent': 'root', 'like_count': int_or_none(comment.get('numLikes')), 'dislike_count': int_or_none(comment.get('numDislikes')), 'timestamp': unified_timestamp(comment.get('postedAt')) ...
@@ -160,6 +168,66 @@ def _get_comments(self, video_id): if not raw_comments.get('content') or is_last or (page_n > pages_total if pages_total else is_last is not False): return + def _perform_login(self, username, password): + LOGIN_PAGE_URL = 'https://secure.rokfin.com/auth/re...
yt_dlp/extractor/rokfin.py
26
Python
0.214
bug
67
51
51
false
[Rokfin] Search & login
2,992
yt-dlp/yt-dlp
132,642
Python
pukkandan
P-reducible
else fcntl.LOCK_EX | fcntl.LOCK_NB) def _unlock_file(f): try: fcntl.flock(f, fcntl.LOCK_UN) except OSError: fcntl.lockf(f, fcntl.LOCK_UN) except ImportError: UNSUPPORTED_MSG = 'file locking is not supported on this...
where did u get these flags? They seem different from what io.open uses https://github.com/python/cpython/blob/f4c03484da59049eb62a9bf7777b963e2267d187/Modules/_io/fileio.c#L207
UnlockFileEx.argtypes = [ ctypes.wintypes.HANDLE, # hFile ctypes.wintypes.DWORD, # dwReserved ctypes.wintypes.DWORD, # nNumberOfBytesToLockLow ctypes.wintypes.DWORD, # nNumberOfBytesToLockHigh ctypes.POINTER(OVERLAPPED) # Overlapped ] UnlockFileEx....
@@ -2178,8 +2178,13 @@ class locked_file(object): _closed = False def __init__(self, filename, mode, block=True, encoding=None): - assert mode in ['r', 'rb', 'a', 'ab', 'w', 'wb'] - self.f = io.open(filename, mode, encoding=encoding) + if mode not in ['r', 'rb', 'a', 'ab', 'w', 'wb']: +...
yt_dlp/utils.py
26
Python
0.429
question
177
51
51
false
Do not O_TRUNC writeable files before obtaining an advisory lock
2,994
yt-dlp/yt-dlp
132,642
Python
pukkandan
jakeogh
subtitles = self.getSubtitles() self.assertEqual(set(subtitles.keys()), set(['en', 'es-ES'])) self.assertEqual(md5(subtitles['en']), 'a3f4d25963fdeace838f327097c13265') self.assertEqual(md5(subtitles['es-ES']), '57e9dad365fd0fbaf0468eac4949f189') def test_subtitles_srt_format(self):...
Can't a extractor download test check these? I'd prefer not to have extractors define their own additional tests. These often tend to get left behind when extractor is updated
#!/usr/bin/env python3 from __future__ import unicode_literals # Allow direct execution import os import sys import unittest sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from test.helper import FakeYDL, md5, is_download_test from yt_dlp.extractor import ( YoutubeIE, Dailym...
@@ -410,5 +411,39 @@ def test_subtitles_sami_format(self): self.assertIn(md5(subtitles['en']), ['4256b16ac7da6a6780fafd04294e85cd']) +@is_download_test +class TestPanoptoSubtitles(BaseTestSubtitles): + url = 'https://na-training-1.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=8285224a-9a2b-4957-84f2-a...
test/test_subtitles.py
26
Python
0.429
refactor
175
29
415
false
[panopto] Extract slides + subtitles for videos without m3u8 subs
3,009
yt-dlp/yt-dlp
132,642
Python
pukkandan
coletdjnz
for timestamp in timestamps or []: caption = timestamp.get('Caption') start, duration = int_or_none(timestamp.get('Time')), int_or_none(timestamp.get('Duration')) if not caption or start is None or duration is None: continue chapters.append({ ...
```suggestion if None not in (obj_pid, session_id, abs_time): ```
'InvocationID': invocation_id, 'PlaybackSpeed': 1, 'SecondsListened': duration - 1, 'SecondsRejected': 0, 'StartPosition': 0, 'StartReason': 2, 'StopRea...
@@ -178,19 +253,82 @@ def _mark_watched(self, base_url, video_id, delivery_info): note='Marking watched', errnote='Unable to mark watched') @staticmethod - def _extract_chapters(delivery): + def _extract_chapters(timestamps): chapters = [] - for timestamp in delivery.get('T...
yt_dlp/extractor/panopto.py
26
Python
0.571
suggestion
79
51
51
false
[panopto] Extract slides + subtitles for videos without m3u8 subs
3,009
yt-dlp/yt-dlp
132,642
Python
pukkandan
coletdjnz
'超清': { 'width': 1280, 'height': 720, }, '流畅': { 'width': 800, 'height': 480 } } def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id=video_id) json_str...
what if this returns None? Ur code will fail
}] _RESOLUTION = { '蓝光4M': { 'width': 1920, 'height': 1080, }, '超清': { 'width': 1280, 'height': 720, }, '流畅': { 'width': 800, 'height': 480 } } def _real_extract(self, url): ...
@@ -0,0 +1,131 @@ +# coding: utf-8 +from __future__ import unicode_literals + +import hashlib +import random +from html import unescape + +from yt_dlp.compat import compat_urlparse, compat_b64decode + +from yt_dlp.utils import ExtractorError, try_get, str_or_none, int_or_none, js_to_json, update_url_query + +from yt_dl...
yt_dlp/extractor/huya.py
26
Python
0.071
bug
45
51
51
false
[Huya] Add new extractor
3,035
yt-dlp/yt-dlp
132,642
Python
Ashish0804
hatienl0i2612
for stream_info in stream_info_list: stream_url = stream_info.get('sFlvUrl') if not stream_url: continue stream_name = stream_info.get('sStreamName') re_secret = not screen_type and live_source_type in (0, 8, 13) params = dict(compat_ur...
```suggestion **self._RESOLUTION.get(si.get('sDisplayName'), {}), ```
if not stream_url: continue stream_name = stream_info.get('sStreamName') re_secret = not screen_type and live_source_type in (0, 8, 13) params = dict(compat_urlparse.parse_qsl(unescapeHTML(stream_info['sFlvAntiCode']))) fm, ss = '', '' ...
@@ -0,0 +1,140 @@ +# coding: utf-8 +from __future__ import unicode_literals + +import hashlib +import random +from html import unescape + +from ..compat import compat_urlparse, compat_b64decode + +from ..utils import ( + ExtractorError, + try_get, + str_or_none, + int_or_none, + js_to_json, + update_u...
yt_dlp/extractor/huya.py
26
Python
0.571
suggestion
91
51
51
false
[Huya] Add new extractor
3,035
yt-dlp/yt-dlp
132,642
Python
pukkandan
hatienl0i2612
'height': 720, }, '流畅': { 'width': 800, 'height': 480 } } def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id=video_id) json_stream = self._search_regex(r'"stream":\s+"([a...
since u didn't answer, I assume this is not expected In that case, why not just: ```suggestion stream_info_list = stream_data['data'][0]['gameStreamInfoList'] ```
'height': 720, }, '流畅': { 'width': 800, 'height': 480 } } def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id=video_id) json_stream = self._search_regex(r'"stream":\s+"([a...
@@ -0,0 +1,140 @@ +# coding: utf-8 +from __future__ import unicode_literals + +import hashlib +import random + +from ..compat import compat_urlparse, compat_b64decode + +from ..utils import ( + ExtractorError, + int_or_none, + js_to_json, + str_or_none, + try_get, + unescapeHTML, + update_url_query...
yt_dlp/extractor/huya.py
26
Python
0.714
suggestion
174
51
51
false
[Huya] Add new extractor
3,035
yt-dlp/yt-dlp
132,642
Python
pukkandan
hatienl0i2612
# coding: utf-8 from __future__ import unicode_literals from yt_dlp.extractor.common import InfoExtractor from yt_dlp.compat import ( compat_kwargs, compat_str, ) from yt_dlp.utils import ( ExtractorError, int_or_none, parse_iso8601, urljoin, try_get, ) class WASDTVBaseIE(InfoExtractor): ...
why is this needed? u are not even using fata=false the code will never show ur ExtractorError message.
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..utils import ( ExtractorError, int_or_none, parse_iso8601, traverse_obj, try_get, ) class WASDTVBaseIE(InfoExtractor): def _fetch(self, path, video_id, description, query={}): response = ...
@@ -0,0 +1,176 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from yt_dlp.extractor.common import InfoExtractor +from yt_dlp.compat import ( + compat_kwargs, + compat_str, +) +from yt_dlp.utils import ( + ExtractorError, + int_or_none, + parse_iso8601, + urljoin, + try_get, +) + + ...
yt_dlp/extractor/wasdtv.py
22
Python
0.571
refactor
105
47
47
false
[WasdTV] Add extractor
3,045
yt-dlp/yt-dlp
132,642
Python
Ashish0804
hatienl0i2612
# coding: utf-8 from __future__ import unicode_literals from yt_dlp.extractor.common import InfoExtractor from yt_dlp.compat import ( compat_kwargs, compat_str, ) from yt_dlp.utils import ( ExtractorError, int_or_none, parse_iso8601, urljoin, try_get, ) class WASDTVBaseIE(InfoExtractor): ...
only used once, no need for it to be class var
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..utils import ( ExtractorError, int_or_none, parse_iso8601, traverse_obj, try_get, ) class WASDTVBaseIE(InfoExtractor): def _fetch(self, path, video_id, description, query={}): response = ...
@@ -0,0 +1,176 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from yt_dlp.extractor.common import InfoExtractor +from yt_dlp.compat import ( + compat_kwargs, + compat_str, +) +from yt_dlp.utils import ( + ExtractorError, + int_or_none, + parse_iso8601, + urljoin, + try_get, +) + + ...
yt_dlp/extractor/wasdtv.py
20
Python
0.143
suggestion
47
45
45
false
[WasdTV] Add extractor
3,045
yt-dlp/yt-dlp
132,642
Python
Ashish0804
hatienl0i2612
if error: raise ExtractorError(f'{self.IE_NAME} returned error: {error}', expected=True) return response.get('result') def _extract_thumbnails(self, thumbnails_dict): if not thumbnails_dict: return None thumbnails = [] for index, thumbnail_size in enu...
when these are None, u will get error upon using .get If they are required, make them fatal else do or {}
traverse_obj(thumbnails_dict, (('small', 'medium', 'large'),))) if url] def _real_extract(self, url): container = self._get_container(url) stream = traverse_obj(container, ('media_container_streams', 0)) media = try_get(stream, lambda x: x['stream_media'][0]) if not medi...
@@ -0,0 +1,176 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from yt_dlp.extractor.common import InfoExtractor +from yt_dlp.compat import ( + compat_kwargs, + compat_str, +) +from yt_dlp.utils import ( + ExtractorError, + int_or_none, + parse_iso8601, + urljoin, + try_get, +) + + ...
yt_dlp/extractor/wasdtv.py
26
Python
0.5
suggestion
106
51
51
false
[WasdTV] Add extractor
3,045
yt-dlp/yt-dlp
132,642
Python
Ashish0804
hatienl0i2612
return None thumbnails = [] for index, thumbnail_size in enumerate(self._THUMBNAIL_SIZES): thumbnail_url = thumbnails_dict.get(thumbnail_size) if not thumbnail_url: continue thumbnails.append({ 'url': thumbnail_url, ...
```suggestion 'id': str(video_id), ```
if not media: raise ExtractorError('Can not extract media data.', expected=True) media_meta = media.get('media_meta') media_url, is_live = self._get_media_url(media_meta) video_id = media.get('media_id') or container.get('media_container_id') formats, subtitles = self...
@@ -0,0 +1,176 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from yt_dlp.extractor.common import InfoExtractor +from yt_dlp.compat import ( + compat_kwargs, + compat_str, +) +from yt_dlp.utils import ( + ExtractorError, + int_or_none, + parse_iso8601, + urljoin, + try_get, +) + + ...
yt_dlp/extractor/wasdtv.py
26
Python
0.571
suggestion
52
51
51
false
[WasdTV] Add extractor
3,045
yt-dlp/yt-dlp
132,642
Python
Ashish0804
hatienl0i2612
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..utils import ( ExtractorError, int_or_none, parse_iso8601, urljoin, try_get, ) class WASDTVBaseIE(InfoExtractor): _API_BASE = 'https://wasd.tv/api/' def _fetch(self, path, video_id, descripti...
```suggestion def _fetch(self, path, video_id, description, query={}): response = self._download_json( f'https://wasd.tv/api/{path}', video_id, query=query, note=f'Downloading {description} metadata', errnote=f'Unable to download {description} metadata') ```
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..utils import ( ExtractorError, int_or_none, parse_iso8601, traverse_obj, try_get, ) class WASDTVBaseIE(InfoExtractor): def _fetch(self, path, video_id, description, query={}): response = ...
@@ -0,0 +1,169 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from .common import InfoExtractor +from ..utils import ( + ExtractorError, + int_or_none, + parse_iso8601, + urljoin, + try_get, +) + + +class WASDTVBaseIE(InfoExtractor): + _API_BASE = 'https://wasd.tv/api/' + + def _fe...
yt_dlp/extractor/wasdtv.py
23
Python
0.786
suggestion
312
48
48
false
[WasdTV] Add extractor
3,045
yt-dlp/yt-dlp
132,642
Python
pukkandan
hatienl0i2612
def _fetch(self, path, video_id, description, query={}): response = self._download_json( urljoin(self._API_BASE, path), video_id=video_id, note=f'Downloading {description} metadata', errnote=f'Unable to download {description} metadata', query=quer...
```suggestion return [{ 'url': url, 'preference': index, } for index, url in enumerate( traverse_obj(thumbnails_dict, (('small', 'medium', 'large'),))) if url] ```
def _fetch(self, path, video_id, description, query={}): response = self._download_json( f'https://wasd.tv/api/{path}', video_id, query=query, note=f'Downloading {description} metadata', errnote=f'Unable to download {description} metadata') error = response.get('e...
@@ -0,0 +1,169 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from .common import InfoExtractor +from ..utils import ( + ExtractorError, + int_or_none, + parse_iso8601, + urljoin, + try_get, +) + + +class WASDTVBaseIE(InfoExtractor): + _API_BASE = 'https://wasd.tv/api/' + + def _fe...
yt_dlp/extractor/wasdtv.py
26
Python
0.857
suggestion
221
51
51
false
[WasdTV] Add extractor
3,045
yt-dlp/yt-dlp
132,642
Python
pukkandan
hatienl0i2612
video_id=video_id, note=f'Downloading {description} metadata', errnote=f'Unable to download {description} metadata', query=query) error = response.get('error') if error: raise ExtractorError(f'{self.IE_NAME} returned error: {error}', expected=T...
Not a amndatory change, but fyi, this can be simplified to: ```suggestion stream = traverse_obj(container, ('media_container_streams', 0)) ```
errnote=f'Unable to download {description} metadata') error = response.get('error') if error: raise ExtractorError(f'{self.IE_NAME} returned error: {error}', expected=True) return response.get('result') def _extract_thumbnails(self, thumbnails_dict): return [...
@@ -0,0 +1,169 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from .common import InfoExtractor +from ..utils import ( + ExtractorError, + int_or_none, + parse_iso8601, + urljoin, + try_get, +) + + +class WASDTVBaseIE(InfoExtractor): + _API_BASE = 'https://wasd.tv/api/' + + def _fe...
yt_dlp/extractor/wasdtv.py
26
Python
0.786
suggestion
153
51
51
false
[WasdTV] Add extractor
3,045
yt-dlp/yt-dlp
132,642
Python
pukkandan
hatienl0i2612
class WASDTVClipIE(WASDTVBaseIE): IE_NAME = 'wasdtv:clip' _VALID_URL = r'https?://wasd\.tv/[^/#?]+/clips\?clip=(?P<id>\d+)$' _TESTS = [{ 'url': 'https://wasd.tv/spacemita/clips?clip=26804', 'md5': '818885e720143d7a4e776ff66fcff148', 'info_dict': { 'id': '26804', ...
```suggestion 'title': clip.get('clip_title') or self._og_search_title( self._download_webpage(url, clip_id, fatal=False)), ```
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..utils import ( ExtractorError, int_or_none, parse_iso8601, traverse_obj, try_get, ) class WASDTVBaseIE(InfoExtractor): def _fetch(self, path, video_id, description, query={}): response = ...
@@ -0,0 +1,169 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from .common import InfoExtractor +from ..utils import ( + ExtractorError, + int_or_none, + parse_iso8601, + urljoin, + try_get, +) + + +class WASDTVBaseIE(InfoExtractor): + _API_BASE = 'https://wasd.tv/api/' + + def _fe...
yt_dlp/extractor/wasdtv.py
26
Python
0.714
suggestion
158
33
162
false
[WasdTV] Add extractor
3,045
yt-dlp/yt-dlp
132,642
Python
pukkandan
hatienl0i2612
if not thumbnails_dict: return None thumbnails = [] for index, thumbnail_size in enumerate(['small', 'medium', 'large']): thumbnail_url = thumbnails_dict.get(thumbnail_size) if not thumbnail_url: continue thumbnails.append({ ...
```suggestion def _get_container(self, url): raise NotImplementedError('Must be defined in subclasses') def _get_media_url(self, media_meta): raise NotImplementedError('Must be defined in subclasses') ``` for self-documentation
} for index, url in enumerate( traverse_obj(thumbnails_dict, (('small', 'medium', 'large'),))) if url] def _real_extract(self, url): container = self._get_container(url) stream = traverse_obj(container, ('media_container_streams', 0)) media = try_get(stream, lambda x: x[...
@@ -0,0 +1,169 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from .common import InfoExtractor +from ..utils import ( + ExtractorError, + int_or_none, + parse_iso8601, + urljoin, + try_get, +) + + +class WASDTVBaseIE(InfoExtractor): + _API_BASE = 'https://wasd.tv/api/' + + def _fe...
yt_dlp/extractor/wasdtv.py
26
Python
0.929
suggestion
261
51
51
false
[WasdTV] Add extractor
3,045
yt-dlp/yt-dlp
132,642
Python
pukkandan
hatienl0i2612
class WASDTVRecordIE(WASDTVBaseIE): IE_NAME = 'wasdtv:record' _VALID_URL = r'https?://wasd\.tv/[^/#?]+/videos\?record=(?P<id>\d+)$' _TESTS = [{ 'url': 'https://wasd.tv/spacemita/videos?record=907755', 'md5': 'c9899dd85be4cc997816ff9f9ca516ce', 'info_dict': { 'id': '90682...
```suggestion return self._fetch( f'v2/media-containers/{container_id}', container_id, 'media container') ```
IE_NAME = 'wasdtv:record' _VALID_URL = r'https?://wasd\.tv/[^/#?]+/videos\?record=(?P<id>\d+)$' _TESTS = [{ 'url': 'https://wasd.tv/spacemita/videos?record=907755', 'md5': 'c9899dd85be4cc997816ff9f9ca516ce', 'info_dict': { 'id': '906825', 'ext': 'mp4', ...
@@ -0,0 +1,165 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from .common import InfoExtractor +from ..utils import ( + ExtractorError, + int_or_none, + parse_iso8601, + traverse_obj, + try_get, +) + + +class WASDTVBaseIE(InfoExtractor): + + def _fetch(self, path, video_id, descripti...
yt_dlp/extractor/wasdtv.py
26
Python
0.714
suggestion
132
51
51
false
[WasdTV] Add extractor
3,045
yt-dlp/yt-dlp
132,642
Python
pukkandan
hatienl0i2612
'timestamp': int, 'upload_date': r're:^\d{8}$', 'is_live': True, 'view_count': int, }, }] def _get_container(self, url): nickname = self._match_id(url) channel = self._fetch(f'channels/nicknames/{nickname}', video_id=nickname, description=...
```suggestion return media_meta['media_url'], True ```
'timestamp': int, 'upload_date': r're:^\d{8}$', 'is_live': True, 'view_count': int, }, }] def _get_container(self, url): nickname = self._match_id(url) channel = self._fetch(f'channels/nicknames/{nickname}', video_id=nickname, description=...
@@ -0,0 +1,165 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from .common import InfoExtractor +from ..utils import ( + ExtractorError, + int_or_none, + parse_iso8601, + traverse_obj, + try_get, +) + + +class WASDTVBaseIE(InfoExtractor): + + def _fetch(self, path, video_id, descripti...
yt_dlp/extractor/wasdtv.py
26
Python
0.571
suggestion
64
51
51
false
[WasdTV] Add extractor
3,045
yt-dlp/yt-dlp
132,642
Python
pukkandan
hatienl0i2612
'ext': 'mp4', 'title': 'Live 24/7 Music', 'description': '24&#x2F;7 Music', 'timestamp': int, 'upload_date': r're:^\d{8}$', 'is_live': True, 'view_count': int, }, }] def _get_container(self, url): nickname = sel...
Does this have `media_archive_url`? If not, `_get_media_url` is actually same for both the classes
'ext': 'mp4', 'title': 'Live 24/7 Music', 'description': '24&#x2F;7 Music', 'timestamp': int, 'upload_date': r're:^\d{8}$', 'is_live': True, 'view_count': int, }, }] def _get_container(self, url): nickname = sel...
@@ -0,0 +1,165 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from .common import InfoExtractor +from ..utils import ( + ExtractorError, + int_or_none, + parse_iso8601, + traverse_obj, + try_get, +) + + +class WASDTVBaseIE(InfoExtractor): + + def _fetch(self, path, video_id, descripti...
yt_dlp/extractor/wasdtv.py
26
Python
0.357
question
98
51
51
false
[WasdTV] Add extractor
3,045
yt-dlp/yt-dlp
132,642
Python
pukkandan
hatienl0i2612
'url': 'https://wasd.tv/24_7', 'info_dict': { 'id': '559738', 'ext': 'mp4', 'title': 'Live 24/7 Music', 'description': '24&#x2F;7 Music', 'timestamp': int, 'upload_date': r're:^\d{8}$', 'is_live': True, 'view...
```suggestion containers = self._fetch( 'v2/media-containers', channel_id, 'running media containers', query={ 'channel_id': channel_id, 'media_container_type': 'SINGLE', 'media_container_status': 'RUNNING', }) ```
'url': 'https://wasd.tv/24_7', 'info_dict': { 'id': '559738', 'ext': 'mp4', 'title': 'Live 24/7 Music', 'description': '24&#x2F;7 Music', 'timestamp': int, 'upload_date': r're:^\d{8}$', 'is_live': True, 'view...
@@ -0,0 +1,165 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from .common import InfoExtractor +from ..utils import ( + ExtractorError, + int_or_none, + parse_iso8601, + traverse_obj, + try_get, +) + + +class WASDTVBaseIE(InfoExtractor): + + def _fetch(self, path, video_id, descripti...
yt_dlp/extractor/wasdtv.py
26
Python
0.929
suggestion
314
51
51
false
[WasdTV] Add extractor
3,045
yt-dlp/yt-dlp
132,642
Python
pukkandan
hatienl0i2612
# changing the file size slightly and causing problems for some users. So # I decided to implement a suggested change and consider the file # completely downloaded if the file size differs less than 100 bytes from ...
Huh, shouldn't there be something after that comma?
# changing the file size slightly and causing problems for some users. So # I decided to implement a suggested change and consider the file # completely downloaded if the file size differs less than 100 bytes from ...
@@ -202,14 +197,16 @@ def establish_connection(): # Unexpected HTTP error raise raise RetryDownload(err) - except socket.timeout as err: - raise RetryDownload(err) - except socket.error as err: - if err.errno ...
yt_dlp/downloader/http.py
26
Python
0.286
question
51
51
51
false
[downloader/http] Make retrying more lenient
3,065
yt-dlp/yt-dlp
132,642
Python
Jules-A
coletdjnz
# subtitle = ' ' 'url': 'https://tver.jp/corner/f0068870', 'only_matching': True, }, { # landing page 'f' 'url': 'https://tver.jp/lp/f0009694', 'only_matching': True, }, { # landing page 'c' 'url': 'https://tver.jp/lp/c0000239', 'only_match...
y not just `if path == 'lp'` ?
# subtitle = ' ' 'url': 'https://tver.jp/corner/f0068870', 'only_matching': True, }, { 'url': 'https://tver.jp/lp/f0009694', 'only_matching': True, }, { 'url': 'https://tver.jp/lp/c0000239', 'only_matching': True, }, { 'url': 'https://tver.jp/t...
@@ -39,6 +51,10 @@ def _real_initialize(self): def _real_extract(self, url): path, video_id = self._match_valid_url(url).groups() + if path[0:2] == "lp":
yt_dlp/extractor/tver.py
26
Python
0.214
question
30
51
50
false
[TVer] Support landing page
3,075
yt-dlp/yt-dlp
132,642
Python
Ashish0804
vvto33
# videos are only available for 7 days _TESTS = [{ 'url': 'https://tver.jp/corner/f0062178', 'only_matching': True, }, { 'url': 'https://tver.jp/feature/f0062413', 'only_matching': True, }, { 'url': 'https://tver.jp/episode/79622438', 'only_matching': True...
```suggestion }, { 'url': 'https://tver.jp/lp/f0009694', 'only_matching': True, }, { 'url': 'https://tver.jp/lp/c0000239', 'only_matching': True, }, { 'url': 'https://tver.jp/tokyo2020/video/6264525510001', 'only_matching': True, ``` The comments sa...
# videos are only available for 7 days _TESTS = [{ 'url': 'https://tver.jp/corner/f0062178', 'only_matching': True, }, { 'url': 'https://tver.jp/feature/f0062413', 'only_matching': True, }, { 'url': 'https://tver.jp/episode/79622438', 'only_matching': True...
@@ -29,6 +29,18 @@ class TVerIE(InfoExtractor): # subtitle = ' ' 'url': 'https://tver.jp/corner/f0068870', 'only_matching': True, + }, { + # landing page 'f' + 'url': 'https://tver.jp/lp/f0009694', + 'only_matching': True, + }, { + # landing page 'c' + ...
yt_dlp/extractor/tver.py
26
Python
0.786
suggestion
348
51
51
false
[TVer] Support landing page
3,075
yt-dlp/yt-dlp
132,642
Python
pukkandan
vvto33
# subtitle = ' ' 'url': 'https://tver.jp/corner/f0068870', 'only_matching': True, }, { # landing page 'f' 'url': 'https://tver.jp/lp/f0009694', 'only_matching': True, }, { # landing page 'c' 'url': 'https://tver.jp/lp/c0000239', 'only_match...
```suggestion if path == 'lp': ```
# subtitle = ' ' 'url': 'https://tver.jp/corner/f0068870', 'only_matching': True, }, { 'url': 'https://tver.jp/lp/f0009694', 'only_matching': True, }, { 'url': 'https://tver.jp/lp/c0000239', 'only_matching': True, }, { 'url': 'https://tver.jp/t...
@@ -39,9 +51,11 @@ def _real_initialize(self): def _real_extract(self, url): path, video_id = self._match_valid_url(url).groups() - api_response = self._download_json( - 'https://api.tver.jp/v4/' + path, video_id, - query={'token': self._TOKEN}) + if path == "lp":
yt_dlp/extractor/tver.py
26
Python
0.429
suggestion
44
51
50
false
[TVer] Support landing page
3,075
yt-dlp/yt-dlp
132,642
Python
pukkandan
vvto33
'only_matching': True, }, { # landing page 'f' 'url': 'https://tver.jp/lp/f0009694', 'only_matching': True, }, { # landing page 'c' 'url': 'https://tver.jp/lp/c0000239', 'only_matching': True, }, { # TOKYO2020 'url': 'https://tver.jp/to...
```suggestion redirect_path = self._search_regex(r'to_href="([^"]+)', webpage, 'redirect path') ```
'only_matching': True, }, { 'url': 'https://tver.jp/lp/f0009694', 'only_matching': True, }, { 'url': 'https://tver.jp/lp/c0000239', 'only_matching': True, }, { 'url': 'https://tver.jp/tokyo2020/video/6264525510001', 'only_matching': True, }] _T...
@@ -39,9 +51,11 @@ def _real_initialize(self): def _real_extract(self, url): path, video_id = self._match_valid_url(url).groups() - api_response = self._download_json( - 'https://api.tver.jp/v4/' + path, video_id, - query={'token': self._TOKEN}) + if path == "lp": + ...
yt_dlp/extractor/tver.py
26
Python
0.714
suggestion
113
51
48
false
[TVer] Support landing page
3,075
yt-dlp/yt-dlp
132,642
Python
pukkandan
vvto33
'ext': 'mp4', 'title': 'md5:bef647f03bd1c6b15b687ea70dfc9700', 'description': 'md5:5efba25e2f9dac85ebcd21160cb4341f', 'thumbnail': r're:^https?://.*\.jpg$', 'uploader': 'Firefox 🔥', 'uploader_id': 'firefox', ...
```suggestion full_webpage = webpage = self._download_webpage(url, video_id) ```
'title': 'md5:bef647f03bd1c6b15b687ea70dfc9700', 'description': 'md5:5efba25e2f9dac85ebcd21160cb4341f', 'thumbnail': r're:^https?://.*\.jpg$', 'uploader': 'Firefox 🔥', 'uploader_id': 'firefox', 'uploader_url': f'https://{cu...
@@ -68,96 +105,122 @@ class NitterIE(InfoExtractor): # official, rate limited 'nitter.net', # offline + 'is-nitter.resolv.ee', + 'lu-nitter.resolv.ee', 'nitter.13ad.de', + 'nitter.40two.app', + 'nitter.cattube.org', + 'nitter.cc', + 'nitter.d...
yt_dlp/extractor/nitter.py
26
Python
0.571
suggestion
92
51
51
false
[nitter] Update instance list; fix minor metadata bugs
3,099
yt-dlp/yt-dlp
132,642
Python
pukkandan
foghawk
self._html_search_meta('og:image', full_webpage, 'thumbnail url') or remove_end('{}{}'.format(base_url, self._html_search_regex( r'<video[^>]+poster="([^"]+)"', webpage, 'thumbnail url', fatal=False)), '%3Asmall')) thumbnails = [ {'id': id, 'url': f'{thumbnai...
```suggestion **counts, } ``` dict `|` is not in py3.6
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..compat import compat_urlparse from ..utils import ( parse_count, unified_timestamp, remove_end, determine_ext, ) import re import random class NitterIE(InfoExtractor): # Taken from https://github.com/...
@@ -168,61 +231,51 @@ def _real_extract(self, url): 'ext': ext }] - title = self._og_search_description(full_webpage) - if not title: - title = self._html_search_regex(r'<div class="tweet-content[^>]+>([^<]+)</div>', webpage, 'title') + title = self._og_se...
yt_dlp/extractor/nitter.py
26
Python
0.571
suggestion
78
27
278
false
[nitter] Update instance list; fix minor metadata bugs
3,099
yt-dlp/yt-dlp
132,642
Python
pukkandan
foghawk
thumbnail = ( self._html_search_meta('og:image', full_webpage, 'thumbnail url') or remove_end('{}{}'.format(base_url, self._html_search_regex( r'<video[^>]+poster="([^"]+)"', webpage, 'thumbnail url', fatal=False)), '%3Asmall')) thumbnails = [ {'id': ...
```suggestion ``` should be automatically set from timestamp. But make sure to test
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..compat import compat_urlparse from ..utils import ( parse_count, unified_timestamp, remove_end, determine_ext, ) import re import random class NitterIE(InfoExtractor): # Taken from https://github.com/...
@@ -168,61 +231,51 @@ def _real_extract(self, url): 'ext': ext }] - title = self._og_search_description(full_webpage) - if not title: - title = self._html_search_regex(r'<div class="tweet-content[^>]+>([^<]+)</div>', webpage, 'title') + title = self._og_se...
yt_dlp/extractor/nitter.py
26
Python
0.643
suggestion
85
28
278
false
[nitter] Update instance list; fix minor metadata bugs
3,099
yt-dlp/yt-dlp
132,642
Python
pukkandan
foghawk
'uploader_url': f'https://{current_instance}/firefox', 'upload_date': '20210128', 'timestamp': 1611855960, 'view_count': int, 'like_count': int, 'repost_count': int, 'comment_count': int, } ...
```suggestion video_url = '%s%s' % (base_url, self._html_search_regex( r'(?:<video[^>]+data-url|<source[^>]+src)="([^"]+)"', webpage, 'video url')) ``` % formatting is fine
'upload_date': '20210128', 'timestamp': 1611855960, 'view_count': int, 'like_count': int, 'repost_count': int, 'comment_count': int, } } ] def _real_extract(self, url): video_id, uploader...
@@ -68,96 +105,122 @@ class NitterIE(InfoExtractor): # official, rate limited 'nitter.net', # offline + 'is-nitter.resolv.ee', + 'lu-nitter.resolv.ee', 'nitter.13ad.de', + 'nitter.40two.app', + 'nitter.cattube.org', + 'nitter.cc', + 'nitter.d...
yt_dlp/extractor/nitter.py
26
Python
0.714
suggestion
196
51
51
false
[nitter] Update instance list; fix minor metadata bugs
3,099
yt-dlp/yt-dlp
132,642
Python
pukkandan
foghawk
full_webpage = self._download_webpage(url, video_id) webpage = full_webpage main_tweet_start = full_webpage.find('class="main-tweet"') if main_tweet_start > 0: webpage = full_webpage[main_tweet_start:] video_url = '{}{}'.format(base_url, self._html_search_regex( ...
```suggestion uploader_id = ( self._html_search_regex( r'<a class="username"[^>]+title="@([^"]+)"', webpage, 'uploader id', fatal=False) or self._match_valid_url(url).group('uploader_id')) ``` weird indent. I'm surprised flake8 allows this
main_tweet_start = full_webpage.find('class="main-tweet"') if main_tweet_start > 0: webpage = full_webpage[main_tweet_start:] video_url = '%s%s' % (base_url, self._html_search_regex( r'(?:<video[^>]+data-url|<source[^>]+src)="([^"]+)"', webpage, 'video url')) ex...
@@ -168,61 +231,51 @@ def _real_extract(self, url): 'ext': ext }] - title = self._og_search_description(full_webpage) - if not title: - title = self._html_search_regex(r'<div class="tweet-content[^>]+>([^<]+)</div>', webpage, 'title') + title = self._og_se...
yt_dlp/extractor/nitter.py
26
Python
0.857
suggestion
293
51
51
false
[nitter] Update instance list; fix minor metadata bugs
3,099
yt-dlp/yt-dlp
132,642
Python
pukkandan
foghawk
title = self._og_search_description(full_webpage) or self._html_search_regex( r'<div class="tweet-content[^>]+>([^<]+)</div>', webpage, 'title', fatal=False) description = title uploader_id = (self._html_search_regex( r'<a class="username"[^>]+title="@([^"]+)"', webpage...
```suggestion or remove_end('%s%s' % (base_url, self._html_search_regex( r'<video[^>]+poster="([^"]+)"', webpage, 'thumbnail url', fatal=False)), '%3Asmall')) ```
r'<div class="tweet-content[^>]+>([^<]+)</div>', webpage, 'title', fatal=False) uploader_id = self._html_search_regex( r'<a class="username"[^>]+title="@([^"]+)"', webpage, 'uploader id', fatal=False) or uploader_id uploader = self._html_search_regex( r'<a class="fu...
@@ -168,61 +231,51 @@ def _real_extract(self, url): 'ext': ext }] - title = self._og_search_description(full_webpage) - if not title: - title = self._html_search_regex(r'<div class="tweet-content[^>]+>([^<]+)</div>', webpage, 'title') + title = self._og_se...
yt_dlp/extractor/nitter.py
26
Python
0.786
suggestion
193
50
46
false
[nitter] Update instance list; fix minor metadata bugs
3,099
yt-dlp/yt-dlp
132,642
Python
pukkandan
foghawk
'nitter.ethibox.fr', # official, rate limited 'nitter.net', # offline 'is-nitter.resolv.ee', 'lu-nitter.resolv.ee', 'nitter.13ad.de', 'nitter.40two.app', 'nitter.cattube.org', 'nitter.cc', 'nitter.dark.fail', 'nitter.himiko...
```suggestion _INSTANCES_RE = f'(?:{"|".join(map(re.escape, INSTANCES))})' ```
# official, rate limited 'nitter.net', # offline 'is-nitter.resolv.ee', 'lu-nitter.resolv.ee', 'nitter.13ad.de', 'nitter.40two.app', 'nitter.cattube.org', 'nitter.cc', 'nitter.dark.fail', 'nitter.himiko.cloud', 'nitter.koyu...
@@ -68,96 +105,121 @@ class NitterIE(InfoExtractor): # official, rate limited 'nitter.net', # offline + 'is-nitter.resolv.ee', + 'lu-nitter.resolv.ee', 'nitter.13ad.de', + 'nitter.40two.app', + 'nitter.cattube.org', + 'nitter.cc', + 'nitter.d...
yt_dlp/extractor/nitter.py
26
Python
0.571
security
84
51
51
false
[nitter] Update instance list; fix minor metadata bugs
3,099
yt-dlp/yt-dlp
132,642
Python
pukkandan
foghawk
'comment_count': int, }, 'expected_warnings': ['Ignoring subtitle tracks found in the HLS manifest'], }, { # not the first tweet but main-tweet 'url': f'https://{current_instance}/firefox/status/1354848277481414657#m', 'info_dict': { ...
```suggestion video_id, uploader_id = self._match_valid_url(url).group('id', 'uploader_id') ```
}, 'expected_warnings': ['Ignoring subtitle tracks found in the HLS manifest'], }, { # not the first tweet but main-tweet 'url': f'https://{current_instance}/firefox/status/1354848277481414657#m', 'info_dict': { 'id': '1354848277481414657', ...
@@ -68,96 +105,121 @@ class NitterIE(InfoExtractor): # official, rate limited 'nitter.net', # offline + 'is-nitter.resolv.ee', + 'lu-nitter.resolv.ee', 'nitter.13ad.de', + 'nitter.40two.app', + 'nitter.cattube.org', + 'nitter.cc', + 'nitter.d...
yt_dlp/extractor/nitter.py
26
Python
0.714
suggestion
105
51
51
false
[nitter] Update instance list; fix minor metadata bugs
3,099
yt-dlp/yt-dlp
132,642
Python
pukkandan
foghawk
full_webpage = webpage = self._download_webpage(url, video_id) main_tweet_start = full_webpage.find('class="main-tweet"') if main_tweet_start > 0: webpage = full_webpage[main_tweet_start:] video_url = '%s%s' % (base_url, self._html_search_regex( r'(?:<video[^>]+...
```suggestion uploader_id = self._html_search_regex( r'<a class="username"[^>]+title="@([^"]+)"', webpage, 'uploader id', fatal=False) or uploader_id ``` (see above comment)
main_tweet_start = full_webpage.find('class="main-tweet"') if main_tweet_start > 0: webpage = full_webpage[main_tweet_start:] video_url = '%s%s' % (base_url, self._html_search_regex( r'(?:<video[^>]+data-url|<source[^>]+src)="([^"]+)"', webpage, 'video url')) ex...
@@ -168,61 +230,53 @@ def _real_extract(self, url): 'ext': ext }] - title = self._og_search_description(full_webpage) - if not title: - title = self._html_search_regex(r'<div class="tweet-content[^>]+>([^<]+)</div>', webpage, 'title') + title = self._og_se...
yt_dlp/extractor/nitter.py
26
Python
0.857
suggestion
203
51
51
false
[nitter] Update instance list; fix minor metadata bugs
3,099
yt-dlp/yt-dlp
132,642
Python
pukkandan
foghawk
metadata = self._download_json( 'https://app.veo.co/api/app/matches/%s' % video_id, video_id) video_data = self._download_json( 'https://app.veo.co/api/app/matches/%s/videos' % video_id, video_id, 'Downloading video data') formats = [] for fmt in video_data: ...
Is this really needed? It is generally preferable to use `--check-formats`
metadata = self._download_json( 'https://app.veo.co/api/app/matches/%s' % video_id, video_id) video_data = self._download_json( 'https://app.veo.co/api/app/matches/%s/videos' % video_id, video_id, 'Downloading video data') formats = [] for fmt in video_data: ...
@@ -39,39 +42,33 @@ def _real_extract(self, url): video_data = self._download_json( 'https://app.veo.co/api/app/matches/%s/videos' % video_id, video_id, 'Downloading video data') - title = metadata.get('title') - thumbnail = url_or_none(metadata.get('thumbnail')) - - timesta...
yt_dlp/extractor/veo.py
26
Python
0.429
question
74
38
45
false
[Veo] Fix extractor
3,101
yt-dlp/yt-dlp
132,642
Python
pukkandan
ghost
'ViuOTT', item_id, entry.get('synopsis', '').strip())) return self.playlist_result(entries, series_id, series.get('name'), series.get('description')) duration_limit = False query = { 'ccs_product_id': v...
~~put this in _real_initialize~~ cache the token in memory
series_id = video_data.get('series_id') if self._yes_playlist(series_id, video_id, idata): series = product_data.get('series') or {} product = series.get('product') if product: entries = [] for entry in sorted(product, key=lambda x: in...
@@ -312,35 +295,50 @@ def _real_extract(self, url): 'ccs_product_id': video_data['ccs_product_id'], 'language_flag_id': self._LANGUAGE_FLAG.get(lang_code.lower()) or '3', } + + rand = ''.join(random.choice('0123456789') for _ in range(10)) + bearer_token = self._download...
yt_dlp/extractor/viu.py
26
Python
0.357
performance
58
51
51
false
[viu] Fixed bugs and API updated
3,136
yt-dlp/yt-dlp
132,642
Python
pukkandan
zackmark29
'SG': 2, 'TH': 4, 'PH': 5, } _LANGUAGE_FLAG = { 'zh-hk': 1, 'zh-cn': 2, 'en-us': 3, } _user_info = None def _detect_error(self, response): code = response.get('status', {}).get('code') if code > 0: message = try_get(respon...
this function is actually redundant
'zh-hk': 1, 'zh-cn': 2, 'en-us': 3, } _user_token = None _auth_codes = {} def _detect_error(self, response): code = try_get(response, lambda x: x['status']['code']) if code and code > 0: message = try_get(response, lambda x: x['status']['message']) ...
@@ -227,21 +210,22 @@ class ViuOTTIE(InfoExtractor): 'zh-cn': 2, 'en-us': 3, } + _user_info = None def _detect_error(self, response): code = response.get('status', {}).get('code') if code > 0: message = try_get(response, lambda x: x['status']['message'])...
yt_dlp/extractor/viu.py
26
Python
0.071
suggestion
35
51
51
false
[viu] Fixed bugs and API updated
3,136
yt-dlp/yt-dlp
132,642
Python
pukkandan
zackmark29
duration_limit = False query = { 'ccs_product_id': video_data['ccs_product_id'], 'language_flag_id': self._LANGUAGE_FLAG.get(lang_code.lower()) or '3', } def download_playback(): stream_data = self._download_json( 'https://api-gateway...
mistake? ```suggestion user = self._login(country_code, video_id) ```
'https://api-gateway-global.viu.com/api/playback/distribute', video_id=video_id, query=query, fatal=False, note='Downloading stream info', headers={ 'Authorization': f'Bearer {self._auth_codes[country_code]}', 'Referer': url, ...
@@ -312,35 +316,36 @@ def _real_extract(self, url): 'ccs_product_id': video_data['ccs_product_id'], 'language_flag_id': self._LANGUAGE_FLAG.get(lang_code.lower()) or '3', } - headers = { - 'Referer': url, - 'Origin': url, - } - try: + + ...
yt_dlp/extractor/viu.py
26
Python
0.643
suggestion
88
51
51
false
[viu] Fixed bugs and API updated
3,136
yt-dlp/yt-dlp
132,642
Python
pukkandan
zackmark29
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import ( int_or_none ) class LastFMPlaylistBaseIE(InfoExtractor): def _extract_current_page(self, url): return int_or_none(self._search_regex( r'\bpage=(\d+)', url, 'page', de...
this is fatal ```sh >>> max([1, None, 2, None, 23]) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: '>' not supported between instances of 'NoneType' and 'int ```
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import int_or_none, format_field class LastFMPlaylistBaseIE(InfoExtractor): def _entries(self, url, playlist_id): webpage = self._download_webpage(url, playlist_id) start_page_number ...
@@ -0,0 +1,158 @@ +# coding: utf-8 +from __future__ import unicode_literals + +import re + +from .common import InfoExtractor +from ..utils import ( + int_or_none +) + + +class LastFMPlaylistBaseIE(InfoExtractor): + def _extract_current_page(self, url): + return int_or_none(self._search_regex( + ...
yt_dlp/extractor/lastfm.py
25
Python
0.929
suggestion
204
50
50
false
[LastFM] Add extractor
3,141
yt-dlp/yt-dlp
132,642
Python
Ashish0804
mezbaul-h
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import ( int_or_none ) class LastFMPlaylistBaseIE(InfoExtractor): def _extract_current_page(self, url): return int_or_none(self._search_regex( r'\bpage=(\d+)', url, 'page', de...
```suggestion page_numbers = list(filter(None, map(int_or_none, re.findall(r'(\d+)', pagination_list)))) last_page = max(page_numbers) ```
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import int_or_none, format_field class LastFMPlaylistBaseIE(InfoExtractor): def _entries(self, url, playlist_id): webpage = self._download_webpage(url, playlist_id) start_page_number ...
@@ -0,0 +1,158 @@ +# coding: utf-8 +from __future__ import unicode_literals + +import re + +from .common import InfoExtractor +from ..utils import ( + int_or_none +) + + +class LastFMPlaylistBaseIE(InfoExtractor): + def _extract_current_page(self, url): + return int_or_none(self._search_regex( + ...
yt_dlp/extractor/lastfm.py
25
Python
0.714
suggestion
165
50
50
false
[LastFM] Add extractor
3,141
yt-dlp/yt-dlp
132,642
Python
Ashish0804
mezbaul-h
return last_page def _extract_entries(self, webpage): tbody = self._search_regex( r'(?s)tbody\s+data-playlisting-add-entries[^>]*>(.+?)</tbody>', webpage, 'tbody') return [ self.url_result(player_url, 'Youtube') for player_url in re.findall(r'href="([^"]...
```suggestion start_page_number = current_page_number if current_page_number != None else 1 ```
] for e in page_entries: yield e def _real_extract(self, url): playlist_id = self._match_id(url) return self.playlist_result(self._entries(url, playlist_id), playlist_id) class LastFMPlaylistIE(LastFMPlaylistBaseIE): _VALID_URL = r'https?://(?:www\.)?l...
@@ -0,0 +1,158 @@ +# coding: utf-8 +from __future__ import unicode_literals + +import re + +from .common import InfoExtractor +from ..utils import ( + int_or_none +) + + +class LastFMPlaylistBaseIE(InfoExtractor): + def _extract_current_page(self, url): + return int_or_none(self._search_regex( + ...
yt_dlp/extractor/lastfm.py
26
Python
0.714
suggestion
105
51
51
false
[LastFM] Add extractor
3,141
yt-dlp/yt-dlp
132,642
Python
Ashish0804
mezbaul-h
def _extract_last_page(self, webpage): last_page = None pagination_list = self._search_regex( r'(?s)class="[^"]*pagination-list[^"]*"[^>]*>(.+?)</ul>', webpage, 'pagination_list', fatal=False, default=None) if pagination_list: page_numbers = re.findall(r'...
bruh that's it? no title no desc, no thumbnail?
for page_number in range(start_page_number, (last_page_number or start_page_number) + 1): webpage = self._download_webpage( url, playlist_id, note='Downloading page %d%s' % (page_number, format_field(last_page_number, template=' of %d')), query={'page...
@@ -0,0 +1,158 @@ +# coding: utf-8 +from __future__ import unicode_literals + +import re + +from .common import InfoExtractor +from ..utils import ( + int_or_none +) + + +class LastFMPlaylistBaseIE(InfoExtractor): + def _extract_current_page(self, url): + return int_or_none(self._search_regex( + ...
yt_dlp/extractor/lastfm.py
26
Python
0.071
question
49
51
51
false
[LastFM] Add extractor
3,141
yt-dlp/yt-dlp
132,642
Python
Ashish0804
mezbaul-h
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import int_or_none class LastFMPlaylistBaseIE(InfoExtractor): def _extract_current_page(self, url): return int_or_none(self._search_regex( r'\bpage=(\d+)', url, 'page', default=No...
isn't it better to directly match ```py r'>(\d+)</a></li><li[^>]+class="pagination-next"' ```
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import int_or_none, format_field class LastFMPlaylistBaseIE(InfoExtractor): def _entries(self, url, playlist_id): webpage = self._download_webpage(url, playlist_id) start_page_number ...
@@ -0,0 +1,153 @@ +# coding: utf-8 +from __future__ import unicode_literals + +import re + +from .common import InfoExtractor +from ..utils import int_or_none + + +class LastFMPlaylistBaseIE(InfoExtractor): + def _extract_current_page(self, url): + return int_or_none(self._search_regex( + r'\bpage=...
yt_dlp/extractor/lastfm.py
24
Python
0.643
suggestion
96
49
49
false
[LastFM] Add extractor
3,141
yt-dlp/yt-dlp
132,642
Python
pukkandan
mezbaul-h
import re from .common import InfoExtractor from ..utils import int_or_none class LastFMPlaylistBaseIE(InfoExtractor): def _extract_current_page(self, url): return int_or_none(self._search_regex( r'\bpage=(\d+)', url, 'page', default=None)) def _extract_last_page(self, webpage): ...
non-greedy matching large strings is dangerous and should be avoided if possible
import re from .common import InfoExtractor from ..utils import int_or_none, format_field class LastFMPlaylistBaseIE(InfoExtractor): def _entries(self, url, playlist_id): webpage = self._download_webpage(url, playlist_id) start_page_number = int_or_none(self._search_regex( r'\bpage=(...
@@ -0,0 +1,153 @@ +# coding: utf-8 +from __future__ import unicode_literals + +import re + +from .common import InfoExtractor +from ..utils import int_or_none + + +class LastFMPlaylistBaseIE(InfoExtractor): + def _extract_current_page(self, url): + return int_or_none(self._search_regex( + r'\bpage=...
yt_dlp/extractor/lastfm.py
26
Python
0.286
suggestion
80
51
51
false
[LastFM] Add extractor
3,141
yt-dlp/yt-dlp
132,642
Python
pukkandan
mezbaul-h
from .common import InfoExtractor from ..utils import int_or_none class LastFMPlaylistBaseIE(InfoExtractor): def _extract_current_page(self, url): return int_or_none(self._search_regex( r'\bpage=(\d+)', url, 'page', default=None)) def _extract_last_page(self, webpage): last_page =...
why not match this on the whole page?
from .common import InfoExtractor from ..utils import int_or_none, format_field class LastFMPlaylistBaseIE(InfoExtractor): def _entries(self, url, playlist_id): webpage = self._download_webpage(url, playlist_id) start_page_number = int_or_none(self._search_regex( r'\bpage=(\d+)', url, ...
@@ -0,0 +1,153 @@ +# coding: utf-8 +from __future__ import unicode_literals + +import re + +from .common import InfoExtractor +from ..utils import int_or_none + + +class LastFMPlaylistBaseIE(InfoExtractor): + def _extract_current_page(self, url): + return int_or_none(self._search_regex( + r'\bpage=...
yt_dlp/extractor/lastfm.py
26
Python
0.071
question
37
51
51
false
[LastFM] Add extractor
3,141
yt-dlp/yt-dlp
132,642
Python
pukkandan
mezbaul-h
pagination_list = self._search_regex( r'(?s)class="[^"]*pagination-list[^"]*"[^>]*>(.+?)</ul>', webpage, 'pagination_list', fatal=False, default=None) if pagination_list: last_page = max(map(int_or_none, re.findall(r'(\d+)', pagination_list))) return last_pa...
these thin wrapper functions aren't really needed since they are only used once
for page_number in range(start_page_number, (last_page_number or start_page_number) + 1): webpage = self._download_webpage( url, playlist_id, note='Downloading page %d%s' % (page_number, format_field(last_page_number, template=' of %d')), query={'page...
@@ -0,0 +1,153 @@ +# coding: utf-8 +from __future__ import unicode_literals + +import re + +from .common import InfoExtractor +from ..utils import int_or_none + + +class LastFMPlaylistBaseIE(InfoExtractor): + def _extract_current_page(self, url): + return int_or_none(self._search_regex( + r'\bpage=...
yt_dlp/extractor/lastfm.py
26
Python
0.286
suggestion
80
51
51
false
[LastFM] Add extractor
3,141
yt-dlp/yt-dlp
132,642
Python
pukkandan
mezbaul-h
pagination_list = self._search_regex( r'(?s)class="[^"]*pagination-list[^"]*"[^>]*>(.+?)</ul>', webpage, 'pagination_list', fatal=False, default=None) if pagination_list: last_page = max(map(int_or_none, re.findall(r'(\d+)', pagination_list))) return last_pa...
```suggestion return self._download_webpage( url, playlist_id, query={'page': current_page_number}, note='Downloading page %d%s' % (current_page_number, format_field(last_page_number, template='of %d')) ``` What's with the logic behind not setting current_page if there is no last_pa...
for page_number in range(start_page_number, (last_page_number or start_page_number) + 1): webpage = self._download_webpage( url, playlist_id, note='Downloading page %d%s' % (page_number, format_field(last_page_number, template=' of %d')), query={'page...
@@ -0,0 +1,153 @@ +# coding: utf-8 +from __future__ import unicode_literals + +import re + +from .common import InfoExtractor +from ..utils import int_or_none + + +class LastFMPlaylistBaseIE(InfoExtractor): + def _extract_current_page(self, url): + return int_or_none(self._search_regex( + r'\bpage=...
yt_dlp/extractor/lastfm.py
26
Python
0.786
question
323
51
51
false
[LastFM] Add extractor
3,141
yt-dlp/yt-dlp
132,642
Python
pukkandan
mezbaul-h
class LastFMPlaylistBaseIE(InfoExtractor): def _extract_current_page(self, url): return int_or_none(self._search_regex( r'\bpage=(\d+)', url, 'page', default=None)) def _extract_last_page(self, webpage): last_page = None pagination_list = self._search_regex( r'...
since all the logic is in the base class, why even make multiple classes? Especially since you seem to have made the regex more complicated for splitting them up
class LastFMPlaylistBaseIE(InfoExtractor): def _entries(self, url, playlist_id): webpage = self._download_webpage(url, playlist_id) start_page_number = int_or_none(self._search_regex( r'\bpage=(\d+)', url, 'page', default=None)) or 1 last_page_number = int_or_none(self._search_...
@@ -0,0 +1,153 @@ +# coding: utf-8 +from __future__ import unicode_literals + +import re + +from .common import InfoExtractor +from ..utils import int_or_none + + +class LastFMPlaylistBaseIE(InfoExtractor): + def _extract_current_page(self, url): + return int_or_none(self._search_regex( + r'\bpage=...
yt_dlp/extractor/lastfm.py
26
Python
0.357
suggestion
161
51
51
false
[LastFM] Add extractor
3,141
yt-dlp/yt-dlp
132,642
Python
pukkandan
mezbaul-h
'only_matching': True, }, { 'url': 'https://www.last.fm/tag/rock', 'only_matching': True, }, { 'url': 'https://www.last.fm/tag/rock/tracks', 'only_matching': True, }] class LastFMUserIE(LastFMPlaylistBaseIE): _VALID_URL = r'https?://(?:www\.)?last\.fm/user/(?P<u...
did u mean this? ```suggestion _VALID_URL = r'https?://(?:www\.)?last\.fm/music/[^/]+/[^/]+/(?P<id>[^/#?]+)' ``` I don't get what `(/|[^/]*/?)$` is trying to do
class LastFMIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?last\.fm/music(?:/[^/]+){2}/(?P<id>[^/#?]+)' _TESTS = [{ 'url': 'https://www.last.fm/music/Oasis/_/Wonderwall', 'md5': '9c4a70c2e84c03d54fe24229b9e13b7b', 'info_dict': { 'id': '6hzrDeceEKc', 'ext': '...
@@ -0,0 +1,153 @@ +# coding: utf-8 +from __future__ import unicode_literals + +import re + +from .common import InfoExtractor +from ..utils import int_or_none + + +class LastFMPlaylistBaseIE(InfoExtractor): + def _extract_current_page(self, url): + return int_or_none(self._search_regex( + r'\bpage=...
yt_dlp/extractor/lastfm.py
26
Python
0.714
suggestion
168
51
49
false
[LastFM] Add extractor
3,141
yt-dlp/yt-dlp
132,642
Python
pukkandan
mezbaul-h
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import int_or_none, format_field class LastFMPlaylistBaseIE(InfoExtractor): def _entries(self, url, playlist_id): webpage = self._download_webpage(url, playlist_id) start_page_number ...
```suggestion start_page_number = int(self._search_regex( r'\bpage=(\d+)', url, 'page', default=None)) or 1 last_page_number = int(self._search_regex( r'>(\d+)</a>[^<]*</li>[^<]*<li[^>]+class="pagination-next', webpage, 'last_page', default=None)) ``` since it's matched w...
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import int_or_none, format_field class LastFMPlaylistBaseIE(InfoExtractor): def _entries(self, url, playlist_id): webpage = self._download_webpage(url, playlist_id) start_page_number ...
@@ -4,51 +4,27 @@ import re from .common import InfoExtractor -from ..utils import int_or_none +from ..utils import int_or_none, format_field class LastFMPlaylistBaseIE(InfoExtractor): - def _extract_current_page(self, url): - return int_or_none(self._search_regex( - r'\bpage=(\d+)', url, ...
yt_dlp/extractor/lastfm.py
17
Python
0.786
suggestion
329
42
42
false
[LastFM] Add extractor
3,141
yt-dlp/yt-dlp
132,642
Python
pukkandan
mezbaul-h
from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import int_or_none, format_field class LastFMPlaylistBaseIE(InfoExtractor): def _entries(self, url, playlist_id): webpage = self._download_webpage(url, playlist_id) start_page_number = int_or_none(se...
This would be better as a pagedlist. Not a mandatory change, just pointing it out
from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import int_or_none, format_field class LastFMPlaylistBaseIE(InfoExtractor): def _entries(self, url, playlist_id): webpage = self._download_webpage(url, playlist_id) start_page_number = int_or_none(se...
@@ -4,51 +4,27 @@ import re from .common import InfoExtractor -from ..utils import int_or_none +from ..utils import int_or_none, format_field class LastFMPlaylistBaseIE(InfoExtractor): - def _extract_current_page(self, url): - return int_or_none(self._search_regex( - r'\bpage=(\d+)', url, ...
yt_dlp/extractor/lastfm.py
26
Python
0.286
suggestion
81
51
51
false
[LastFM] Add extractor
3,141
yt-dlp/yt-dlp
132,642
Python
pukkandan
mezbaul-h
start_page_number = int_or_none(self._search_regex( r'\bpage=(\d+)', url, 'page', default=None)) or 1 last_page_number = int_or_none(self._search_regex( r'>(\d+)</a>[^<]*</li>[^<]*<li[^>]+class="pagination-next', webpage, 'last_page', default=None)) for page_number in r...
it should match ``` https://www.last.fm/music/Oasis/xxx https://www.last.fm/music/Oasis https://www.last.fm/music/Oasis/ https://www.last.fm/music/Oasis?ss https://www.last.fm/music/Oasis#aa https://www.last.fm/music/Oasis/?dd https://www.last.fm/music/Oasis/xxx?aaa ``` but not ``` https://www.last.fm/music...
start_page_number = int_or_none(self._search_regex( r'\bpage=(\d+)', url, 'page', default=None)) or 1 last_page_number = int_or_none(self._search_regex( r'>(\d+)</a>[^<]*</li>[^<]*<li[^>]+class="pagination-next', webpage, 'last_page', default=None)) for page_number in ra...
@@ -58,25 +34,17 @@ def _real_extract(self, url): return self.playlist_result(self._entries(url, playlist_id), playlist_id) -class LastFMAlbumIE(LastFMPlaylistBaseIE): - _VALID_URL = r'https?://(?:www\.)?last\.fm/music/(?P<artist_id>[^/]+)/(?P<id>[^+/#?][^/#?]+)(/|[^/]*/?)$' - _TESTS = [{ - 'u...
yt_dlp/extractor/lastfm.py
26
Python
0.857
suggestion
470
51
51
false
[LastFM] Add extractor
3,141
yt-dlp/yt-dlp
132,642
Python
pukkandan
mezbaul-h
'only_matching': True, }, { 'url': 'https://www.last.fm/music/Oasis/+tracks', 'only_matching': True, }, { 'url': 'https://www.last.fm/tag/rock', 'only_matching': True, }, { 'url': 'https://www.last.fm/tag/rock/tracks', 'only_matching': True, }] c...
```suggestion _VALID_URL = r'https?://(?:www\.)?last\.fm/music(?:/[^/]+){2}/(?P<id>[^/#?]+)' ```
}, { 'url': 'https://www.last.fm/music/Oasis/', 'only_matching': True, }, { 'url': 'https://www.last.fm/music/Oasis?top_tracks_date_preset=ALL#top-tracks', 'only_matching': True, }, { 'url': 'https://www.last.fm/music/Oasis/+tracks', 'only_matching': True, ...
@@ -0,0 +1,118 @@ +# coding: utf-8 +from __future__ import unicode_literals + +import re + +from .common import InfoExtractor +from ..utils import int_or_none, format_field + + +class LastFMPlaylistBaseIE(InfoExtractor): + def _entries(self, url, playlist_id): + webpage = self._download_webpage(url, playlist_...
yt_dlp/extractor/lastfm.py
26
Python
0.714
suggestion
102
51
51
false
[LastFM] Add extractor
3,141
yt-dlp/yt-dlp
132,642
Python
pukkandan
mezbaul-h
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import int_or_none, format_field class LastFMPlaylistBaseIE(InfoExtractor): def _entries(self, url, playlist_id): webpage = self._download_webpage(url, playlist_id) start_page_number ...
`last_page_number` is nullable, `int(None)` will raise a non-fatal exception. reverting it back to `int_or_none`
# coding: utf-8 from __future__ import unicode_literals import re from .common import InfoExtractor from ..utils import int_or_none, format_field class LastFMPlaylistBaseIE(InfoExtractor): def _entries(self, url, playlist_id): webpage = self._download_webpage(url, playlist_id) start_page_number ...
@@ -10,10 +10,10 @@ class LastFMPlaylistBaseIE(InfoExtractor): def _entries(self, url, playlist_id): webpage = self._download_webpage(url, playlist_id) - start_page_number = int_or_none(self._search_regex( + start_page_number = int(self._search_regex( r'\bpage=(\d+)', url, 'pag...
yt_dlp/extractor/lastfm.py
16
Python
0.643
suggestion
112
41
41
false
[LastFM] Add extractor
3,141
yt-dlp/yt-dlp
132,642
Python
mezbaul-h
mezbaul-h
ext = determine_ext(src).lower() if src_type == 'video/youtube': return self.url_result(src, YoutubeIE.ie_key()) if src_type == 'application/dash+xml' or ext == 'mpd': fmts, subs = self._extract_mpd_formats_and_subtitles( ...
```suggestion for sub_match in re.finditer(rf'(?s){re.escape(varname)}' r'\.addRemoteTextTrack\(({.+?})\s*,\s*(?:true|false)\)', webpage): ```
if isinstance(src_type, compat_str): src_type = src_type.lower() ext = determine_ext(src).lower() if src_type == 'video/youtube': return self.url_result(src, YoutubeIE.ie_key()) if src_type == 'application/dash+xml' ...
@@ -3819,6 +3820,24 @@ def _real_extract(self, url): 'Referer': full_response.geturl(), }, }) + # https://docs.videojs.com/player#addRemoteTextTrack + # https://html.spec.whatwg.org/multipage/media.html#htmltrackelement + ...
yt_dlp/extractor/generic.py
26
Python
0.714
security
156
51
51
false
[generic] Extract subtitles from video.js
3,156
yt-dlp/yt-dlp
132,642
Python
pukkandan
Lesmiscore
fmts, subs = self._extract_m3u8_formats_and_subtitles( src, video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls', fatal=False) formats.extend(fmts) self._merge_subtitles(subs, target=subtitles) ...
```suggestion subtitles.setdefault(dict_get(sub, ('language', 'srclang')) or 'und', []).append({ ```
self._merge_subtitles(subs, target=subtitles) elif src_type == 'application/x-mpegurl' or ext == 'm3u8': fmts, subs = self._extract_m3u8_formats_and_subtitles( src, video_id, 'mp4', entry_protocol='m3u8_native', m3u8...
@@ -3819,6 +3820,24 @@ def _real_extract(self, url): 'Referer': full_response.geturl(), }, }) + # https://docs.videojs.com/player#addRemoteTextTrack + # https://html.spec.whatwg.org/multipage/media.html#htmltrackelement + ...
yt_dlp/extractor/generic.py
26
Python
0.714
suggestion
118
51
51
false
[generic] Extract subtitles from video.js
3,156
yt-dlp/yt-dlp
132,642
Python
pukkandan
Lesmiscore
elif src_type == 'application/x-mpegurl' or ext == 'm3u8': fmts, subs = self._extract_m3u8_formats_and_subtitles( src, video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls', fatal=False) formats.extend(fmts) ...
```suggestion sub = self._parse_json( sub_match.group(1), video_id, transform_source=js_to_json, fatal=False) or {} src = try_get(sub, sub['src'], str) if not src: continue ```
formats.extend(fmts) self._merge_subtitles(subs, target=subtitles) elif src_type == 'application/x-mpegurl' or ext == 'm3u8': fmts, subs = self._extract_m3u8_formats_and_subtitles( src, video_id, 'mp4', entry_protocol='m...
@@ -3819,6 +3820,24 @@ def _real_extract(self, url): 'Referer': full_response.geturl(), }, }) + # https://docs.videojs.com/player#addRemoteTextTrack + # https://html.spec.whatwg.org/multipage/media.html#htmltrackelement + ...
yt_dlp/extractor/generic.py
26
Python
0.786
suggestion
270
51
51
false
[generic] Extract subtitles from video.js
3,156
yt-dlp/yt-dlp
132,642
Python
pukkandan
Lesmiscore
self._sort_formats(entry['formats']) return self.playlist_result(entries, video_id, video_title) jwplayer_data = self._find_jwplayer_data( webpage, video_id, transform_source=js_to_json) if jwplayer_data: if isinstance(jwplayer_data.get('playlist'), s...
```suggestion r'(?s)\bvideojs\s*\(.+?([a-zA-Z0-9_$]+)\.src\s*\(\s*((?:\[.+?\]|{.+?}))\s*\)\s*;', ```
}) for entry in entries: self._sort_formats(entry['formats']) return self.playlist_result(entries, video_id, video_title) jwplayer_data = self._find_jwplayer_data( webpage, video_id, transform_source=js_to_json) if jwplayer_data: ...
@@ -3778,11 +3778,12 @@ def _real_extract(self, url): # Video.js embed mobj = re.search( - r'(?s)\bvideojs\s*\(.+?\.src\s*\(\s*((?:\[.+?\]|{.+?}))\s*\)\s*;', + r'(?s)\bvideojs\s*\(.+?([a-zA-Z0-9_$]+?)\.src\s*\(\s*((?:\[.+?\]|{.+?}))\s*\)\s*;',
yt_dlp/extractor/generic.py
26
Python
0.714
suggestion
114
51
51
false
[generic] Extract subtitles from video.js
3,156
yt-dlp/yt-dlp
132,642
Python
pukkandan
Lesmiscore
break # Youtube sometimes sends incomplete data # See: https://github.com/ytdl-org/youtube-dl/issues/28194 last_error = 'Incomplete data received' if count >= retries: if fatal: raise Extracto...
We need to handle the case that `traverse_obj(renderer, ('title', 'accessibility', 'accessibilityData', 'label'))` returns `None`, which crashes `_search_regex`. This can happen when downloading a playlist that contains unavailable videos.
break # Youtube sometimes sends incomplete data # See: https://github.com/ytdl-org/youtube-dl/issues/28194 last_error = 'Incomplete data received' if count >= retries: if fatal: raise Extracto...
@@ -807,6 +807,12 @@ def _extract_video(self, renderer): description = self._get_text(renderer, 'descriptionSnippet') duration = parse_duration(self._get_text( renderer, 'lengthText', ('thumbnailOverlays', ..., 'thumbnailOverlayTimeStatusRenderer', 'text'))) + if duration is None: ...
yt_dlp/extractor/youtube.py
26
Python
0.714
bug
239
51
51
false
[youtube:tab] Fix duration extraction for shorts
3,171
yt-dlp/yt-dlp
132,642
Python
mechanical-snail
coletdjnz
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..utils import unified_timestamp class BanByeBaseIE(InfoExtractor): _API_BASE = 'https://api.banbye.com' _CDN_BASE = 'https://cdn.banbye.com' def _extract_playlist(self, playlist_id): data = self._dow...
```suggestion self.url_result(f'https://banbye.com/watch/{video_id}', BanByeIE) ```
# coding: utf-8 from __future__ import unicode_literals import math from .common import InfoExtractor from ..compat import ( compat_urllib_parse_urlparse, compat_parse_qs, ) from ..utils import ( format_field, InAdvancePagedList, traverse_obj, unified_timestamp, ) class BanByeBaseIE(InfoExtr...
@@ -0,0 +1,114 @@ +# coding: utf-8 +from __future__ import unicode_literals + + +from .common import InfoExtractor +from ..utils import unified_timestamp + + +class BanByeBaseIE(InfoExtractor): + _API_BASE = 'https://api.banbye.com' + _CDN_BASE = 'https://cdn.banbye.com' + + def _extract_playlist(self, playlis...
yt_dlp/extractor/banbye.py
16
Python
0.571
suggestion
97
41
41
false
[BanBye] Add extractor
3,177
yt-dlp/yt-dlp
132,642
Python
pukkandan
mezbaul-h
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..utils import unified_timestamp class BanByeBaseIE(InfoExtractor): _API_BASE = 'https://api.banbye.com' _CDN_BASE = 'https://cdn.banbye.com' def _extract_playlist(self, playlist_id): data = self._dow...
```suggestion for video_id in data['videoIds']], playlist_id, data.get('name')) ```
# coding: utf-8 from __future__ import unicode_literals import math from .common import InfoExtractor from ..compat import ( compat_urllib_parse_urlparse, compat_parse_qs, ) from ..utils import ( format_field, InAdvancePagedList, traverse_obj, unified_timestamp, ) class BanByeBaseIE(InfoExtr...
@@ -0,0 +1,114 @@ +# coding: utf-8 +from __future__ import unicode_literals + + +from .common import InfoExtractor +from ..utils import unified_timestamp + + +class BanByeBaseIE(InfoExtractor): + _API_BASE = 'https://api.banbye.com' + _CDN_BASE = 'https://cdn.banbye.com' + + def _extract_playlist(self, playlis...
yt_dlp/extractor/banbye.py
17
Python
0.571
suggestion
97
42
42
false
[BanBye] Add extractor
3,177
yt-dlp/yt-dlp
132,642
Python
pukkandan
mezbaul-h
# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from ..utils import unified_timestamp class BanByeBaseIE(InfoExtractor): _API_BASE = 'https://api.banbye.com' _CDN_BASE = 'https://cdn.banbye.com' def _extract_playlist(self, playlist_id): data = self._dow...
```suggestion _VALID_URL = r'https?://(?:www\.)?banbye.com/(?:en/)?watch/(?P<id>\w+)' ``` there may be other queries in the URL. Better to take playlist_id from parse_url
# coding: utf-8 from __future__ import unicode_literals import math from .common import InfoExtractor from ..compat import ( compat_urllib_parse_urlparse, compat_parse_qs, ) from ..utils import ( format_field, InAdvancePagedList, traverse_obj, unified_timestamp, ) class BanByeBaseIE(InfoExtr...
@@ -0,0 +1,114 @@ +# coding: utf-8 +from __future__ import unicode_literals + + +from .common import InfoExtractor +from ..utils import unified_timestamp + + +class BanByeBaseIE(InfoExtractor): + _API_BASE = 'https://api.banbye.com' + _CDN_BASE = 'https://cdn.banbye.com' + + def _extract_playlist(self, playlis...
yt_dlp/extractor/banbye.py
26
Python
0.786
suggestion
177
51
51
false
[BanBye] Add extractor
3,177
yt-dlp/yt-dlp
132,642
Python
pukkandan
mezbaul-h
'url': '%s/video/%s/%d.mp4' % (self._CDN_BASE, video_id, quality), } for quality in data['quality']] self._sort_formats(formats) return { 'id': video_id, 'title': data['title'], 'description': data['desc'], 'uploader': data['channel']...
Same issue as the other one. URLs like: ``` https://banbye.com/channel/ch_wrealu24?a=1&playlist=p_Ld82N6gBw_OJ ``` should match
'id': f'{quality}p', 'url': f'{self._CDN_BASE}/video/{video_id}/{quality}.webp', } for quality in [48, 96, 144, 240, 512, 1080]] formats = [{ 'format_id': f'http-{quality}p', 'quality': quality, 'url': f'{self._CDN_BASE}/video/{video_id}/{quali...
@@ -0,0 +1,114 @@ +# coding: utf-8 +from __future__ import unicode_literals + + +from .common import InfoExtractor +from ..utils import unified_timestamp + + +class BanByeBaseIE(InfoExtractor): + _API_BASE = 'https://api.banbye.com' + _CDN_BASE = 'https://cdn.banbye.com' + + def _extract_playlist(self, playlis...
yt_dlp/extractor/banbye.py
26
Python
0.786
suggestion
131
39
51
false
[BanBye] Add extractor
3,177
yt-dlp/yt-dlp
132,642
Python
pukkandan
mezbaul-h
compat_urllib_parse_urlparse, compat_parse_qs, ) from ..utils import ( format_field, unified_timestamp, InAdvancePagedList, ) class BanByeBaseIE(InfoExtractor): _API_BASE = 'https://api.banbye.com' _CDN_BASE = 'https://cdn.banbye.com' _VIDEO_BASE = 'https://banbye.com/watch' @stat...
why not? u cant make playlist data without `videoIds`. imo an error would be better than an empty playlist when the extraction process breaks
compat_urllib_parse_urlparse, compat_parse_qs, ) from ..utils import ( format_field, InAdvancePagedList, traverse_obj, unified_timestamp, ) class BanByeBaseIE(InfoExtractor): _API_BASE = 'https://api.banbye.com' _CDN_BASE = 'https://cdn.banbye.com' _VIDEO_BASE = 'https://banbye.com...
@@ -0,0 +1,152 @@ +# coding: utf-8 +from __future__ import unicode_literals + +import math + +from .common import InfoExtractor +from ..compat import ( + compat_urllib_parse_urlparse, + compat_parse_qs, +) +from ..utils import ( + format_field, + unified_timestamp, + InAdvancePagedList, +) + + +class Ban...
yt_dlp/extractor/banbye.py
26
Python
0.714
refactor
141
51
51
false
[BanBye] Add extractor
3,177
yt-dlp/yt-dlp
132,642
Python
mezbaul-h
mezbaul-h
def _real_extract(self, url): video_id = self._match_id(url) playlist_id = self._extract_playlist_id(url, 'playlistId') if self._yes_playlist(playlist_id, video_id): return self._extract_playlist(playlist_id) data = self._download_json(f'{self._API_BASE}/videos/{video_...
```suggestion 'uploader': traverse_obj(data, ('channel', 'name')), ```
}] def _real_extract(self, url): video_id = self._match_id(url) playlist_id = self._extract_playlist_id(url, 'playlistId') if self._yes_playlist(playlist_id, video_id): return self._extract_playlist(playlist_id) data = self._download_json(f'{self._API_BASE}/videos/...
@@ -0,0 +1,152 @@ +# coding: utf-8 +from __future__ import unicode_literals + +import math + +from .common import InfoExtractor +from ..compat import ( + compat_urllib_parse_urlparse, + compat_parse_qs, +) +from ..utils import ( + format_field, + unified_timestamp, + InAdvancePagedList, +) + + +class Ban...
yt_dlp/extractor/banbye.py
26
Python
0.571
suggestion
84
51
51
false
[BanBye] Add extractor
3,177
yt-dlp/yt-dlp
132,642
Python
pukkandan
mezbaul-h