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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
'upload_date': '19700101',
'timestamp': 0,
'thumbnail': 'https://sun9-86.userapi.com/impf/7vN3ACwSTgChP96OdOfzFjUCzFR6ZglDQgWsIw/KPaACiVJJxM.jpg?size=800x450&quality=96&keep_aspect_ratio=1&background=000000&sign=b48ea459c4d33dbcba5e26d63574b1cb&type=video_thumb',
},
}, {
... | None of these are needed
```suggestion
``` | 'thumbnail': r're:https://[^/]+/impf/7vN3ACwSTgChP96OdOfzFjUCzFR6ZglDQgWsIw/KPaACiVJJxM\.jpg\?size=800x450&quality=96&keep_aspect_ratio=1&background=000000&sign=b48ea459c4d33dbcba5e26d63574b1cb&type=video_thumb',
'timestamp': 0,
},
}, {
'url': 'http://biqle.org/watch/-4478184... | @@ -32,54 +34,79 @@ class BIQLEIE(InfoExtractor):
'id': '-44781847_168547604',
'ext': 'mp4',
'title': 'Ребенок в шоке от автоматической мойки',
+ 'description': 'Ребенок в шоке от автоматической мойки — Смотреть онлайн',
'timestamp': 1396633454,
- ... | yt_dlp/extractor/biqle.py | 26 | Python | 0.429 | suggestion | 44 | 51 | 51 | false | Fixing Biqle #193 | 2,731 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Bricio |
globParams = self._parse_json(self._search_regex(
r'<script id="globParams">.*window.globParams = ([^;]+);[^<]+</script>',
embed_page, 'Global Parameters', flags=re.DOTALL), video_id, transform_source=js_to_json)
self.write_debug('globParams: %s' % globParams)
hostName = ... | use `%`/`format`/`fstrings`, not `+` | formats = []
for f_id, f_url in item.get('files', {}).items():
if f_id == 'external':
return self.url_result(f_url)
ext, height = f_id.split('_')
height_extra_key = traverse_obj(glob_params, ('video', 'partial', 'quality', height))
if heigh... | @@ -32,54 +34,79 @@ class BIQLEIE(InfoExtractor):
'id': '-44781847_168547604',
'ext': 'mp4',
'title': 'Ребенок в шоке от автоматической мойки',
+ 'description': 'Ребенок в шоке от автоматической мойки — Смотреть онлайн',
'timestamp': 1396633454,
- ... | yt_dlp/extractor/biqle.py | 26 | Python | 0.286 | style | 36 | 51 | 37 | false | Fixing Biqle #193 | 2,731 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Bricio |
# coding: utf-8
from __future__ import unicode_literals
import re
from .common import InfoExtractor
from .vk import VKIE
from ..compat import compat_b64decode
from ..utils import (
int_or_none,
js_to_json,
traverse_obj,
unified_timestamp,
)
class BIQLEIE(InfoExtractor):
_VALID_URL = r'https?://... | ```suggestion
from ..compat import compat_b64decode
from ..utils import (
``` | # coding: utf-8
from __future__ import unicode_literals
from .common import InfoExtractor
from .vk import VKIE
from ..compat import compat_b64decode
from ..utils import (
int_or_none,
js_to_json,
traverse_obj,
unified_timestamp,
)
class BIQLEIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?bi... | @@ -1,29 +1,33 @@
# coding: utf-8
from __future__ import unicode_literals
+import re
+
from .common import InfoExtractor
from .vk import VKIE
-from ..compat import (
- compat_b64decode,
- compat_urllib_parse_unquote,
+from ..compat import compat_b64decode
+
+from ..utils import ( | yt_dlp/extractor/biqle.py | 10 | Python | 0.571 | suggestion | 80 | 35 | 35 | false | Fixing Biqle #193 | 2,731 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Bricio |
'title': 'Forsaken By Hope Studio Clip',
'description': 'Forsaken By Hope Studio Clip — Смотреть онлайн',
'upload_date': '19700101',
'timestamp': 0,
'thumbnail': r're:https://[^/]+/impf/7vN3ACwSTgChP96OdOfzFjUCzFR6ZglDQgWsIw/KPaACiVJJxM\.jpg\?size=800x450&qual... | This is how the regex should be if `_html_search_meta` wasnt available
```suggestion
r'<meta[^>]+itemprop\s*=\s*"name"[^>]+content\s*=\s*"([^">]+)"',
``` | 'thumbnail': r're:https://[^/]+/impf/7vN3ACwSTgChP96OdOfzFjUCzFR6ZglDQgWsIw/KPaACiVJJxM\.jpg\?size=800x450&quality=96&keep_aspect_ratio=1&background=000000&sign=b48ea459c4d33dbcba5e26d63574b1cb&type=video_thumb',
'timestamp': 0,
},
}, {
'url': 'http://biqle.org/watch/-4478184... | @@ -32,53 +36,70 @@ class BIQLEIE(InfoExtractor):
'id': '-44781847_168547604',
'ext': 'mp4',
'title': 'Ребенок в шоке от автоматической мойки',
+ 'description': 'Ребенок в шоке от автоматической мойки — Смотреть онлайн',
'timestamp': 1396633454,
- ... | yt_dlp/extractor/biqle.py | 26 | Python | 0.786 | suggestion | 170 | 51 | 51 | false | Fixing Biqle #193 | 2,731 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Bricio |
'ext': 'mp4',
'title': 'Ребенок в шоке от автоматической мойки',
'description': 'Ребенок в шоке от автоматической мойки — Смотреть онлайн',
'timestamp': 1396633454,
'upload_date': '20140404',
'thumbnail': r're:https://[^/]+/c535507/u190034692/video... | ```suggestion
r'<script.+?window.globEmbedUrl\s*=\s*\'((?:https?:)?//(?:daxab\.com|dxb\.to|[^/]+/player)/[^\']+)\'',
``` | 'timestamp': 1396633454,
'upload_date': '20140404',
'thumbnail': r're:https://[^/]+/c535507/u190034692/video/l_b84df002\.jpg',
},
}]
def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
... | @@ -32,53 +36,70 @@ class BIQLEIE(InfoExtractor):
'id': '-44781847_168547604',
'ext': 'mp4',
'title': 'Ребенок в шоке от автоматической мойки',
+ 'description': 'Ребенок в шоке от автоматической мойки — Смотреть онлайн',
'timestamp': 1396633454,
- ... | yt_dlp/extractor/biqle.py | 26 | Python | 0.714 | suggestion | 134 | 51 | 51 | false | Fixing Biqle #193 | 2,731 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Bricio |
'upload_date': '20140404',
'thumbnail': r're:https://[^/]+/c535507/u190034692/video/l_b84df002\.jpg',
},
}]
def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
title = self._search_regex(
... | ```suggestion
hash = self._search_regex(
r'<script id="data-embed-video[^<]+?hash:\s*"([^"<]+)"', webpage, 'Hash')
``` | }]
def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
title = self._html_search_meta('name', webpage, 'Title', fatal=False)
timestamp = unified_timestamp(self._html_search_meta('uploadDate', webpage, 'Upload Date', defau... | @@ -32,53 +36,70 @@ class BIQLEIE(InfoExtractor):
'id': '-44781847_168547604',
'ext': 'mp4',
'title': 'Ребенок в шоке от автоматической мойки',
+ 'description': 'Ребенок в шоке от автоматической мойки — Смотреть онлайн',
'timestamp': 1396633454,
- ... | yt_dlp/extractor/biqle.py | 26 | Python | 0.714 | suggestion | 141 | 51 | 51 | false | Fixing Biqle #193 | 2,731 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Bricio |
r'<meta.*itemprop ?= ?"description".*content ?= ?"([^"]+)".*/>',
webpage, 'Description', fatal=False)
globalEmbed_url = self._search_regex(
r'<script.+?window.globEmbedUrl = \'((?:https?:)?//(?:daxab\.com|dxb\.to|[^/]+/player)/[^\']+)\'.*?></script>',
webpage, 'g... | ```suggestion
f'https://{hostName}/method/video.get/{video_id}', video_id,
``` |
if VKIE.suitable(embed_url):
return self.url_result(embed_url, VKIE.ie_key(), video_id)
embed_page = self._download_webpage(
embed_url, video_id, 'Downloading embed webpage', headers={'Referer': url})
glob_params = self._parse_json(self._search_regex(
r'<sc... | @@ -32,53 +36,70 @@ class BIQLEIE(InfoExtractor):
'id': '-44781847_168547604',
'ext': 'mp4',
'title': 'Ребенок в шоке от автоматической мойки',
+ 'description': 'Ребенок в шоке от автоматической мойки — Смотреть онлайн',
'timestamp': 1396633454,
- ... | yt_dlp/extractor/biqle.py | 26 | Python | 0.571 | suggestion | 92 | 51 | 51 | false | Fixing Biqle #193 | 2,731 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Bricio |
return self.url_result(embed_url, VKIE.ie_key(), video_id)
embed_page = self._download_webpage(
embed_url, video_id, 'Downloading embed webpage', headers={'Referer': url})
globParams = self._parse_json(self._search_regex(
r'<script id="globParams">.*window.globParam... | makes sense to put it in a var | f'https://{host_name}/method/video.get/{video_id}', video_id,
headers={'Referer': url}, query={
'token': glob_params['video']['access_token'],
'videos': video_id,
'ckey': glob_params['c_key'],
'credentials': glob_params['video']['cr... | @@ -32,53 +36,70 @@ class BIQLEIE(InfoExtractor):
'id': '-44781847_168547604',
'ext': 'mp4',
'title': 'Ребенок в шоке от автоматической мойки',
+ 'description': 'Ребенок в шоке от автоматической мойки — Смотреть онлайн',
'timestamp': 1396633454,
- ... | yt_dlp/extractor/biqle.py | 26 | Python | 0.071 | suggestion | 30 | 51 | 45 | false | Fixing Biqle #193 | 2,731 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Bricio |
}, {
'url': 'http://biqle.org/watch/-44781847_168547604',
'md5': '7f24e72af1db0edf7c1aaba513174f97',
'info_dict': {
'id': '-44781847_168547604',
'ext': 'mp4',
'title': 'Ребенок в шоке от автоматической мойки',
'description': 'Ребенок в шоке от ... | ```suggestion
r'<script[^<]+?window.globEmbedUrl\s*=\s*\'((?:https?:)?//(?:daxab\.com|dxb\.to|[^/]+/player)/[^\']+)\'',
```
I think this is causing the need for dotall. In general, we want to avoid `.` completely in order to prevent issues like catastrophic backtracking and poor performance on large page... | 'md5': '7f24e72af1db0edf7c1aaba513174f97',
'info_dict': {
'id': '-44781847_168547604',
'ext': 'mp4',
'title': 'Ребенок в шоке от автоматической мойки',
'description': 'Ребенок в шоке от автоматической мойки — Смотреть онлайн',
'timestamp': 1396... | @@ -47,56 +46,51 @@ def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
- title = self._search_regex(
- r'<meta.*itemprop ?= ?"name".*content ?= ?"([^"]+)".*/>',
- webpage, 'Title', default='Empty Title', fatal=Fal... | yt_dlp/extractor/biqle.py | 26 | Python | 1 | performance | 385 | 51 | 51 | false | Fixing Biqle #193 | 2,731 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Bricio |
embed_page = self._download_webpage(
embed_url, video_id, 'Downloading embed webpage', headers={'Referer': url})
glob_params = self._parse_json(self._search_regex(
r'<script id="globParams">[^<]*window.globParams = ([^;]+);[^<]+</script>',
embed_page, 'Global Paramet... | ```suggestion
height_extra_key = traverse_obj(glob_params, ('video', 'partial', 'quality', height))
if height_extra_key:
formats.append({
'format_id': f'{height}p',
``` |
glob_params = self._parse_json(self._search_regex(
r'<script id="globParams">[^<]*window.globParams = ([^;]+);[^<]+</script>',
embed_page, 'Global Parameters'), video_id, transform_source=js_to_json)
host_name = compat_b64decode(glob_params['server'][::-1]).decode()
ite... | @@ -32,53 +33,64 @@ class BIQLEIE(InfoExtractor):
'id': '-44781847_168547604',
'ext': 'mp4',
'title': 'Ребенок в шоке от автоматической мойки',
+ 'description': 'Ребенок в шоке от автоматической мойки — Смотреть онлайн',
'timestamp': 1396633454,
- ... | yt_dlp/extractor/biqle.py | 26 | Python | 0.786 | suggestion | 233 | 51 | 51 | false | Fixing Biqle #193 | 2,731 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Bricio |
# coding: utf-8
from __future__ import unicode_literals
from .common import InfoExtractor
from .vk import VKIE
from ..compat import (
compat_b64decode,
compat_urllib_parse_unquote,
)
from ..utils import int_or_none
class BIQLEIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?biqle\.(?:com|org|ru)/watc... | should be `None` if it cant be extracted (ie, remove field from test), not 0 | # coding: utf-8
from __future__ import unicode_literals
from .common import InfoExtractor
from .vk import VKIE
from ..compat import compat_b64decode
from ..utils import (
int_or_none,
js_to_json,
traverse_obj,
unified_timestamp,
)
class BIQLEIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?bi... | @@ -3,27 +3,28 @@
from .common import InfoExtractor
from .vk import VKIE
-from ..compat import (
- compat_b64decode,
- compat_urllib_parse_unquote,
+from ..compat import compat_b64decode
+from ..utils import (
+ int_or_none,
+ js_to_json,
+ traverse_obj,
+ unified_timestamp,
)
-from ..utils impor... | yt_dlp/extractor/biqle.py | 26 | Python | 0.429 | refactor | 76 | 51 | 51 | false | Fixing Biqle #193 | 2,731 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Bricio |
'uploader': 'Phanolito',
'upload_date': '20120822',
},
}, {
'url': 'http://biqle.org/watch/-44781847_168547604',
'md5': '7f24e72af1db0edf7c1aaba513174f97',
'info_dict': {
'id': '-44781847_168547604',
'ext': 'mp4',
'title': '... | ```suggestion
upload_date = unified_timestamp(self._html_search_meta('uploadDate', webpage, 'Upload Date', default=None))
``` | 'upload_date': '19700101',
'thumbnail': r're:https://[^/]+/impf/7vN3ACwSTgChP96OdOfzFjUCzFR6ZglDQgWsIw/KPaACiVJJxM\.jpg\?size=800x450&quality=96&keep_aspect_ratio=1&background=000000&sign=b48ea459c4d33dbcba5e26d63574b1cb&type=video_thumb',
'timestamp': 0,
},
}, {
... | @@ -32,53 +33,64 @@ class BIQLEIE(InfoExtractor):
'id': '-44781847_168547604',
'ext': 'mp4',
'title': 'Ребенок в шоке от автоматической мойки',
+ 'description': 'Ребенок в шоке от автоматической мойки — Смотреть онлайн',
'timestamp': 1396633454,
- ... | yt_dlp/extractor/biqle.py | 26 | Python | 0.714 | suggestion | 135 | 51 | 51 | false | Fixing Biqle #193 | 2,731 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Bricio |
'title': "PASSE-PARTOUT - L'ete c'est fait pour jouer",
'description': 'Passe-Partout',
'uploader_id': 'mrsimpsonstef3',
'uploader': 'Phanolito',
'upload_date': '20120822',
},
}, {
'url': 'http://biqle.org/watch/-44781847_168547604',
... | fatal=False means extraction is non-fatal, but display a warning
default=None means don't show any warning
```suggestion
title = self._html_search_meta('name', webpage, 'Title', fatal=False)
``` | 'ext': 'mp4',
'title': 'Forsaken By Hope Studio Clip',
'description': 'Forsaken By Hope Studio Clip — Смотреть онлайн',
'upload_date': '19700101',
'thumbnail': r're:https://[^/]+/impf/7vN3ACwSTgChP96OdOfzFjUCzFR6ZglDQgWsIw/KPaACiVJJxM\.jpg\?size=800x450&qualit... | @@ -32,53 +33,64 @@ class BIQLEIE(InfoExtractor):
'id': '-44781847_168547604',
'ext': 'mp4',
'title': 'Ребенок в шоке от автоматической мойки',
+ 'description': 'Ребенок в шоке от автоматической мойки — Смотреть онлайн',
'timestamp': 1396633454,
- ... | yt_dlp/extractor/biqle.py | 26 | Python | 0.857 | refactor | 206 | 51 | 51 | false | Fixing Biqle #193 | 2,731 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Bricio |
'upload_date': '20120822',
},
}, {
'url': 'http://biqle.org/watch/-44781847_168547604',
'md5': '7f24e72af1db0edf7c1aaba513174f97',
'info_dict': {
'id': '-44781847_168547604',
'ext': 'mp4',
'title': 'Ребенок в шоке от автоматической мойк... | ```suggestion
description = self._html_search_meta('description', webpage, 'Description', default=None)
``` | 'thumbnail': r're:https://[^/]+/impf/7vN3ACwSTgChP96OdOfzFjUCzFR6ZglDQgWsIw/KPaACiVJJxM\.jpg\?size=800x450&quality=96&keep_aspect_ratio=1&background=000000&sign=b48ea459c4d33dbcba5e26d63574b1cb&type=video_thumb',
'timestamp': 0,
},
}, {
'url': 'http://biqle.org/watch/-4478184... | @@ -32,53 +33,64 @@ class BIQLEIE(InfoExtractor):
'id': '-44781847_168547604',
'ext': 'mp4',
'title': 'Ребенок в шоке от автоматической мойки',
+ 'description': 'Ребенок в шоке от автоматической мойки — Смотреть онлайн',
'timestamp': 1396633454,
- ... | yt_dlp/extractor/biqle.py | 26 | Python | 0.714 | suggestion | 117 | 51 | 51 | false | Fixing Biqle #193 | 2,731 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Bricio |
_VALID_URL = r'https?://(?:www\.)?daftsex\.com/watch/(?P<id>-?\d+_\d+)'
_TESTS = [{
'url': 'https://daftsex.com/watch/-35370899_456246186',
'md5': 'd95135e6cea2d905bea20dbe82cda64a',
'info_dict': {
'id': '-35370899_456246186',
'ext': 'mp4',
'title': 'j... | ```suggestion
title = self._html_search_meta('name', webpage, 'title')
```
fatal=False is default | _VALID_URL = r'https?://(?:www\.)?daftsex\.com/watch/(?P<id>-?\d+_\d+)'
_TESTS = [{
'url': 'https://daftsex.com/watch/-35370899_456246186',
'md5': 'd95135e6cea2d905bea20dbe82cda64a',
'info_dict': {
'id': '-35370899_456246186',
'ext': 'mp4',
'title': 'j... | @@ -27,7 +40,10 @@ class DaftsexIE(InfoExtractor):
def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
- title = get_elements_by_class('heading', webpage)[-1]
+ title = self._html_search_meta('name', webpage, 'Title', fatal=Fa... | yt_dlp/extractor/daftsex.py | 26 | Python | 0.714 | suggestion | 108 | 51 | 51 | false | [daftsex] Fix yt-dlp#2637 | 2,757 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Soebb |
webpage, 'duration', fatal=False))
views = parse_count(self._search_regex(
r'Views: ([0-9 ]+)',
webpage, 'views', fatal=False))
player_hash = self._search_regex(
r'DaxabPlayer\.Init\({[\s\S]*hash:\s*"([0-9a-zA-Z_\-]+)"[\s\S]*}',
webpage, 'play... | ```suggestion
cdn_files = traverse_obj(video_params, ('video', 'cdn_files')) or {}
if cdn_files:
formats = []
for format_id, format_data in cdn_files.items():
``` | description = self._html_search_meta('description', webpage, 'Description', default=None)
duration = parse_duration(self._search_regex(
r'Duration: ((?:[0-9]{2}:){0,2}[0-9]{2})',
webpage, 'duration', fatal=False))
views = parse_count(self._search_regex(
r'Vie... | @@ -52,28 +68,79 @@ def _real_extract(self, url):
video_id, transform_source=js_to_json)
server_domain = 'https://%s' % compat_b64decode(video_params['server'][::-1]).decode('utf-8')
- formats = []
- for format_id, format_data in video_params['video']['cdn_files'].items():
- ... | yt_dlp/extractor/daftsex.py | 26 | Python | 0.786 | suggestion | 207 | 51 | 51 | false | [daftsex] Fix yt-dlp#2637 | 2,757 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Soebb |
r'DaxabPlayer\.Init\({[\s\S]*color:\s*"([0-9a-z]+)"[\s\S]*}',
webpage, 'player color', fatal=False) or ''
embed_page = self._download_webpage(
'https://daxab.com/player/%s?color=%s' % (player_hash, player_color),
video_id, headers={'Referer': url})
video_... | ```suggestion
formats.append({
'format_id': format_id,
'url': f'{server_domain}/videos/{video_id.replace("_", "/")}/{height}.mp4?extra={format_data.split(".")[-1]}',
'height': int_or_none(height),
'ext': ext,
... | player_hash = self._search_regex(
r'DaxabPlayer\.Init\({[\s\S]*hash:\s*"([0-9a-zA-Z_\-]+)"[\s\S]*}',
webpage, 'player hash')
player_color = self._search_regex(
r'DaxabPlayer\.Init\({[\s\S]*color:\s*"([0-9a-z]+)"[\s\S]*}',
webpage, 'player color', fatal=Fal... | @@ -52,28 +68,79 @@ def _real_extract(self, url):
video_id, transform_source=js_to_json)
server_domain = 'https://%s' % compat_b64decode(video_params['server'][::-1]).decode('utf-8')
- formats = []
- for format_id, format_data in video_params['video']['cdn_files'].items():
- ... | yt_dlp/extractor/daftsex.py | 26 | Python | 0.857 | suggestion | 334 | 51 | 51 | false | [daftsex] Fix yt-dlp#2637 | 2,757 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Soebb |
for format_id, format_data in video_params['video']['cdn_files'].items():
ext, height = format_id.split('_')
extra_quality_data = format_data.split('.')[-1]
url = f'{server_domain}/videos/{video_id.replace("_", "/")}/{height}.mp4?extra={extra_quality_data}'
... | ```suggestion
thumbnail =
return {
'id': video_id,
'title': title,
'formats': formats,
'description': description,
'duration': duration,
'thumbnail': try_get(video_params,
... | server_domain = 'https://%s' % compat_b64decode(video_params['server'][::-1]).decode('utf-8')
cdn_files = traverse_obj(video_params, ('video', 'cdn_files')) or {}
if cdn_files:
formats = []
for format_id, format_data in cdn_files.items():
ext, height = fo... | @@ -52,28 +68,79 @@ def _real_extract(self, url):
video_id, transform_source=js_to_json)
server_domain = 'https://%s' % compat_b64decode(video_params['server'][::-1]).decode('utf-8')
- formats = []
- for format_id, format_data in video_params['video']['cdn_files'].items():
- ... | yt_dlp/extractor/daftsex.py | 26 | Python | 0.786 | suggestion | 552 | 51 | 51 | false | [daftsex] Fix yt-dlp#2637 | 2,757 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Soebb |
'height': int_or_none(height),
'ext': ext,
})
self._sort_formats(formats)
thumbnails = []
for k, v in item.items():
if k.startswith('photo_') and v:
width = k.replace('photo_', ''... | Since the if block returns, else can be removed and the whole thing dedented | 'ext': ext,
})
self._sort_formats(formats)
thumbnails = []
for k, v in item.items():
if k.startswith('photo_') and v:
width = k.replace('photo_', '')
thumbnails.append({
'id': width,
... | @@ -52,28 +68,79 @@ def _real_extract(self, url):
video_id, transform_source=js_to_json)
server_domain = 'https://%s' % compat_b64decode(video_params['server'][::-1]).decode('utf-8')
- formats = []
- for format_id, format_data in video_params['video']['cdn_files'].items():
- ... | yt_dlp/extractor/daftsex.py | 26 | Python | 0.286 | suggestion | 76 | 27 | 27 | false | [daftsex] Fix yt-dlp#2637 | 2,757 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Soebb |
# We will benefit from it by extracting some metadata
mobj = re.search(r'(?P<height>\d{3,4})[pP]_(?P<bitrate>\d+)[kK]_\d+', video_url)
if mobj:
if not height:
height = int(mobj.group('height'))
bitrate = int(mobj.group('bitrate'))
... | Use `self._search_json_ld(webpage, video_id, expected_type='Video', default={})` ? | 'https://www.youporn.com/api/video/media_definitions/%s/' % video_id,
display_id)
formats = []
for definition in definitions:
if not isinstance(definition, dict):
continue
video_url = url_or_none(definition.get('videoUrl'))
if ... | @@ -114,43 +114,51 @@ def _real_extract(self, url):
webpage = self._download_webpage(
'http://www.youporn.com/watch/%s' % video_id, display_id,
- headers={'Cookie': 'age_verified=1'})
-
- title = self._html_search_regex(
- r'(?s)<div[^>]+class=["\']watchVideoTitle[^>... | yt_dlp/extractor/youporn.py | 26 | Python | 0.571 | question | 82 | 51 | 51 | false | [youporn] Fix extraction of metadata | 2,768 | yt-dlp/yt-dlp | 132,642 | Python | dirkf | marieell |
class PlayVidsIE(PeekVidsIE):
_VALID_URL = r'https?://(?:www\.)?playvids\.com/(?:embed/|[^/]{2}/)?(?P<id>[^/?#]*)'
_TESTS = [{
'url': 'https://www.playvids.com/U3pBrYhsjXM/pc/dane-jones-cute-redhead-with-perfect-tits-with-mini-vamp',
'md5': '2f12e50213dd65f142175da633c4564c',
'info_dic... | don't do clever tricks for test definition. Define them literally. You can also make the rest only_matching | })
return info
class PlayVidsIE(PeekVidsIE):
_VALID_URL = r'https?://(?:www\.)?playvids\.com/(?:embed/|[^/]{2}/)?(?P<id>[^/?#]*)'
_TESTS = [{
'url': 'https://www.playvids.com/U3pBrYhsjXM/pc/dane-jones-cute-redhead-with-perfect-tits-with-mini-vamp',
'md5': 'cd7dfd8a2e815a4540236... | @@ -40,46 +45,35 @@ def _real_extract(self, url):
formats = [{'url': url} for url in srcs.values()]
self._sort_formats(formats)
- title = remove_end(self._html_search_regex(
- (r'<h1.*?>\s*(.+?)\s*</h1>', r'<title>\s*(.+?)\s*</title>'),
- webpage, 'video title', defa... | yt_dlp/extractor/peekvids.py | 26 | Python | 0.357 | suggestion | 107 | 34 | 30 | false | [peekvids] use JSON-LD | 2,784 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | schn0sch |
# coding: utf-8
from .common import InfoExtractor
class VideocampusSachsenIE(InfoExtractor):
_VALID_URL = r'https?://videocampus\.sachsen\.de/(?:(?:m/(?P<tmp_id>[0-9a-f]+))|(?:(?P<c>category/)?video/(?P<display_id>[A-Za-z0-9-]+)/(?P<id>[0-9a-f]{32}))(?(c)/[0-9]+))'
_TESTS = [
{
'url': 'ht... | ```suggestion
_VALID_URL = r'''(?x)https?://videocampus\.sachsen\.de/(?:
m/(?P<tmp_id>[0-9a-f]+)|
(?:category/)?video/[\w-]+/(?P<id>[0-9a-f]{32})
)'''
```
(untested) | # coding: utf-8
from .common import InfoExtractor
class VideocampusSachsenIE(InfoExtractor):
_VALID_URL = r'''(?x)https?://videocampus\.sachsen\.de/(?:
m/(?P<tmp_id>[0-9a-f]+)|
(?:category/)?video/(?P<display_id>[\w-]+)/(?P<id>[0-9a-f]{32})
)'''
_TESTS = [
{
'url': 'ht... | @@ -0,0 +1,98 @@
+# coding: utf-8
+from .common import InfoExtractor
+
+
+class VideocampusSachsenIE(InfoExtractor):
+ _VALID_URL = r'https?://videocampus\.sachsen\.de/(?:(?:m/(?P<tmp_id>[0-9a-f]+))|(?:(?P<c>category/)?video/(?P<display_id>[A-Za-z0-9-]+)/(?P<id>[0-9a-f]{32}))(?(c)/[0-9]+))' | yt_dlp/extractor/videocampus_sachsen.py | 6 | Python | 0.714 | suggestion | 195 | 31 | 31 | false | [VideocampusSachsen] Add extractor | 2,787 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | FestplattenSchnitzel |
'info_dict': {
'id': 'fc99c527e4205b121cb7c74433469262',
'title': 'Was ist selbstgesteuertes Lernen?',
'ext': 'mp4',
},
}
]
def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webp... | ```suggestion
def _real_extract(self, url):
video_id, tmp_id, display_id = self._match_valid_url(url).group('id', 'tmp_id', 'display_id')
webpage = self._download_webpage(url, video_id or tmp_id)
if not tmp_id:
video_id = self._html_search_regex(
r'src="ht... | # coding: utf-8
from .common import InfoExtractor
class VideocampusSachsenIE(InfoExtractor):
_VALID_URL = r'''(?x)https?://videocampus\.sachsen\.de/(?:
m/(?P<tmp_id>[0-9a-f]+)|
(?:category/)?video/(?P<display_id>[\w-]+)/(?P<id>[0-9a-f]{32})
)'''
_TESTS = [
{
'url': 'ht... | @@ -0,0 +1,106 @@
+# coding: utf-8
+from .common import InfoExtractor
+
+
+class VideocampusSachsenIE(InfoExtractor):
+ _VALID_URL = r'''(?x)https?://videocampus\.sachsen\.de/(?:
+ m/(?P<tmp_id>[0-9a-f]+)|
+ (?:category/)?video/(?P<display_id>[\w-]+)/(?P<id>[0-9a-f]{32})
+ )'''
+
+ _TESTS = [
+ ... | yt_dlp/extractor/videocampus_sachsen.py | 26 | Python | 0.857 | refactor | 2,263 | 27 | 97 | false | [VideocampusSachsen] Add extractor | 2,787 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | FestplattenSchnitzel |
'title': title,
'display_id': display_id,
'formats': formats,
'subtitles': subtitles
}
class VideocampusSachsenEmbedIE(InfoExtractor):
_VALID_URL = r'https?://videocampus.sachsen.de/media/embed\?key=(?P<id>[0-9a-f]+)'
_TESTS = [
{
'u... | ```suggestion
title = self._html_search_regex(r'<img[^>]*title="([^"<]+)"', webpage, 'title', fatal=False)
``` | 'title': title,
'display_id': display_id,
'formats': formats,
'subtitles': subtitles
}
class VideocampusSachsenEmbedIE(InfoExtractor):
_VALID_URL = r'https?://videocampus.sachsen.de/media/embed\?key=(?P<id>[0-9a-f]+)'
_TESTS = [
{
'u... | @@ -0,0 +1,96 @@
+# coding: utf-8
+from .common import InfoExtractor
+
+
+class VideocampusSachsenIE(InfoExtractor):
+ _VALID_URL = r'''(?x)https?://videocampus\.sachsen\.de/(?:
+ m/(?P<tmp_id>[0-9a-f]+)|
+ (?:category/)?video/(?P<display_id>[\w-]+)/(?P<id>[0-9a-f]{32})
+ )'''
+
+ _TESTS = [
+ ... | yt_dlp/extractor/videocampus_sachsen.py | 26 | Python | 0.714 | suggestion | 120 | 38 | 38 | false | [VideocampusSachsen] Add extractor | 2,787 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | FestplattenSchnitzel |
'ext': 'mp4',
},
},
{
'url': 'https://videocampus.sachsen.de/category/video/Tutorial-zur-Nutzung-von-Adobe-Connect-aus-Veranstalter-Sicht/09d4ed029002eb1bdda610f1103dd54c/100',
'info_dict': {
'id': '09d4ed029002eb1bdda610f1103dd54c',
... | isn't the second regex just `_search_meta`?
```suggestion
title = self._html_search_regex(
(r'<h1>(?P<content>[^<]+)</h1>', *self._meta_regex('title')),
webpage, 'title', group='content', fatal=False)
``` | 'ext': 'mp4',
},
},
{
'url': 'https://videocampus.sachsen.de/category/video/Tutorial-zur-Nutzung-von-Adobe-Connect-aus-Veranstalter-Sicht/09d4ed029002eb1bdda610f1103dd54c/100',
'info_dict': {
'id': '09d4ed029002eb1bdda610f1103dd54c',
... | @@ -0,0 +1,96 @@
+# coding: utf-8
+from .common import InfoExtractor
+
+
+class VideocampusSachsenIE(InfoExtractor):
+ _VALID_URL = r'''(?x)https?://videocampus\.sachsen\.de/(?:
+ m/(?P<tmp_id>[0-9a-f]+)|
+ (?:category/)?video/(?P<display_id>[\w-]+)/(?P<id>[0-9a-f]{32})
+ )'''
+
+ _TESTS = [
+ ... | yt_dlp/extractor/videocampus_sachsen.py | 26 | Python | 0.786 | question | 241 | 51 | 51 | false | [VideocampusSachsen] Add extractor | 2,787 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | FestplattenSchnitzel |
'ext': 'mp4',
},
},
{
'url': 'https://videocampus.sachsen.de/video/Was-ist-selbstgesteuertes-Lernen/fc99c527e4205b121cb7c74433469262',
'info_dict': {
'id': 'fc99c527e4205b121cb7c74433469262',
'title': 'Was ist selbstgest... | only id/format extraction should be fatal. This download isn't always necessary for that. So shouldn't it be non-fatal?
```suggestion
webpage = self._download_webpage(url, video_id or tmp_id, fatal=False) or ''
``` | 'ext': 'mp4',
},
},
{
'url': 'https://videocampus.sachsen.de/video/Was-ist-selbstgesteuertes-Lernen/fc99c527e4205b121cb7c74433469262',
'info_dict': {
'id': 'fc99c527e4205b121cb7c74433469262',
'title': 'Was ist selbstgest... | @@ -0,0 +1,96 @@
+# coding: utf-8
+from .common import InfoExtractor
+
+
+class VideocampusSachsenIE(InfoExtractor):
+ _VALID_URL = r'''(?x)https?://videocampus\.sachsen\.de/(?:
+ m/(?P<tmp_id>[0-9a-f]+)|
+ (?:category/)?video/(?P<display_id>[\w-]+)/(?P<id>[0-9a-f]{32})
+ )'''
+
+ _TESTS = [
+ ... | yt_dlp/extractor/videocampus_sachsen.py | 26 | Python | 0.857 | refactor | 225 | 51 | 51 | false | [VideocampusSachsen] Add extractor | 2,787 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | FestplattenSchnitzel |
json_url = self._search_regex(
r'var\s+url\s*=\s*"([^"]+)"\s*\+\s*ruurl', webpage,
'Json URL')
full_json_url = f'https:{json_url}b=mozilla&p=win&v=97&f=0&d=1'
data = self._download_json(
full_json_url, video_id, 'Downloading json')
if data.get('clip')... | ```py
if traverse...:
formats = [{'url': ...}]
else:
formats = ...
self._sort_formats(formats)
return {
...,
'formats': formats,
}
``` | # coding: utf-8
from __future__ import unicode_literals
import re
from .common import InfoExtractor
from ..utils import (
parse_duration,
traverse_obj,
unified_timestamp,
)
class RTVSIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?rtvs\.sk/(?:radio|televizia)/archiv(?:/\d+)?/(?P<id>\d+)/?(?:[#... | @@ -3,45 +3,96 @@
from .common import InfoExtractor
+from ..utils import (
+ int_or_none,
+ parse_duration,
+ traverse_obj,
+ unified_timestamp,
+)
+
class RTVSIE(InfoExtractor):
- _VALID_URL = r'https?://(?:www\.)?rtvs\.sk/(?:radio|televizia)/archiv/\d+/(?P<id>\d+)'
+ _VALID_URL = r'https?://... | yt_dlp/extractor/rtvs.py | 26 | Python | 0.786 | style | 230 | 27 | 90 | false | Fix rtvs extractor | 2,795 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Bricio |
'thumbnail': 'https://www.rtvs.sk/media/a501/image/file/2/0916/robin.jpg',
}
}]
# TODO
# live video https://www.rtvs.sk/televizia/live-3 , https://www.rtvs.sk/televizia/sport
# live radio https://slovensko.rtvs.sk/player
def _real_extract(self, url):
video_id = self._match_id(url)
... | ```suggestion
data = self._download_json(f'https:{json_url}b=mozilla&p=win&v=97&f=0&d=1', video_id)
``` | 'upload_date': '20211111',
'thumbnail': 'https://www.rtvs.sk/media/a501/image/file/2/0916/robin.jpg',
}
}]
def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
iframe_id = self._search_regex(
... | @@ -3,45 +3,96 @@
from .common import InfoExtractor
+from ..utils import (
+ int_or_none,
+ parse_duration,
+ traverse_obj,
+ unified_timestamp,
+)
+
class RTVSIE(InfoExtractor):
- _VALID_URL = r'https?://(?:www\.)?rtvs\.sk/(?:radio|televizia)/archiv/\d+/(?P<id>\d+)'
+ _VALID_URL = r'https?://... | yt_dlp/extractor/rtvs.py | 26 | Python | 0.714 | suggestion | 113 | 47 | 38 | false | Fix rtvs extractor | 2,795 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Bricio |
'display_id': '307655',
'duration': 831,
'upload_date': '20211111',
'thumbnail': 'https://www.rtvs.sk/media/a501/image/file/2/0916/robin.jpg',
}
}]
# TODO
# live video https://www.rtvs.sk/televizia/live-3 , https://www.rtvs.sk/televizia/sport
# live radio htt... | ```suggestion
json_url = self._search_regex(r'var\s+url\s*=\s*"([^"]+)"\s*\+\s*ruurl', webpage, 'json URL')
``` | 'timestamp': 1636652760,
'display_id': '307655',
'duration': 831,
'upload_date': '20211111',
'thumbnail': 'https://www.rtvs.sk/media/a501/image/file/2/0916/robin.jpg',
}
}]
def _real_extract(self, url):
video_id = self._match_id(url)
... | @@ -3,45 +3,96 @@
from .common import InfoExtractor
+from ..utils import (
+ int_or_none,
+ parse_duration,
+ traverse_obj,
+ unified_timestamp,
+)
+
class RTVSIE(InfoExtractor):
- _VALID_URL = r'https?://(?:www\.)?rtvs\.sk/(?:radio|televizia)/archiv/\d+/(?P<id>\d+)'
+ _VALID_URL = r'https?://... | yt_dlp/extractor/rtvs.py | 26 | Python | 0.714 | suggestion | 121 | 50 | 41 | false | Fix rtvs extractor | 2,795 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Bricio |
'info_dict': {
'id': '18083',
'ext': 'mp4',
'title': 'Robin',
'description': '\nRichard so svojím psíkom Robinom a deťmi prežívajú dobrodružné príbehy, ktoré pomáhajú malým divákom orientovať sa a nachádzať riešenia v rôznych zložitých životných situáciách.',
... | ```suggestion
fr'<iframe[^>]+id\s*=\s*"player_[^_]+_{re.escape(iframe_id)}"[^>]+src\s*=\s*"([^"]+)"', webpage,
``` | 'url': 'https://www.rtvs.sk/televizia/archiv/18083?utm_source=web&utm_medium=rozcestnik&utm_campaign=Robin',
'info_dict': {
'id': '18083',
'ext': 'mp4',
'title': 'Robin',
'description': 'md5:2f70505a7b8364491003d65ff7a0940a',
'timestamp': 16366... | @@ -3,45 +3,96 @@
from .common import InfoExtractor
+from ..utils import (
+ int_or_none,
+ parse_duration,
+ traverse_obj,
+ unified_timestamp,
+)
+
class RTVSIE(InfoExtractor):
- _VALID_URL = r'https?://(?:www\.)?rtvs\.sk/(?:radio|televizia)/archiv/\d+/(?P<id>\d+)'
+ _VALID_URL = r'https?://... | yt_dlp/extractor/rtvs.py | 26 | Python | 0.714 | security | 128 | 51 | 47 | false | Fix rtvs extractor | 2,795 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Bricio |
# tv archive
'url': 'https://www.rtvs.sk/televizia/archiv/18083?utm_source=web&utm_medium=rozcestnik&utm_campaign=Robin',
'info_dict': {
'id': '18083',
'ext': 'mp4',
'title': 'Robin',
'description': '\nRichard so svojím psíkom Robinom a deťmi preží... | ```suggestion
iframe_id = self._search_regex(
r'<iframe[^>]+id\s*=\s*"player_[^_]+_([0-9]+)"', webpage, 'iframe ID')
``` | }, {
# tv archive
'url': 'https://www.rtvs.sk/televizia/archiv/18083?utm_source=web&utm_medium=rozcestnik&utm_campaign=Robin',
'info_dict': {
'id': '18083',
'ext': 'mp4',
'title': 'Robin',
'description': 'md5:2f70505a7b8364491003d65ff7a0940a',
... | @@ -3,45 +3,96 @@
from .common import InfoExtractor
+from ..utils import (
+ int_or_none,
+ parse_duration,
+ traverse_obj,
+ unified_timestamp,
+)
+
class RTVSIE(InfoExtractor):
- _VALID_URL = r'https?://(?:www\.)?rtvs\.sk/(?:radio|televizia)/archiv/\d+/(?P<id>\d+)'
+ _VALID_URL = r'https?://... | yt_dlp/extractor/rtvs.py | 26 | Python | 0.714 | suggestion | 143 | 51 | 49 | false | Fix rtvs extractor | 2,795 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Bricio |
# coding: utf-8
from __future__ import unicode_literals
from .common import InfoExtractor
from ..utils import (
int_or_none,
parse_duration,
traverse_obj,
unified_timestamp,
)
class RTVSIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?rtvs\.sk/(?:radio|televizia)/archiv/?.*/(?P<id>\d+)\??.*'... | did u mean this?
```suggestion
_VALID_URL = r'https?://(?:www\.)?rtvs\.sk/(?:radio|televizia)/archiv(?:/\d+)?/(?P<id>\d+)/?(?:[#?]|$)'
``` | # coding: utf-8
from __future__ import unicode_literals
import re
from .common import InfoExtractor
from ..utils import (
parse_duration,
traverse_obj,
unified_timestamp,
)
class RTVSIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?rtvs\.sk/(?:radio|televizia)/archiv(?:/\d+)?/(?P<id>\d+)/?(?:[#... | @@ -3,45 +3,96 @@
from .common import InfoExtractor
+from ..utils import (
+ int_or_none,
+ parse_duration,
+ traverse_obj,
+ unified_timestamp,
+)
+
class RTVSIE(InfoExtractor):
- _VALID_URL = r'https?://(?:www\.)?rtvs\.sk/(?:radio|televizia)/archiv/\d+/(?P<id>\d+)'
+ _VALID_URL = r'https?://... | yt_dlp/extractor/rtvs.py | 15 | Python | 0.714 | suggestion | 145 | 40 | 40 | false | Fix rtvs extractor | 2,795 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Bricio |
webpage = self._download_webpage(url, video_id)
iframe_id = self._search_regex(
r'<iframe[^>]+id\s*=\s*"player_[^_]+_([0-9]+)"', webpage,
'Iframe ID')
iframe_url = self._search_regex(
fr'<iframe[^>]+id\s*=\s*"player_[^_]+_{iframe_id}"[^>]+src\s*=\s*"([^"]+)"'... | parse_duration always return int or None | r'<iframe[^>]+id\s*=\s*"player_[^_]+_([0-9]+)"', webpage, 'Iframe ID')
iframe_url = self._search_regex(
fr'<iframe[^>]+id\s*=\s*"player_[^_]+_{re.escape(iframe_id)}"[^>]+src\s*=\s*"([^"]+)"', webpage, 'Iframe URL')
webpage = self._download_webpage(iframe_url, video_id, 'Download... | @@ -3,45 +3,96 @@
from .common import InfoExtractor
+from ..utils import (
+ int_or_none,
+ parse_duration,
+ traverse_obj,
+ unified_timestamp,
+)
+
class RTVSIE(InfoExtractor):
- _VALID_URL = r'https?://(?:www\.)?rtvs\.sk/(?:radio|televizia)/archiv/\d+/(?P<id>\d+)'
+ _VALID_URL = r'https?://... | yt_dlp/extractor/rtvs.py | 26 | Python | 0.071 | suggestion | 40 | 37 | 28 | false | Fix rtvs extractor | 2,795 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Bricio |
'upload_date': '20211111',
'thumbnail': 'https://www.rtvs.sk/media/a501/image/file/2/0916/robin.jpg',
}
}]
def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
iframe_id = self._search_regex(
... | ```suggestion
self._sort_formats(formats)
```
This must be always run | 'upload_date': '20211111',
'thumbnail': 'https://www.rtvs.sk/media/a501/image/file/2/0916/robin.jpg',
}
}]
def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
iframe_id = self._search_regex(
... | @@ -54,45 +55,35 @@ class RTVSIE(InfoExtractor):
}
}]
-# TODO
-# live video https://www.rtvs.sk/televizia/live-3 , https://www.rtvs.sk/televizia/sport
-# live radio https://slovensko.rtvs.sk/player
-
def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._do... | yt_dlp/extractor/rtvs.py | 26 | Python | 0.571 | suggestion | 80 | 38 | 38 | false | Fix rtvs extractor | 2,795 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Bricio |
def _real_extract(self, url):
video_id = self._match_id(url)
return self.url_result(
'arcpublishing:wapo:' + video_id, 'ArcPublishing', video_id)
class WashingtonPostArticleIE(InfoExtractor):
IE_NAME = 'washingtonpost:article'
_VALID_URL = r'https?://(?:www\.)?washingtonpost\.c... | The subdomain may change. Use regex | def _real_extract(self, url):
video_id = self._match_id(url)
return self.url_result(
'arcpublishing:wapo:' + video_id, 'ArcPublishing', video_id)
class WashingtonPostArticleIE(InfoExtractor):
IE_NAME = 'washingtonpost:article'
_VALID_URL = r'https?://(?:www\.)?washingtonpost\.c... | @@ -59,9 +61,10 @@ class WashingtonPostArticleIE(InfoExtractor):
'description': 'Overly complicated paper pushing is nothing new to government bureaucracy. But the way federal retirement applications are filed may be the most outdated. David Fahrenthold explains.',
'timestamp': 1395440... | yt_dlp/extractor/washingtonpost.py | 26 | Python | 0.143 | suggestion | 35 | 51 | 51 | false | [washingtonpost] Add feature to read data from json that will be loaded on page. | 2,796 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Bricio |
'url': 'https://www.washingtonpost.com/posttv/world/iraq-to-track-down-antiquities-after-islamic-state-museum-rampage/2015/02/28/7c57e916-bf86-11e4-9dfb-03366e719af8_video.html',
'only_matching': True,
}]
@classmethod
def _extract_urls(cls, webpage):
return re.findall(
r... | why are the md5 changing? is this a fragmented download? In that case, md5 check should be removed | 'url': 'https://www.washingtonpost.com/posttv/world/iraq-to-track-down-antiquities-after-islamic-state-museum-rampage/2015/02/28/7c57e916-bf86-11e4-9dfb-03366e719af8_video.html',
'only_matching': True,
}]
@classmethod
def _extract_urls(cls, webpage):
return re.findall(
r... | @@ -50,7 +52,7 @@ class WashingtonPostArticleIE(InfoExtractor):
'title': 'Sinkhole of bureaucracy',
},
'playlist': [{
- 'md5': 'b9be794ceb56c7267d410a13f99d801a',
+ 'md5': '7ccf53ea8cbb77de5f570242b3b21a59', | yt_dlp/extractor/washingtonpost.py | 26 | Python | 0.286 | question | 98 | 51 | 51 | false | [washingtonpost] Add feature to read data from json that will be loaded on page. | 2,796 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Bricio |
},
]
@classmethod
def suitable(cls, url):
return (
False
if BandcampAlbumIE.suitable(url)
or BandcampIE.suitable(url)
or BandcampWeeklyIE.suitable(url)
else super(BandcampUserIE, cls).suitable(url)
)
def _real_extract(self... | ```suggestion
if discography_data:
``` | # coding: utf-8
from __future__ import unicode_literals
import random
import re
import time
from .common import InfoExtractor
from ..compat import compat_str
from ..utils import (
ExtractorError,
float_or_none,
int_or_none,
KNOWN_EXTENSIONS,
parse_filesize,
str_or_none,
try_get,
update... | @@ -429,3 +421,116 @@ def _real_extract(self, url):
ie=self._TYPE_IE_DICT[item[1]])
for item in items]
return self.playlist_result(entries, id)
+
+
+class BandcampUserIE(InfoExtractor):
+ IE_NAME = "Bandcamp:user"
+ _VALID_URL = r"https?://(?:(?P<id>[^.]+)\.)?bandcamp\.com"
... | yt_dlp/extractor/bandcamp.py | 26 | Python | 0.429 | suggestion | 48 | 51 | 446 | false | feat: support bandcamp user urls | 2,800 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | lyz-code |
entries = []
# Bandcamp User type 1 page
discography_data = re.findall(
r'<li data-item-id="([^"]+)[^>]+>\s*<a href="(/[^/]+/[^/"]+)">',
webpage,
re.MULTILINE,
)
if len(discography_data) > 0:
for match in discography_data:
... | ```suggestion
entries = [self.url_result(urljoin(url, element_url)) for element_id, element_url in discography_data]
```
Return id and title only if they are actually correct | # coding: utf-8
from __future__ import unicode_literals
import random
import re
import time
from .common import InfoExtractor
from ..compat import compat_str
from ..utils import (
ExtractorError,
float_or_none,
int_or_none,
KNOWN_EXTENSIONS,
parse_filesize,
str_or_none,
try_get,
update... | @@ -429,3 +421,116 @@ def _real_extract(self, url):
ie=self._TYPE_IE_DICT[item[1]])
for item in items]
return self.playlist_result(entries, id)
+
+
+class BandcampUserIE(InfoExtractor):
+ IE_NAME = "Bandcamp:user"
+ _VALID_URL = r"https?://(?:(?P<id>[^.]+)\.)?bandcamp\.com"
... | yt_dlp/extractor/bandcamp.py | 26 | Python | 0.714 | suggestion | 189 | 51 | 446 | false | feat: support bandcamp user urls | 2,800 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | lyz-code |
title = '%s - %s' % (artist, track) if artist else track
if not duration:
duration = float_or_none(self._html_search_meta(
'duration', webpage, default=None))
return {
'id': track_id,
'title': title,
'thumbnail': thumbnail,
... | ```suggestion
_VALID_URL = r'https?://(?:(?P<subdomain>[^.]+)\.)?bandcamp\.com/album/(?P<id>[^/?#&]+)'
```
unnecessary change | title = '%s - %s' % (artist, track) if artist else track
if not duration:
duration = float_or_none(self._html_search_meta(
'duration', webpage, default=None))
return {
'id': track_id,
'title': title,
'thumbnail': thumbnail,
... | @@ -212,7 +212,7 @@ def _real_extract(self, url):
class BandcampAlbumIE(BandcampIE):
IE_NAME = 'Bandcamp:album'
- _VALID_URL = r'https?://(?:(?P<subdomain>[^.]+)\.)?bandcamp\.com(?!/music)(?:/album/(?P<id>[^/?#&]+))?'
+ _VALID_URL = r'https?://(?:(?P<subdomain>[^.]+)\.)?bandcamp\.com/album/(?P<album_id>[^... | yt_dlp/extractor/bandcamp.py | 26 | Python | 0.786 | suggestion | 132 | 51 | 51 | false | feat: support bandcamp user urls | 2,800 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | lyz-code |
},
}, {
'url': 'https://coldworldofficial.bandcamp.com/music',
'playlist_mincount': 10,
'info_dict': {
'id': 'coldworldofficial',
'title': 'Discography of coldworldofficial',
},
}, {
'url': 'https://nuclearwarnowproductions.bandcamp.com/mus... | I noticed that this is seriously over capturing. Can you give example why you can't just capture the homepage and /music? | # coding: utf-8
from __future__ import unicode_literals
import random
import re
import time
from .common import InfoExtractor
from ..compat import compat_str
from ..utils import (
ExtractorError,
float_or_none,
int_or_none,
KNOWN_EXTENSIONS,
parse_filesize,
str_or_none,
try_get,
update... | @@ -429,3 +421,88 @@ def _real_extract(self, url):
ie=self._TYPE_IE_DICT[item[1]])
for item in items]
return self.playlist_result(entries, id)
+
+
+class BandcampUserIE(InfoExtractor):
+ IE_NAME = 'Bandcamp:user'
+ _VALID_URL = r'https?://(?:(?P<id>[^.]+)\.)?bandcamp\.com'
+... | yt_dlp/extractor/bandcamp.py | 26 | Python | 0.357 | question | 121 | 51 | 446 | false | feat: support bandcamp user urls | 2,800 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | lyz-code |
'duration': float_or_none(show.get('audio_duration')),
'is_live': False,
'release_date': unified_strdate(show.get('published_date')),
'series': 'Bandcamp Weekly',
'episode': show.get('subtitle'),
'episode_id': show_id,
'formats': format... | ```suggestion
'info_dict': {
'id': 'dotscale',
'title': 'Discography of dotscale'
},
``` | 'duration': float_or_none(show.get('audio_duration')),
'is_live': False,
'release_date': unified_strdate(show.get('published_date')),
'series': 'Bandcamp Weekly',
'episode': show.get('subtitle'),
'episode_id': show_id,
'formats': format... | @@ -391,41 +383,61 @@ def _real_extract(self, url):
}
-class BandcampMusicIE(InfoExtractor):
- _VALID_URL = r'https?://(?P<id>[^/]+)\.bandcamp\.com/music'
+class BandcampUserIE(InfoExtractor):
+ IE_NAME = 'Bandcamp:user'
+ _VALID_URL = r'https?://(?!www\.)(?P<id>[^.]+)\.bandcamp\.com(?:/music)?/?(... | yt_dlp/extractor/bandcamp.py | 26 | Python | 0.714 | suggestion | 133 | 51 | 51 | false | feat: support bandcamp user urls | 2,800 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | lyz-code |
self._login_status = self._login()
def _login(self):
username, password = self._get_login_info()
if not username:
return False
login_ok = True
login_form_strs = {
'_username': username,
'_password': password,
'_remember_me': 'o... | `self.report_warning`.
Actually this can be an error | 'uploader_id': 'wowaka',
'title': '裏表ラバーズ',
'thumbnail': r're:^https?://.*\.jpg$',
}
}]
def _real_initialize(self):
self._login_status = self._login()
def _login(self):
username, password = self._get_login_info()
if not username:
... | @@ -0,0 +1,97 @@
+# coding: utf-8
+
+from __future__ import unicode_literals
+from .common import InfoExtractor
+from ..compat import compat_urlparse
+from ..utils import int_or_none, parse_duration, parse_filesize, unified_timestamp, urlencode_postdata, ExtractorError
+
+
+class PiaproIE(InfoExtractor):
+ _NETRC_MA... | yt_dlp/extractor/piapro.py | 26 | Python | 0.5 | suggestion | 55 | 51 | 51 | false | [piapro] add support for piapro.jp | 2,801 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Lesmiscore |
if urlh is False:
login_ok = False
else:
parts = compat_urlparse.urlparse(urlh.geturl())
if parts.path != '/':
login_ok = False
if not login_ok:
self._downloader.report_warning(
'unable to log in: bad username or pas... | just use str_to_int instead of int_or_none | 'login': 'ログイン'
}
self._request_webpage('https://piapro.jp/login/', None)
urlh = self._request_webpage(
'https://piapro.jp/login/exe', None,
note='Logging in', errnote='Unable to log in',
data=urlencode_postdata(login_form_strs))
if urlh is... | @@ -0,0 +1,97 @@
+# coding: utf-8
+
+from __future__ import unicode_literals
+from .common import InfoExtractor
+from ..compat import compat_urlparse
+from ..utils import int_or_none, parse_duration, parse_filesize, unified_timestamp, urlencode_postdata, ExtractorError
+
+
+class PiaproIE(InfoExtractor):
+ _NETRC_MA... | yt_dlp/extractor/piapro.py | 26 | Python | 0.143 | suggestion | 42 | 51 | 51 | false | [piapro] add support for piapro.jp | 2,801 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Lesmiscore |
str_filesize = str_filesize.replace(',', '')
str_viewcount = str_viewcount.replace(',', '')
uploader_id, uploader = self._search_regex(
r'<a\s+class="cd_user-name"\s+href="/(.*)">([^<]+)さん<', webpage, 'uploader',
group=(1, 2), default=(None, None))
content_id = s... | ```suggestion
'filesize_approx': parse_filesize(str_filesize),
```
that is why it's called approx :D | raise ExtractorError('The URL does not contain audio.', expected=True)
str_duration, str_filesize = self._search_regex(
r'サイズ:</span>(.+?)/\(([0-9,]+?[KMG]?B))', webpage, 'duration and size',
group=(1, 2), default=(None, None))
str_viewcount = self._search_regex(r'閲覧... | @@ -0,0 +1,97 @@
+# coding: utf-8
+
+from __future__ import unicode_literals
+from .common import InfoExtractor
+from ..compat import compat_urlparse
+from ..utils import int_or_none, parse_duration, parse_filesize, unified_timestamp, urlencode_postdata, ExtractorError
+
+
+class PiaproIE(InfoExtractor):
+ _NETRC_MA... | yt_dlp/extractor/piapro.py | 26 | Python | 0.714 | suggestion | 115 | 31 | 34 | false | [piapro] add support for piapro.jp | 2,801 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Lesmiscore |
return
def check_thumbnails(thumbnails):
for t in thumbnails:
self.to_screen(f'[info] Testing thumbnail {t["id"]}')
try:
self.urlopen(HEADRequest(t['url']))
except network_exceptions as err:
self.to_... | make it private function. I also don't like the name, but 🤷 | return
def check_thumbnails(thumbnails):
for t in thumbnails:
self.to_screen(f'[info] Testing thumbnail {t["id"]}')
try:
self.urlopen(HEADRequest(t['url']))
except network_exceptions as err:
self.to_... | @@ -2309,6 +2310,55 @@ def check_thumbnails(thumbnails):
else:
info_dict['thumbnails'] = thumbnails
+ def fill_common_fields(self, info_dict, is_video=True): | yt_dlp/YoutubeDL.py | 26 | Python | 0.214 | suggestion | 60 | 51 | 51 | false | [YoutubeDL] Fill more fields for playlists | 2,824 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Lesmiscore |
if not sub_url:
continue
subtitles.setdefault(sub.get('lang', 'English'), []).append({
'url': self._proto_relative_url(sub_url),
})
infodict = {
'id': video_id,
'title': title,
'formats': formats,
... |
```py
season_number, episode_number, episode_title = self._search_regex(
r'^S(\d+):E(\d+) - (.+)', ..., groups=(1, 2, 3), default=(None, None, None))
return {
...
'episode': episode_title,
...
}
``` | if not sub_url:
continue
subtitles.setdefault(sub.get('lang', 'English'), []).append({
'url': self._proto_relative_url(sub_url),
})
season_number, episode_number, episode_title = self._search_regex(
r'^S(\d+):E(\d+) - (.+)', title,... | @@ -119,6 +119,15 @@ def _real_extract(self, url):
'release_year': int_or_none(video_data.get('year')),
}
+ episode_match = re.search(r'^S(\d+):E(\d+) - (.+)', title)
+
+ if episode_match:
+ infodict['season_number'] = int(episode_match.group(1))
+ infodict['e... | yt_dlp/extractor/tubitv.py | 26 | Python | 0.786 | suggestion | 280 | 51 | 51 | false | [tubitv] TV series extraction fix & metadata improvements | 2,829 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bbepis |
infodict['season_number'] = int(episode_match.group(1))
infodict['episode_number'] = int(episode_match.group(2))
infodict['episode_title'] = episode_match.group(3)
return infodict
class TubiTvShowIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?tubitv\.com/series/[... | unnecessary changes. Only the regex needs to be changed
```suggestion
show_json = self._parse_json(self._search_regex(
r'window\.__data\s*=\s*({[^<]+});\s*</script>',
show_webpage, 'data'), show_name, transform_source=js_to_json)['video']
``` | 'episode_title': episode_title
}
class TubiTvShowIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?tubitv\.com/series/[0-9]+/(?P<show_name>[^/?#]+)'
_TESTS = [{
'url': 'https://tubitv.com/series/3936/the-joy-of-painting-with-bob-ross?start=true',
'playlist_mincount': 390... | @@ -132,9 +141,13 @@ class TubiTvShowIE(InfoExtractor):
def _entries(self, show_url, show_name):
show_webpage = self._download_webpage(show_url, show_name)
- show_json = self._parse_json(self._search_regex(
- r"window\.__data\s*=\s*({.+?});\s*</script>",
- show_webpage, 'dat... | yt_dlp/extractor/tubitv.py | 26 | Python | 0.857 | suggestion | 279 | 35 | 30 | false | [tubitv] TV series extraction fix & metadata improvements | 2,829 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | bbepis |
'title': 'scene 05 “ことばドリル”にちょうせん!'
}, {
'start_time': 256.055,
'end_time': 345.011,
'title': 'scene 06 ことばアンケート'
}, {
'start_time': 345.011,
'end_time': 408.474,
'title': 'scene 07 ハソ... | needed?
```suggestion
'chapters': 'count:12'
``` | version = base_values.get('r_version') or program_values.get('version')
if version:
video_id = f'{video_id.split("_")[0]}_{version}'
formats = self._extract_m3u8_formats(
f'https://nhks-vh.akamaihd.net/i/das/{video_id[0:8]}/{video_id}_V_000.f4v/master.m3u8',
... | @@ -176,3 +183,203 @@ def _real_extract(self, url):
program_title = entries[0].get('series')
return self.playlist_result(entries, program_id, program_title)
+
+
+class NhkForSchoolBangumiIE(InfoExtractor):
+ _VALID_URL = r'https?://www2\.nhk\.or\.jp/school/movie/(?P<type>bangumi|clip)\.cgi\?d... | yt_dlp/extractor/nhk.py | 26 | Python | 0.571 | suggestion | 63 | 51 | 51 | false | [nhk] Add support for NHK for School | 2,850 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Lesmiscore |
'title': t,
} for s, e, t in zip(start_time, end_time, chapter_titles)]
return {
'id': video_id,
'title': program_values.get('name'),
'duration': parse_duration(base_values.get('r_duration')),
'timestamp': unified_timestamp(base_values... | ```suggestion
_VALID_URL = r'https?://www\.nhk\.or\.jp/school/(?P<id>%s)' % '|'.join(re.escape(s) for s in KNOWN_SUBJECTS)
```
etc | self._html_search_regex(r'(?s)<span\s+class="subjectName">\s*<img\s*[^<]+>\s*([^<]+?)</span>', webpage, 'title', fatal=False),
lambda g: urljoin(url, g.group(1)))
class NhkForSchoolProgramListIE(InfoExtractor):
_VALID_URL = r'https?://www\.nhk\.or\.jp/school/(?P<id>(?:%s)/[a-zA-Z0-9_-]+)' ... | @@ -176,3 +183,203 @@ def _real_extract(self, url):
program_title = entries[0].get('series')
return self.playlist_result(entries, program_id, program_title)
+
+
+class NhkForSchoolBangumiIE(InfoExtractor):
+ _VALID_URL = r'https?://www2\.nhk\.or\.jp/school/movie/(?P<type>bangumi|clip)\.cgi\?d... | yt_dlp/extractor/nhk.py | 26 | Python | 0.714 | security | 137 | 51 | 37 | false | [nhk] Add support for NHK for School | 2,850 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Lesmiscore |
'formats': formats,
'chapters': chapters,
}
class NhkForSchoolSubjectIE(InfoExtractor):
IE_DESC = 'Portal page for each school subjects, like Japanese (kokugo, 国語) or math (sansuu/suugaku or 算数・数学)'
KNOWN_SUBJECTS = (
'rika', 'syakai', 'kokugo',
'sansuu', 'seika... | ```suggestion
'playlist_mincount': 16,
```
etc | _TESTS = [{
'url': 'https://www.nhk.or.jp/school/sougou/q/',
'info_dict': {
'id': 'sougou/q',
'title': 'Q~こどものための哲学',
},
'playlist_mincount': 20,
}]
def _real_extract(self, url):
program_id = self._match_id(url)
webpage = self._downlo... | @@ -176,3 +183,203 @@ def _real_extract(self, url):
program_title = entries[0].get('series')
return self.playlist_result(entries, program_id, program_title)
+
+
+class NhkForSchoolBangumiIE(InfoExtractor):
+ _VALID_URL = r'https?://www2\.nhk\.or\.jp/school/movie/(?P<type>bangumi|clip)\.cgi\?d... | yt_dlp/extractor/nhk.py | 26 | Python | 0.571 | suggestion | 57 | 51 | 29 | false | [nhk] Add support for NHK for School | 2,850 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Lesmiscore |
'eigo', 'tokkatsu',
'tokushi', 'sonota',
)
_VALID_URL = r'https?://www\.nhk\.or\.jp/school/(?P<id>%s)' % (
'|'.join(re.escape(s) for s in KNOWN_SUBJECTS)
)
_TESTS = [{
'url': 'https://www.nhk.or.jp/school/sougou/',
'info_dict': {
'id': 'sougou',
... | isnt it easier to just do this with regex?
```py
r'https?://www\.nhk\.or\.jp/school/(?P<id>%s)(?:$|[#?])'
``` | from __future__ import unicode_literals
import re
from .common import InfoExtractor
from ..utils import (
parse_duration,
traverse_obj,
unescapeHTML,
unified_timestamp,
urljoin
)
class NhkBaseIE(InfoExtractor):
_API_URL_TEMPLATE = 'https://api.nhk.or.jp/nhkworld/%sod%slist/v7a/%s/%s/%s/all%s... | @@ -176,3 +183,203 @@ def _real_extract(self, url):
program_title = entries[0].get('series')
return self.playlist_result(entries, program_id, program_title)
+
+
+class NhkForSchoolBangumiIE(InfoExtractor):
+ _VALID_URL = r'https?://www2\.nhk\.or\.jp/school/movie/(?P<type>bangumi|clip)\.cgi\?d... | yt_dlp/extractor/nhk.py | 26 | Python | 0.714 | suggestion | 112 | 51 | 326 | false | [nhk] Add support for NHK for School | 2,850 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Lesmiscore |
'playlist_mincount': 16, # as of 2021/06/20
}, {
'url': 'https://www.nhk.or.jp/school/rika/',
'info_dict': {
'id': 'rika',
'title': '理科',
},
'playlist_mincount': 15, # as of 2021/06/25
}]
@classmethod
def suitable(cls, url):
retu... | wouldnt `playlist_from_matches` be simpler? | from __future__ import unicode_literals
import re
from .common import InfoExtractor
from ..utils import (
parse_duration,
traverse_obj,
unescapeHTML,
unified_timestamp,
urljoin
)
class NhkBaseIE(InfoExtractor):
_API_URL_TEMPLATE = 'https://api.nhk.or.jp/nhkworld/%sod%slist/v7a/%s/%s/%s/all%s... | @@ -176,3 +183,203 @@ def _real_extract(self, url):
program_title = entries[0].get('series')
return self.playlist_result(entries, program_id, program_title)
+
+
+class NhkForSchoolBangumiIE(InfoExtractor):
+ _VALID_URL = r'https?://www2\.nhk\.or\.jp/school/movie/(?P<type>bangumi|clip)\.cgi\?d... | yt_dlp/extractor/nhk.py | 26 | Python | 0.214 | question | 43 | 51 | 326 | false | [nhk] Add support for NHK for School | 2,850 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Lesmiscore |
self._html_search_regex(r'(?s)<span\s+class="subjectName">\s*<img\s*[^<]+>\s*([^<]+?)</span>', webpage, 'title', fatal=False))
class NhkForSchoolProgramListIE(InfoExtractor):
_VALID_URL = r'https?://www\.nhk\.or\.jp/school/(?P<id>(?:%s)/[a-zA-Z0-9_-]+)' % (
'|'.join(re.escape(s) for s in NhkFo... | ```suggestion
title = self._og_search_title(webpage, fatal=False) or self._html_extract_title(webpage, fatal=False) or self._html_search_regex(r'<h3>([^<]+?)とは?\s*</h3>', webpage, 'title', fatal=False)
title = re.sub(r'\s*\|\s*NHK\s+for\s+School\s*$', '', title) if title else None
```
(fix formattin... | from __future__ import unicode_literals
import re
from .common import InfoExtractor
from ..utils import (
parse_duration,
traverse_obj,
unescapeHTML,
unified_timestamp,
urljoin
)
class NhkBaseIE(InfoExtractor):
_API_URL_TEMPLATE = 'https://api.nhk.or.jp/nhkworld/%sod%slist/v7a/%s/%s/%s/all%s... | @@ -176,3 +183,203 @@ def _real_extract(self, url):
program_title = entries[0].get('series')
return self.playlist_result(entries, program_id, program_title)
+
+
+class NhkForSchoolBangumiIE(InfoExtractor):
+ _VALID_URL = r'https?://www2\.nhk\.or\.jp/school/movie/(?P<type>bangumi|clip)\.cgi\?d... | yt_dlp/extractor/nhk.py | 26 | Python | 0.857 | refactor | 322 | 39 | 326 | false | [nhk] Add support for NHK for School | 2,850 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | Lesmiscore |
'like_count': int,
'repost_count': int,
'age_limit': 0,
'tags': 'count:19',
},
'params': {
'format': 'hd',
},
}, {
'note': 'non-iframe video (with related posts)',
'url': 'https://shieldfoss.tumblr.com/post/675519763... | i didn't know `note` can be used for this...
I always thought we have to stick to comments... | 'like_count': int,
'repost_count': int,
'age_limit': 0,
'tags': 'count:19',
},
'params': {
'format': 'hd',
},
}, {
'note': 'non-iframe video (with related posts)',
'url': 'https://shieldfoss.tumblr.com/post/675519763... | @@ -14,31 +15,129 @@ class TumblrIE(InfoExtractor):
_VALID_URL = r'https?://(?P<blog_name>[^/?#&]+)\.tumblr\.com/(?:post|video)/(?P<id>[0-9]+)(?:$|[/?#])'
_NETRC_MACHINE = 'tumblr'
_LOGIN_URL = 'https://www.tumblr.com/login'
+ _OAUTH_URL = 'https://www.tumblr.com/api/v2/oauth2/token'
_TESTS = [{
... | yt_dlp/extractor/tumblr.py | 26 | Python | 0.429 | suggestion | 94 | 51 | 51 | false | [tumblr] Fix extraction; fix login; get additional metadata | 2,883 | yt-dlp/yt-dlp | 132,642 | Python | Ashish0804 | foghawk |
'vimeo': 'Vimeo',
'vine': 'Vine',
'youtube': 'Youtube',
}
def _real_initialize(self):
self._ACCESS_TOKEN = None
self.get_access_token()
self._login()
def get_access_token(self):
try:
login_page = self._download_webpage(
se... | Why keep the access token sep from login??
Shouldn't the access token extraction be part of this login function aswell? | 'instagram': 'Instagram',
'vimeo': 'Vimeo',
'vine': 'Vine',
'youtube': 'Youtube',
}
_ACCESS_TOKEN = None
def _real_initialize(self):
self.get_access_token()
self._login()
def get_access_token(self):
login_page = self._download_webpage(
... | @@ -107,116 +237,176 @@ class TumblrIE(InfoExtractor):
'add_ie': ['Instagram'],
}]
+ _providers = {
+ 'instagram': 'Instagram',
+ 'vimeo': 'Vimeo',
+ 'vine': 'Vine',
+ 'youtube': 'Youtube',
+ }
+
def _real_initialize(self):
+ self._ACCESS_TOKEN = None
+ ... | yt_dlp/extractor/tumblr.py | 26 | Python | 0.429 | refactor | 120 | 51 | 51 | false | [tumblr] Fix extraction; fix login; get additional metadata | 2,883 | yt-dlp/yt-dlp | 132,642 | Python | Ashish0804 | foghawk |
username, password = self._get_login_info()
if not username:
return
if not self._ACCESS_TOKEN:
self.report_warning('Cannot log in without access token')
return
try:
self._download_json(
self._OAUTH_URL, None, 'Logging in',... | compress this into 1 line.
No need to assign match object to var and then call group individually.
Just call groups on the match object |
def _login(self):
username, password = self._get_login_info()
if not username:
return
if not self._ACCESS_TOKEN:
return
self._download_json(
self._OAUTH_URL, None, 'Logging in',
data=urlencode_postdata({
'password': p... | @@ -107,116 +237,176 @@ class TumblrIE(InfoExtractor):
'add_ie': ['Instagram'],
}]
+ _providers = {
+ 'instagram': 'Instagram',
+ 'vimeo': 'Vimeo',
+ 'vine': 'Vine',
+ 'youtube': 'Youtube',
+ }
+
def _real_initialize(self):
+ self._ACCESS_TOKEN = None
+ ... | yt_dlp/extractor/tumblr.py | 26 | Python | 0.357 | suggestion | 137 | 51 | 51 | false | [tumblr] Fix extraction; fix login; get additional metadata | 2,883 | yt-dlp/yt-dlp | 132,642 | Python | Ashish0804 | foghawk |
def _real_extract(self, url):
m_url = self._match_valid_url(url)
video_id = m_url.group('id')
blog = m_url.group('blog_name')
url = f'http://{blog}.tumblr.com/post/{video_id}/'
webpage, urlh = self._download_webpage_handle(url, video_id)
redirect_url = urlh.geturl()... | sus formatting bro.
Weird that flake8 didn't find it problematic.
But anyways, this is confusing to read. | blog, video_id = self._match_valid_url(url).groups()
url = f'http://{blog}.tumblr.com/post/{video_id}/'
webpage, urlh = self._download_webpage_handle(url, video_id)
redirect_url = urlh.geturl()
api_only = bool(self._search_regex(
r'(tumblr.com|^)/(safe-mode|login_r... | @@ -107,116 +237,176 @@ class TumblrIE(InfoExtractor):
'add_ie': ['Instagram'],
}]
+ _providers = {
+ 'instagram': 'Instagram',
+ 'vimeo': 'Vimeo',
+ 'vine': 'Vine',
+ 'youtube': 'Youtube',
+ }
+
def _real_initialize(self):
+ self._ACCESS_TOKEN = None
+ ... | yt_dlp/extractor/tumblr.py | 26 | Python | 0.357 | style | 107 | 51 | 51 | false | [tumblr] Fix extraction; fix login; get additional metadata | 2,883 | yt-dlp/yt-dlp | 132,642 | Python | Ashish0804 | foghawk |
webpage, urlh = self._download_webpage_handle(url, video_id)
redirect_url = urlh.geturl()
api_only = bool(self._search_regex(
r'(tumblr.com|^)/(safe-mode|login_required|blog/view)',
redirect_url, 'redirect', default=None))
if api_only and not self._ACCESS_TOKEN... | when using .get for iterables, Don't pass the blank iter object as default.
rather do this
`var = your_dict.get('key') or <iter blank object>`
for example here it should be `media_json = video_json.get('media') or {}`
Fix this at other places too |
api_only = bool(self._search_regex(
r'(tumblr.com|^)/(safe-mode|login_required|blog/view)',
redirect_url, 'redirect', default=None))
if api_only and not self._ACCESS_TOKEN:
raise ExtractorError('Cannot get data for dashboard-only post without access token')
... | @@ -107,116 +237,176 @@ class TumblrIE(InfoExtractor):
'add_ie': ['Instagram'],
}]
+ _providers = {
+ 'instagram': 'Instagram',
+ 'vimeo': 'Vimeo',
+ 'vine': 'Vine',
+ 'youtube': 'Youtube',
+ }
+
def _real_initialize(self):
+ self._ACCESS_TOKEN = None
+ ... | yt_dlp/extractor/tumblr.py | 26 | Python | 0.643 | suggestion | 253 | 51 | 51 | false | [tumblr] Fix extraction; fix login; get additional metadata | 2,883 | yt-dlp/yt-dlp | 132,642 | Python | Ashish0804 | foghawk |
self._download_json(
f'https://www.tumblr.com/api/v2/blog/{blog}/posts/{video_id}/permalink',
video_id,
headers={
'Authorization': f'Bearer {self._ACCESS_TOKEN}',
},
fatal=False) if self._ACCESS_TOKEN else No... | ```suggestion
formats = []
``` | f'https://www.tumblr.com/api/v2/blog/{blog}/posts/{video_id}/permalink',
video_id, headers={'Authorization': f'Bearer {self._ACCESS_TOKEN}'}, fatal=False),
('response', 'timeline', 'elements', 0)) or {}
content_json = traverse_obj(post_json, ('trail', 0, '... | @@ -107,116 +237,176 @@ class TumblrIE(InfoExtractor):
'add_ie': ['Instagram'],
}]
+ _providers = {
+ 'instagram': 'Instagram',
+ 'vimeo': 'Vimeo',
+ 'vine': 'Vine',
+ 'youtube': 'Youtube',
+ }
+
def _real_initialize(self):
+ self._ACCESS_TOKEN = None
+ ... | yt_dlp/extractor/tumblr.py | 26 | Python | 0.429 | suggestion | 40 | 51 | 51 | false | [tumblr] Fix extraction; fix login; get additional metadata | 2,883 | yt-dlp/yt-dlp | 132,642 | Python | Ashish0804 | foghawk |
'url': media_json.get('url') or video_url,
'format_id': '0',
'width': media_json.get('width') or int_or_none(
self._og_search_property('video:width', webpage, default=None)),
'height': media_json.get('height') or int_or_none(
self._og_searc... | bruh 😑
Clean it or move extraction out of return statement | # the url we're extracting from might be an original post or it might be a reblog.
# if it's a reblog, og:description will be the reblogger's comment, not the uploader's.
# content_json is always the op, so if it exists but has no text, there's no description
if content_json:
... | @@ -107,116 +237,176 @@ class TumblrIE(InfoExtractor):
'add_ie': ['Instagram'],
}]
+ _providers = {
+ 'instagram': 'Instagram',
+ 'vimeo': 'Vimeo',
+ 'vine': 'Vine',
+ 'youtube': 'Youtube',
+ }
+
def _real_initialize(self):
+ self._ACCESS_TOKEN = None
+ ... | yt_dlp/extractor/tumblr.py | 26 | Python | 0.286 | refactor | 60 | 39 | 27 | false | [tumblr] Fix extraction; fix login; get additional metadata | 2,883 | yt-dlp/yt-dlp | 132,642 | Python | Ashish0804 | foghawk |
return {
'id': video_id,
'title': (post_json.get('summary')
or (blog if api_only else self._html_search_regex(
r'(?s)<title>(?P<title>.*?)(?: \| Tumblr)?</title>',
webpage, 'title'))),
# the url we're ... | ```suggestion
'age_limit': 18 if post_json.get('is_nsfw') else 0,
```
Isn't this enough? (I'm not sure how dlp consumes age_limit tho) | # coding: utf-8
from __future__ import unicode_literals
from .common import InfoExtractor
from ..utils import (
ExtractorError,
int_or_none,
traverse_obj,
urlencode_postdata
)
class TumblrIE(InfoExtractor):
_VALID_URL = r'https?://(?P<blog_name>[^/?#&]+)\.tumblr\.com/(?:post|video)/(?P<id>[0-9]+... | @@ -107,116 +237,176 @@ class TumblrIE(InfoExtractor):
'add_ie': ['Instagram'],
}]
+ _providers = {
+ 'instagram': 'Instagram',
+ 'vimeo': 'Vimeo',
+ 'vine': 'Vine',
+ 'youtube': 'Youtube',
+ }
+
def _real_initialize(self):
+ self._ACCESS_TOKEN = None
+ ... | yt_dlp/extractor/tumblr.py | 26 | Python | 0.714 | suggestion | 149 | 30 | 401 | false | [tumblr] Fix extraction; fix login; get additional metadata | 2,883 | yt-dlp/yt-dlp | 132,642 | Python | Ashish0804 | foghawk |
},
'add_ie': ['Youtube'],
}, {
'url': 'https://dominustempori.tumblr.com/post/673572712813297664/youtubes-all-right-for-some-pretty-cool',
'md5': '203e9eb8077e3f45bfaeb4c86c1467b8',
'info_dict': {
'id': '87816359',
'ext': 'mov',
'title': 'H... | Am i missing something u forgot to sort formats before returning? | 'availability': 'public',
},
'add_ie': ['Youtube'],
}, {
'url': 'https://dominustempori.tumblr.com/post/673572712813297664/youtubes-all-right-for-some-pretty-cool',
'md5': '203e9eb8077e3f45bfaeb4c86c1467b8',
'info_dict': {
'id': '87816359',
... | @@ -107,116 +237,176 @@ class TumblrIE(InfoExtractor):
'add_ie': ['Instagram'],
}]
+ _providers = {
+ 'instagram': 'Instagram',
+ 'vimeo': 'Vimeo',
+ 'vine': 'Vine',
+ 'youtube': 'Youtube',
+ }
+
def _real_initialize(self):
+ self._ACCESS_TOKEN = None
+ ... | yt_dlp/extractor/tumblr.py | 26 | Python | 0.214 | question | 65 | 51 | 51 | false | [tumblr] Fix extraction; fix login; get additional metadata | 2,883 | yt-dlp/yt-dlp | 132,642 | Python | Ashish0804 | foghawk |
'vimeo': 'Vimeo',
'vine': 'Vine',
'youtube': 'Youtube',
}
def _real_initialize(self):
self._ACCESS_TOKEN = None
self.get_access_token()
self._login()
def get_access_token(self):
try:
login_page = self._download_webpage(
se... | unnecessary since the "failed to get access token" warning would have already been issued in this case | 'instagram': 'Instagram',
'vimeo': 'Vimeo',
'vine': 'Vine',
'youtube': 'Youtube',
}
_ACCESS_TOKEN = None
def _real_initialize(self):
self.get_access_token()
self._login()
def get_access_token(self):
login_page = self._download_webpage(
... | @@ -107,116 +237,173 @@ class TumblrIE(InfoExtractor):
'add_ie': ['Instagram'],
}]
+ _providers = {
+ 'instagram': 'Instagram',
+ 'vimeo': 'Vimeo',
+ 'vine': 'Vine',
+ 'youtube': 'Youtube',
+ }
+
def _real_initialize(self):
+ self._ACCESS_TOKEN = None
+ ... | yt_dlp/extractor/tumblr.py | 26 | Python | 0.357 | bug | 102 | 51 | 51 | false | [tumblr] Fix extraction; fix login; get additional metadata | 2,883 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | foghawk |
'comment_count': int,
'upload_date': '20140429',
},
'add_ie': ['Instagram'],
}]
_providers = {
'instagram': 'Instagram',
'vimeo': 'Vimeo',
'vine': 'Vine',
'youtube': 'Youtube',
}
def _real_initialize(self):
self._ACCESS_TO... | use `errnote` and `fatal=False` rather than try-catch | 'channel': 'silbulterman',
'comment_count': int,
'upload_date': '20140429',
},
'add_ie': ['Instagram'],
}]
_providers = {
'instagram': 'Instagram',
'vimeo': 'Vimeo',
'vine': 'Vine',
'youtube': 'Youtube',
}
_ACCESS_TOKE... | @@ -107,116 +237,173 @@ class TumblrIE(InfoExtractor):
'add_ie': ['Instagram'],
}]
+ _providers = {
+ 'instagram': 'Instagram',
+ 'vimeo': 'Vimeo',
+ 'vine': 'Vine',
+ 'youtube': 'Youtube',
+ }
+
def _real_initialize(self):
+ self._ACCESS_TOKEN = None
+ ... | yt_dlp/extractor/tumblr.py | 26 | Python | 0.429 | suggestion | 53 | 51 | 51 | false | [tumblr] Fix extraction; fix login; get additional metadata | 2,883 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | foghawk |
'info_dict': {
'id': 'nYtvtTPuTl',
'ext': 'mp4',
'title': 'Video by silbulterman',
'description': '#maschine',
'uploader_id': '242859024',
'thumbnail': r're:^https?://.*\.jpg',
'timestamp': 1398801174,
'like_count': ... | ```suggestion
}
_ACCESS_TOKEN = None
def _real_initialize(self):
``` | 'md5': '3c92d7c3d867f14ccbeefa2119022277',
'info_dict': {
'id': 'nYtvtTPuTl',
'ext': 'mp4',
'title': 'Video by silbulterman',
'description': '#maschine',
'uploader_id': '242859024',
'thumbnail': r're:^https?://.*\.jpg',
... | @@ -107,116 +237,170 @@ class TumblrIE(InfoExtractor):
'add_ie': ['Instagram'],
}]
+ _providers = {
+ 'instagram': 'Instagram',
+ 'vimeo': 'Vimeo',
+ 'vine': 'Vine',
+ 'youtube': 'Youtube',
+ }
+
def _real_initialize(self):
+ self._ACCESS_TOKEN = None | yt_dlp/extractor/tumblr.py | 26 | Python | 0.571 | suggestion | 86 | 51 | 51 | false | [tumblr] Fix extraction; fix login; get additional metadata | 2,883 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | foghawk |
return self.url_result(iframe_url or redirect_url, 'Generic')
formats = formats or [{
'url': media_json.get('url', video_url),
'format_id': '0',
'width': media_json.get('width', int_or_none(
self._og_search_property('video:width', webpage, default... |
```suggestion
'title': post_json.get('summary') or (blog if api_only else self._html_search_regex(
r'(?s)<title>(?P<title>.*?)(?: \| Tumblr)?</title>', webpage, 'title'))),
``` | 'width': int_or_none(
media_json.get('width') or self._og_search_property('video:width', webpage, default=None)),
'height': int_or_none(
media_json.get('height') or self._og_search_property('video:height', webpage, default=None)),
}]
self._sort_for... | @@ -107,116 +237,170 @@ class TumblrIE(InfoExtractor):
'add_ie': ['Instagram'],
}]
+ _providers = {
+ 'instagram': 'Instagram',
+ 'vimeo': 'Vimeo',
+ 'vine': 'Vine',
+ 'youtube': 'Youtube',
+ }
+
def _real_initialize(self):
+ self._ACCESS_TOKEN = None
+ ... | yt_dlp/extractor/tumblr.py | 26 | Python | 0.786 | suggestion | 209 | 40 | 34 | false | [tumblr] Fix extraction; fix login; get additional metadata | 2,883 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | foghawk |
} for quality, (video_url, format_id) in enumerate(sources)]
if 'url' not in media_json and not video_url and not iframe_url:
# external video host (but we weren't able to figure it out from the api)
iframe_url = self._search_regex(
r'src=["\'](https?... | why do u put brackets everywhere!!?
```suggestion
uploader_id = traverse_obj(post_json, 'reblogged_root_name', 'blog_name')
``` | iframe_url = self._search_regex(
r'src=["\'](https?://safe\.txmblr\.com/svc/embed/inline/[^"\']+)["\']',
webpage, 'embed iframe url', default=None)
return self.url_result(iframe_url or redirect_url, 'Generic')
formats = formats or [{
'url': me... | @@ -107,116 +237,170 @@ class TumblrIE(InfoExtractor):
'add_ie': ['Instagram'],
}]
+ _providers = {
+ 'instagram': 'Instagram',
+ 'vimeo': 'Vimeo',
+ 'vine': 'Vine',
+ 'youtube': 'Youtube',
+ }
+
def _real_initialize(self):
+ self._ACCESS_TOKEN = None
+ ... | yt_dlp/extractor/tumblr.py | 26 | Python | 0.714 | question | 138 | 47 | 41 | false | [tumblr] Fix extraction; fix login; get additional metadata | 2,883 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | foghawk |
if sd_url:
sources.append((sd_url, 'sd'))
sources.append((hd_url, 'hd'))
formats = [{
'url': video_url,
'format_id': format_id,
'height': int_or_none(self._search_... | ```suggestion
'width': int_or_none(media_json.get('width') or self._og_search_property('video:width', webpage, default=None)),
'height': int_or_none(media_json.get('height') or self._og_search_property('height', webpage, default=None)),
``` | formats = [{
'url': video_url,
'format_id': format_id,
'height': int_or_none(self._search_regex(
r'_(\d+)\.\w+$', video_url, 'height', default=None)),
'quality': quality,
... | @@ -107,116 +237,170 @@ class TumblrIE(InfoExtractor):
'add_ie': ['Instagram'],
}]
+ _providers = {
+ 'instagram': 'Instagram',
+ 'vimeo': 'Vimeo',
+ 'vine': 'Vine',
+ 'youtube': 'Youtube',
+ }
+
def _real_initialize(self):
+ self._ACCESS_TOKEN = None
+ ... | yt_dlp/extractor/tumblr.py | 26 | Python | 0.786 | suggestion | 267 | 51 | 51 | false | [tumblr] Fix extraction; fix login; get additional metadata | 2,883 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | foghawk |
# (and ignore other sources of width/height data as they may be wrong)
sources = []
sd_url = self._search_regex(
r'<source[^>]+src=(["\'])(?P<url>.+?)\1', iframe,
'sd video url', default=None, group='url')
... | ```suggestion
'url': media_json.get('url') or video_url,
```
`media_json['url']` can be `None` | 'sd video url', default=None, group='url')
if sd_url:
sources.append((sd_url, 'sd'))
sources.append((hd_url, 'hd'))
formats = [{
'url': video_url,
'format_id': for... | @@ -107,116 +237,170 @@ class TumblrIE(InfoExtractor):
'add_ie': ['Instagram'],
}]
+ _providers = {
+ 'instagram': 'Instagram',
+ 'vimeo': 'Vimeo',
+ 'vine': 'Vine',
+ 'youtube': 'Youtube',
+ }
+
def _real_initialize(self):
+ self._ACCESS_TOKEN = None
+ ... | yt_dlp/extractor/tumblr.py | 26 | Python | 0.714 | suggestion | 109 | 51 | 51 | false | [tumblr] Fix extraction; fix login; get additional metadata | 2,883 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | foghawk |
'hd video url', default='', group='options'),
video_id, fatal=False)
if options:
duration = int_or_none(options.get('duration'))
hd_url = options.get('hdUrl')
if hd_url:
# there are multiple formats; ext... | ```suggestion
if not media_json.get('url') and not video_url and not iframe_url:
``` |
hd_url = options.get('hdUrl')
if hd_url:
# there are multiple formats; extract them
# ignore other sources of width/height data as they may be wrong
sources = []
sd_url = self._search_regex(
... | @@ -107,116 +237,170 @@ class TumblrIE(InfoExtractor):
'add_ie': ['Instagram'],
}]
+ _providers = {
+ 'instagram': 'Instagram',
+ 'vimeo': 'Vimeo',
+ 'vine': 'Vine',
+ 'youtube': 'Youtube',
+ }
+
def _real_initialize(self):
+ self._ACCESS_TOKEN = None
+ ... | yt_dlp/extractor/tumblr.py | 26 | Python | 0.571 | suggestion | 94 | 51 | 51 | false | [tumblr] Fix extraction; fix login; get additional metadata | 2,883 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | foghawk |
video_url = self._og_search_video_url(webpage, default=None)
duration = None
formats = []
# iframes can supply duration and sometimes additional formats, so check for one
iframe_url = self._search_regex(
fr'src=\'(https?://www\.tumblr\.com/video/{blog}/{video_id}/[^... | ```suggestion
# ignore other sources of width/height data as they may be wrong
``` |
# iframes can supply duration and sometimes additional formats, so check for one
iframe_url = self._search_regex(
fr'src=\'(https?://www\.tumblr\.com/video/{blog}/{video_id}/[^\']+)\'',
webpage, 'iframe url', default=None)
if iframe_url:
iframe = self._downlo... | @@ -107,116 +237,170 @@ class TumblrIE(InfoExtractor):
'add_ie': ['Instagram'],
}]
+ _providers = {
+ 'instagram': 'Instagram',
+ 'vimeo': 'Vimeo',
+ 'vine': 'Vine',
+ 'youtube': 'Youtube',
+ }
+
def _real_initialize(self):
+ self._ACCESS_TOKEN = None
+ ... | yt_dlp/extractor/tumblr.py | 26 | Python | 0.714 | bug | 104 | 51 | 51 | false | [tumblr] Fix extraction; fix login; get additional metadata | 2,883 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | foghawk |
def _real_extract(self, url):
blog, video_id = self._match_valid_url(url).groups()
url = f'http://{blog}.tumblr.com/post/{video_id}/'
webpage, urlh = self._download_webpage_handle(url, video_id)
redirect_url = urlh.geturl()
api_only = bool(self._search_regex(
r... | ```suggestion
post_json = traverse_obj(
self._download_json(
f'https://www.tumblr.com/api/v2/blog/{blog}/posts/{video_id}/permalink',
video_id, headers={'Authorization': f'Bearer {self._ACCESS_TOKEN}'}, fatal=False),
('response', '... | errnote='Login failed', fatal=False)
def _real_extract(self, url):
blog, video_id = self._match_valid_url(url).groups()
url = f'http://{blog}.tumblr.com/post/{video_id}/'
webpage, urlh = self._download_webpage_handle(url, video_id)
redirect_url = urlh.geturl()
... | @@ -107,116 +237,170 @@ class TumblrIE(InfoExtractor):
'add_ie': ['Instagram'],
}]
+ _providers = {
+ 'instagram': 'Instagram',
+ 'vimeo': 'Vimeo',
+ 'vine': 'Vine',
+ 'youtube': 'Youtube',
+ }
+
def _real_initialize(self):
+ self._ACCESS_TOKEN = None
+ ... | yt_dlp/extractor/tumblr.py | 26 | Python | 0.786 | security | 357 | 51 | 51 | false | [tumblr] Fix extraction; fix login; get additional metadata | 2,883 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | foghawk |
redirect_url = urlh.geturl()
api_only = bool(self._search_regex(
r'(tumblr.com|^)/(safe-mode|login_required|blog/view)',
redirect_url, 'redirect', default=None))
if api_only and not self._ACCESS_TOKEN:
raise ExtractorError('Cannot get data for dashboard-onl... | ```suggestion
video_json = next(
(item for item in content_json if item.get('type') == 'video'), {})
``` | url = f'http://{blog}.tumblr.com/post/{video_id}/'
webpage, urlh = self._download_webpage_handle(url, video_id)
redirect_url = urlh.geturl()
api_only = bool(self._search_regex(
r'(tumblr.com|^)/(safe-mode|login_required|blog/view)',
redirect_url, 'redirect', def... | @@ -107,116 +237,170 @@ class TumblrIE(InfoExtractor):
'add_ie': ['Instagram'],
}]
+ _providers = {
+ 'instagram': 'Instagram',
+ 'vimeo': 'Vimeo',
+ 'vine': 'Vine',
+ 'youtube': 'Youtube',
+ }
+
def _real_initialize(self):
+ self._ACCESS_TOKEN = None
+ ... | yt_dlp/extractor/tumblr.py | 26 | Python | 0.857 | suggestion | 127 | 51 | 51 | false | [tumblr] Fix extraction; fix login; get additional metadata | 2,883 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | foghawk |
url = f'http://{blog}.tumblr.com/post/{video_id}/'
webpage, urlh = self._download_webpage_handle(url, video_id)
redirect_url = urlh.geturl()
api_only = bool(self._search_regex(
r'(tumblr.com|^)/(safe-mode|login_required|blog/view)',
redirect_url, 'redirect', de... | ```suggestion
content_json = traverse_obj(post_json, ('trail', 0, 'content'), 'content') or []
``` | def _real_extract(self, url):
blog, video_id = self._match_valid_url(url).groups()
url = f'http://{blog}.tumblr.com/post/{video_id}/'
webpage, urlh = self._download_webpage_handle(url, video_id)
redirect_url = urlh.geturl()
api_only = bool(self._search_regex(
r... | @@ -107,116 +237,170 @@ class TumblrIE(InfoExtractor):
'add_ie': ['Instagram'],
}]
+ _providers = {
+ 'instagram': 'Instagram',
+ 'vimeo': 'Vimeo',
+ 'vine': 'Vine',
+ 'youtube': 'Youtube',
+ }
+
def _real_initialize(self):
+ self._ACCESS_TOKEN = None
+ ... | yt_dlp/extractor/tumblr.py | 26 | Python | 0.714 | suggestion | 108 | 51 | 51 | false | [tumblr] Fix extraction; fix login; get additional metadata | 2,883 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | foghawk |
'height': int_or_none(self._search_regex(
r'_(\d+)\.\w+$', video_url, 'height', default=None)),
'quality': quality,
} for quality, (video_url, format_id) in enumerate(sources)]
if not media_json.get('url') and not v... | ```suggestion
description = '\n\n'.join((
item.get('text') for item in content_json if item.get('type') == 'text')) or None
``` | 'height': int_or_none(self._search_regex(
r'_(\d+)\.\w+$', video_url, 'height', default=None)),
'quality': quality,
} for quality, (video_url, format_id) in enumerate(sources)]
if not media_json.get('url') and not v... | @@ -107,116 +238,162 @@ class TumblrIE(InfoExtractor):
'add_ie': ['Instagram'],
}]
+ _providers = {
+ 'instagram': 'Instagram',
+ 'vimeo': 'Vimeo',
+ 'vine': 'Vine',
+ 'youtube': 'Youtube',
+ }
+
+ _ACCESS_TOKEN = None
+
def _real_initialize(self):
+ self... | yt_dlp/extractor/tumblr.py | 26 | Python | 0.857 | suggestion | 158 | 47 | 48 | false | [tumblr] Fix extraction; fix login; get additional metadata | 2,883 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | foghawk |
sd_url = self._search_regex(
r'<source[^>]+src=(["\'])(?P<url>.+?)\1', iframe,
'sd video url', default=None, group='url')
if sd_url:
sources.append((sd_url, 'sd'))
sources.append((hd_url, ... | ```suggestion
'width': int_or_none(
media_json.get('width') or self._og_search_property('video:width', webpage, default=None)),
'height': int_or_none(
media_json.get('height') or self._og_search_property('video:height', webpage, default=None)),
``` | sd_url = self._search_regex(
r'<source[^>]+src=(["\'])(?P<url>.+?)\1', iframe,
'sd video url', default=None, group='url')
if sd_url:
sources.append((sd_url, 'sd'))
sources.append((hd_url, ... | @@ -107,116 +238,161 @@ class TumblrIE(InfoExtractor):
'add_ie': ['Instagram'],
}]
+ _providers = {
+ 'instagram': 'Instagram',
+ 'vimeo': 'Vimeo',
+ 'vine': 'Vine',
+ 'youtube': 'Youtube',
+ }
+
+ _ACCESS_TOKEN = None
+
def _real_initialize(self):
+ self... | yt_dlp/extractor/tumblr.py | 26 | Python | 0.786 | suggestion | 309 | 51 | 51 | false | [tumblr] Fix extraction; fix login; get additional metadata | 2,883 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | foghawk |
self.raise_geo_restricted(countries=self._GEO_COUNTRIES, metadata_available=True)
self.raise_no_formats(msg, expected=True)
self._sort_formats(formats)
subtitles = None
lyric = item.get('lyric')
if lyric:
subtitles = {
'origin': [{... | `_proto_relative_url` appends `http:`, so it should be left unchanged | continue
if k == 'hls':
formats.extend(self._extract_m3u8_formats(
video_url, item_id, 'mp4',
'm3u8_native', m3u8_id=k, fatal=False))
elif k == 'mp4':
f... | @@ -35,13 +63,14 @@ def _extract_item(self, item, fatal):
r'^(\d+)p', res, 'resolution', default=None)),
})
else:
- formats.append({
- 'ext': 'mp3',
- 'format_id': k,
- 'tbr': i... | yt_dlp/extractor/zingmp3.py | 26 | Python | 0.429 | suggestion | 69 | 51 | 51 | false | Feat: update new version for zingmp3 | 2,889 | yt-dlp/yt-dlp | 132,642 | Python | Lesmiscore | hatienl0i2612 |
'info_dict': {
'id': 'ZWZB9WAB',
'title': 'Xa Mãi Xa',
'ext': 'mp3',
'thumbnail': r're:^https?://.+\.jpg',
'subtitles': {
'origin': [{
'ext': 'lrc',
}]
},
'duration': 255,
... | You can/must do
```suggestion
song_id, type_url = self._match_valid_url(url).group('id', 'type')
```
Don't assign non-constant values to `self`! | return {
'id': item_id,
'title': title,
'formats': formats,
'thumbnail': traverse_obj(item, 'thumbnail', 'thumbnailM'),
'subtitles': subtitles,
'duration': int_or_none(item.get('duration')),
'track': title,
'artist':... | @@ -51,45 +80,101 @@ def _extract_item(self, item, fatal):
self.raise_no_formats(msg, expected=True)
self._sort_formats(formats)
- subtitles = None
lyric = item.get('lyric')
if lyric:
subtitles = {
'origin': [{
'url': ly... | yt_dlp/extractor/zingmp3.py | 26 | Python | 0.857 | suggestion | 156 | 51 | 51 | false | Feat: update new version for zingmp3 | 2,889 | yt-dlp/yt-dlp | 132,642 | Python | Lesmiscore | hatienl0i2612 |
def _process_data(self, data):
return self._extract_item(data, True)
class ZingMp3AlbumIE(ZingMp3BaseIE):
_VALID_URL = ZingMp3BaseIE._VALID_URL_TMPL % 'album|playlist'
_TESTS = [{
'url': 'http://mp3.zing.vn/album/Lau-Dai-Tinh-Ai-Bang-Kieu-Minh-Tuyet/ZWZBWDAF.html',
'info_dict': {
... | > query param
Shouldn't key-value pairs be joined by `&`? |
class ZingMp3IE(ZingMp3BaseIE):
_VALID_URL = ZingMp3BaseIE._VALID_URL_TMPL % 'bai-hat|video-clip|embed'
_TESTS = [{
'url': 'https://mp3.zing.vn/bai-hat/Xa-Mai-Xa-Bao-Thy/ZWZB9WAB.html',
'md5': 'ead7ae13693b3205cbc89536a077daed',
'info_dict': {
'id': 'ZWZB9WAB',
'... | @@ -51,45 +80,101 @@ def _extract_item(self, item, fatal):
self.raise_no_formats(msg, expected=True)
self._sort_formats(formats)
- subtitles = None
lyric = item.get('lyric')
if lyric:
subtitles = {
'origin': [{
'url': ly... | yt_dlp/extractor/zingmp3.py | 26 | Python | 0.429 | question | 60 | 34 | 51 | false | Feat: update new version for zingmp3 | 2,889 | yt-dlp/yt-dlp | 132,642 | Python | Lesmiscore | hatienl0i2612 |
'album': album.get('name') or album.get('title'),
'album_artist': album.get('artists_names'),
}
def _real_extract(self, url):
page_id = self._match_id(url)
webpage = self._download_webpage(
url.replace('://zingmp3.vn/', '://mp3.zing.vn/'),
pag... | ```suggestions
subtitles = None
lyric = item.get('lyric')
if not lyric:
api = self.get_api_with_signature(name_api=self.SLUG_API.get("lyric"), param={
'ctime': self.TIMESTAMP,
'id': self.song_id})
info_lyric = self.download_json(api)... | return
msg = item.get('msg')
if msg == 'Sorry, this content is not available in your country.':
self.raise_geo_restricted(countries=self._GEO_COUNTRIES, metadata_available=True)
self.raise_no_formats(msg, expected=True)
self._sort_formats(forma... | @@ -51,45 +80,101 @@ def _extract_item(self, item, fatal):
self.raise_no_formats(msg, expected=True)
self._sort_formats(formats)
- subtitles = None
lyric = item.get('lyric')
if lyric:
subtitles = {
'origin': [{
'url': ly... | yt_dlp/extractor/zingmp3.py | 26 | Python | 0.857 | suggestion | 635 | 51 | 51 | false | Feat: update new version for zingmp3 | 2,889 | yt-dlp/yt-dlp | 132,642 | Python | Lesmiscore | hatienl0i2612 |
def _extract_item(self, item, fatal):
item_id = item['id']
title = item.get('name') or item['title']
formats = []
for k, v in (item.get('source') or {}).items():
if not v:
continue
if k in ('mp4', 'hls'):
for res, video_url in... | ```suggestion
if type_url == "video-clip":
```
Pass `type_url` as an argument too. | )
class ZingMp3BaseIE(InfoExtractor):
_VALID_URL_TMPL = r'https?://(?:mp3\.zing|zingmp3)\.vn/(?P<type>(?:%s))/[^/]+/(?P<id>\w+)(?:\.html|\?)'
_GEO_COUNTRIES = ['VN']
_DOMAIN = 'https://zingmp3.vn'
_SLUG_API = {
'bai-hat': '/api/v2/page/get/song',
'embed': '/api/v2/page/get/song',
... | @@ -1,22 +1,50 @@
# coding: utf-8
from __future__ import unicode_literals
+import datetime
+import hashlib
+import hmac
+import re
+from urllib.parse import urlencode
+
from .common import InfoExtractor
from ..utils import (
- int_or_none,
+ int_or_none, try_get,
)
+SLUG_API = {
+ "bai_hat": "/api/v2/... | yt_dlp/extractor/zingmp3.py | 26 | Python | 0.714 | suggestion | 93 | 51 | 51 | false | Feat: update new version for zingmp3 | 2,889 | yt-dlp/yt-dlp | 132,642 | Python | Lesmiscore | hatienl0i2612 |
class ZingMp3BaseIE(InfoExtractor):
_VALID_URL_TMPL = r'https?://(?:mp3\.zing|zingmp3)\.vn/(?:%s)/[^/]+/(?P<id>\w+)\.html'
_GEO_COUNTRIES = ['VN']
def _extract_item(self, item, fatal):
item_id = item['id']
title = item.get('name') or item['title']
formats = []
for k, v in (... | ```suggestion
item_id = item.get('encodeId') or song_id
```
Pass `song_id` as an argument. You must change all related references. | int_or_none,
traverse_obj,
HEADRequest,
)
class ZingMp3BaseIE(InfoExtractor):
_VALID_URL_TMPL = r'https?://(?:mp3\.zing|zingmp3)\.vn/(?P<type>(?:%s))/[^/]+/(?P<id>\w+)(?:\.html|\?)'
_GEO_COUNTRIES = ['VN']
_DOMAIN = 'https://zingmp3.vn'
_SLUG_API = {
'bai-hat': '/api/v2/page/get/so... | @@ -1,22 +1,50 @@
# coding: utf-8
from __future__ import unicode_literals
+import datetime
+import hashlib
+import hmac
+import re
+from urllib.parse import urlencode
+
from .common import InfoExtractor
from ..utils import (
- int_or_none,
+ int_or_none, try_get,
)
+SLUG_API = {
+ "bai_hat": "/api/v2/... | yt_dlp/extractor/zingmp3.py | 26 | Python | 0.786 | suggestion | 141 | 51 | 51 | false | Feat: update new version for zingmp3 | 2,889 | yt-dlp/yt-dlp | 132,642 | Python | Lesmiscore | hatienl0i2612 |
# coding: utf-8
from __future__ import unicode_literals
from .common import InfoExtractor
from ..utils import (
int_or_none,
)
class ZingMp3BaseIE(InfoExtractor):
_VALID_URL_TMPL = r'https?://(?:mp3\.zing|zingmp3)\.vn/(?:%s)/[^/]+/(?P<id>\w+)\.html'
_GEO_COUNTRIES = ['VN']
def _extract_item(self, it... | ```suggestion
int_or_none,
try_get,
``` | # coding: utf-8
from __future__ import unicode_literals
import hashlib
import hmac
import urllib.parse
from .common import InfoExtractor
from ..utils import (
int_or_none,
traverse_obj,
HEADRequest,
)
class ZingMp3BaseIE(InfoExtractor):
_VALID_URL_TMPL = r'https?://(?:mp3\.zing|zingmp3)\.vn/(?P<type... | @@ -1,22 +1,50 @@
# coding: utf-8
from __future__ import unicode_literals
+import datetime
+import hashlib
+import hmac
+import re
+from urllib.parse import urlencode
+
from .common import InfoExtractor
from ..utils import (
- int_or_none,
+ int_or_none, try_get, | yt_dlp/extractor/zingmp3.py | 12 | Python | 0.571 | suggestion | 50 | 37 | 37 | false | Feat: update new version for zingmp3 | 2,889 | yt-dlp/yt-dlp | 132,642 | Python | Lesmiscore | hatienl0i2612 |
'url': 'http://mp3.zing.vn/bai-hat/Xa-Mai-Xa-Bao-Thy/ZWZB9WAB.html',
'md5': 'ead7ae13693b3205cbc89536a077daed',
'info_dict': {
'id': 'ZWZB9WAB',
'title': 'Xa Mãi Xa',
'ext': 'mp3',
'thumbnail': r're:^https?://.+\.jpg',
'subtitles': {
... | Don't think so this should be .get
| album = item.get('album') or {}
return {
'id': item_id,
'title': title,
'formats': formats,
'thumbnail': traverse_obj(item, 'thumbnail', 'thumbnailM'),
'subtitles': subtitles,
'duration': int_or_none(item.get('duration')),
... | @@ -51,45 +83,88 @@ def _extract_item(self, item, fatal):
self.raise_no_formats(msg, expected=True)
self._sort_formats(formats)
- subtitles = None
lyric = item.get('lyric')
- if lyric:
- subtitles = {
- 'origin': [{
- 'url': lyr... | yt_dlp/extractor/zingmp3.py | 26 | Python | 0.143 | suggestion | 36 | 51 | 51 | false | Feat: update new version for zingmp3 | 2,889 | yt-dlp/yt-dlp | 132,642 | Python | Ashish0804 | hatienl0i2612 |
'id': 'ZWZB9WAB',
'title': 'Xa Mãi Xa',
'ext': 'mp3',
'thumbnail': r're:^https?://.+\.jpg',
'subtitles': {
'origin': [{
'ext': 'lrc',
}]
},
'duration': 255,
'track': 'Xa Mã... | ```suggestion
api = self.get_api_with_signature(name_api= SLUG_API[type_url], param={
'ctime': TIMESTAMP,
'id': song_id})
info = self.download_json(api, song_id)
return self._process_data(info.get('data'), song_id, type_url)
``` | 'id': item_id,
'title': title,
'formats': formats,
'thumbnail': traverse_obj(item, 'thumbnail', 'thumbnailM'),
'subtitles': subtitles,
'duration': int_or_none(item.get('duration')),
'track': title,
'artist': traverse_obj(ite... | @@ -51,45 +83,88 @@ def _extract_item(self, item, fatal):
self.raise_no_formats(msg, expected=True)
self._sort_formats(formats)
- subtitles = None
lyric = item.get('lyric')
- if lyric:
- subtitles = {
- 'origin': [{
- 'url': lyr... | yt_dlp/extractor/zingmp3.py | 26 | Python | 0.929 | suggestion | 282 | 51 | 51 | false | Feat: update new version for zingmp3 | 2,889 | yt-dlp/yt-dlp | 132,642 | Python | Ashish0804 | hatienl0i2612 |
}, {
'url': 'https://zingmp3.vn/bai-hat/Xa-Mai-Xa-Bao-Thy/ZWZB9WAB.html',
'only_matching': True,
}]
IE_NAME = 'zingmp3'
IE_DESC = 'mp3.zing.vn'
def _process_data(self, data):
return self._extract_item(data, True)
class ZingMp3AlbumIE(ZingMp3BaseIE):
_VALID_URL = ZingMp... | Don't make functions for 1 time use | 'apiKey': self._API_KEY,
'sig': hmac.new(self._SECRET_KEY, f'{name_api}{sha256}'.encode('utf-8'), hashlib.sha512).hexdigest(),
**param,
}
return f'{self._DOMAIN}{name_api}?{urllib.parse.urlencode(data)}'
class ZingMp3IE(ZingMp3BaseIE):
_VALID_URL = ZingMp3BaseIE... | @@ -51,45 +83,88 @@ def _extract_item(self, item, fatal):
self.raise_no_formats(msg, expected=True)
self._sort_formats(formats)
- subtitles = None
lyric = item.get('lyric')
- if lyric:
- subtitles = {
- 'origin': [{
- 'url': lyr... | yt_dlp/extractor/zingmp3.py | 26 | Python | 0.143 | suggestion | 35 | 40 | 51 | false | Feat: update new version for zingmp3 | 2,889 | yt-dlp/yt-dlp | 132,642 | Python | Ashish0804 | hatienl0i2612 |
'info_dict': {
'id': 'ZO8ZF7C7',
'title': 'Sương Hoa Đưa Lối',
'ext': 'mp4',
'thumbnail': r're:^https?://.+\.jpg',
'duration': 207,
'track': 'Sương Hoa Đưa Lối',
'artist': 'K-ICM, RYO',
},
}, {
'url': 'https:... | json.dumps(param).replace('\"', '').replace(',','') will do the same thing ig but this is okay too |
api = self.get_api_with_signature(name_api=self._SLUG_API[type_url], param={'id': song_id})
return self._process_data(self._download_json(api, song_id)['data'], song_id, type_url)
def get_api_with_signature(self, name_api, param):
sha256 = hashlib.sha256(''.join(f'{k}={v}' for k, v in par... | @@ -51,45 +83,88 @@ def _extract_item(self, item, fatal):
self.raise_no_formats(msg, expected=True)
self._sort_formats(formats)
- subtitles = None
lyric = item.get('lyric')
- if lyric:
- subtitles = {
- 'origin': [{
- 'url': lyr... | yt_dlp/extractor/zingmp3.py | 26 | Python | 0.286 | suggestion | 99 | 49 | 51 | false | Feat: update new version for zingmp3 | 2,889 | yt-dlp/yt-dlp | 132,642 | Python | Ashish0804 | hatienl0i2612 |
'album_artist': 'Bảo Thy',
},
}, {
'url': 'https://mp3.zing.vn/video-clip/Suong-Hoa-Dua-Loi-K-ICM-RYO/ZO8ZF7C7.html',
'md5': 'e9c972b693aa88301ef981c8151c4343',
'info_dict': {
'id': 'ZO8ZF7C7',
'title': 'Sương Hoa Đưa Lối',
'ext': 'mp4'... | I honestly don't understand why this function is required tbh.
Why can't u just manually make a call once?
Why is this func required if it's going to behave like the builtin one after being called for the first time? | if not self.get_param('cookiefile') and not self.get_param('cookiesfrombrowser'):
self._request_webpage(HEADRequest(self._DOMAIN), None, note='Updating cookies')
def _real_extract(self, url):
song_id, type_url = self._match_valid_url(url).group('id', 'type')
api = self.get_api_... | @@ -51,45 +83,88 @@ def _extract_item(self, item, fatal):
self.raise_no_formats(msg, expected=True)
self._sort_formats(formats)
- subtitles = None
lyric = item.get('lyric')
- if lyric:
- subtitles = {
- 'origin': [{
- 'url': lyr... | yt_dlp/extractor/zingmp3.py | 26 | Python | 0.429 | question | 219 | 51 | 51 | false | Feat: update new version for zingmp3 | 2,889 | yt-dlp/yt-dlp | 132,642 | Python | Ashish0804 | hatienl0i2612 |
'ext': 'mp4',
'thumbnail': r're:^https?://.+\.jpg',
'duration': 207,
'track': 'Sương Hoa Đưa Lối',
'artist': 'K-ICM, RYO',
},
}, {
'url': 'https://zingmp3.vn/bai-hat/Xa-Mai-Xa-Bao-Thy/ZWZB9WAB.html',
'only_matching': True,
}]
... | Don't.
This will give the wrong error in the api call. | return self._process_data(self._download_json(api, song_id)['data'], song_id, type_url)
def get_api_with_signature(self, name_api, param):
sha256 = hashlib.sha256(''.join(f'{k}={v}' for k, v in param.items()).encode('utf-8')).hexdigest()
data = {
'apiKey': self._API_KEY,
... | @@ -51,45 +83,88 @@ def _extract_item(self, item, fatal):
self.raise_no_formats(msg, expected=True)
self._sort_formats(formats)
- subtitles = None
lyric = item.get('lyric')
- if lyric:
- subtitles = {
- 'origin': [{
- 'url': lyr... | yt_dlp/extractor/zingmp3.py | 26 | Python | 0.357 | bug | 55 | 46 | 51 | false | Feat: update new version for zingmp3 | 2,889 | yt-dlp/yt-dlp | 132,642 | Python | Ashish0804 | hatienl0i2612 |
from urllib.parse import urlencode
from .common import InfoExtractor
from ..utils import (
int_or_none,
try_get,
traverse_obj,
)
class ZingMp3BaseIE(InfoExtractor):
_VALID_URL_TMPL = r'https?://(?:mp3\.zing|zingmp3)\.vn/(?P<type>(?:%s))/[^/]+/(?P<id>\w+)(?:\.html|\?)'
_GEO_COUNTRIES = ['VN']
... | shouldn't this be computed at each request and not at import time? |
from .common import InfoExtractor
from ..utils import (
int_or_none,
traverse_obj,
HEADRequest,
)
class ZingMp3BaseIE(InfoExtractor):
_VALID_URL_TMPL = r'https?://(?:mp3\.zing|zingmp3)\.vn/(?P<type>(?:%s))/[^/]+/(?P<id>\w+)(?:\.html|\?)'
_GEO_COUNTRIES = ['VN']
_DOMAIN = 'https://zingmp3.vn'
... | @@ -1,22 +1,52 @@
# coding: utf-8
from __future__ import unicode_literals
+import datetime
+import hashlib
+import hmac
+from urllib.parse import urlencode
+
from .common import InfoExtractor
from ..utils import (
int_or_none,
+ try_get,
+ traverse_obj,
)
class ZingMp3BaseIE(InfoExtractor):
- ... | yt_dlp/extractor/zingmp3.py | 26 | Python | 0.286 | question | 66 | 51 | 51 | false | Feat: update new version for zingmp3 | 2,889 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | hatienl0i2612 |
msg = item.get('msg')
if msg == 'Sorry, this content is not available in your country.':
self.raise_geo_restricted(countries=self._GEO_COUNTRIES, metadata_available=True)
self.raise_no_formats(msg, expected=True)
self._sort_formats(formats)
lyric = it... | Use dict_get/traverse_obj. Same in other places | self._sort_formats(formats)
lyric = item.get('lyric')
if not lyric:
api = self.get_api_with_signature(name_api=self._SLUG_API.get("lyric"), param={'id': item_id})
info_lyric = self._download_json(api, video_id=item_id)
lyric = traverse_obj(info_lyric, ('data'... | @@ -35,61 +65,98 @@ def _extract_item(self, item, fatal):
r'^(\d+)p', res, 'resolution', default=None)),
})
else:
- formats.append({
- 'ext': 'mp3',
- 'format_id': k,
- 'tbr': i... | yt_dlp/extractor/zingmp3.py | 26 | Python | 0.143 | suggestion | 47 | 51 | 51 | false | Feat: update new version for zingmp3 | 2,889 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | hatienl0i2612 |
api = self.get_api_with_signature(name_api=self._SLUG_API[type_url], param={
'ctime': self._TIMESTAMP,
'id': song_id})
info = self.download_json(api, song_id)
return self._process_data(info.get('data'), song_id, type_url)
def download_json(self, api, video_id):
... | ```suggestion
sha256 = self.get_hash256(''.join(f'{k}={v}' for k, v in param.items()))
``` |
return self._process_data(self._download_json(api, song_id)['data'], song_id, type_url)
def get_api_with_signature(self, name_api, param):
sha256 = hashlib.sha256(''.join(f'{k}={v}' for k, v in param.items()).encode('utf-8')).hexdigest()
data = {
'apiKey': self._API_KEY,
... | @@ -35,61 +65,98 @@ def _extract_item(self, item, fatal):
r'^(\d+)p', res, 'resolution', default=None)),
})
else:
- formats.append({
- 'ext': 'mp3',
- 'format_id': k,
- 'tbr': i... | yt_dlp/extractor/zingmp3.py | 26 | Python | 0.714 | suggestion | 100 | 51 | 51 | false | Feat: update new version for zingmp3 | 2,889 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | hatienl0i2612 |
}
def _real_extract(self, url):
song_id, type_url = self._match_valid_url(url).group('id', 'type')
api = self.get_api_with_signature(name_api=self._SLUG_API[type_url], param={
'ctime': self._TEMP_TIMESTAMP,
'id': song_id})
info = self.download_json(api, song... | use a better name,
`sha256_params` or `hashed_params` or `param_string` makes more sense |
def _real_extract(self, url):
song_id, type_url = self._match_valid_url(url).group('id', 'type')
api = self.get_api_with_signature(name_api=self._SLUG_API[type_url], param={'id': song_id})
return self._process_data(self._download_json(api, song_id)['data'], song_id, type_url)
def get... | @@ -35,61 +64,95 @@ def _extract_item(self, item, fatal):
r'^(\d+)p', res, 'resolution', default=None)),
})
else:
- formats.append({
- 'ext': 'mp3',
- 'format_id': k,
- 'tbr': i... | yt_dlp/extractor/zingmp3.py | 26 | Python | 0.429 | suggestion | 89 | 51 | 51 | false | Feat: update new version for zingmp3 | 2,889 | yt-dlp/yt-dlp | 132,642 | Python | Ashish0804 | hatienl0i2612 |
# coding: utf-8
from __future__ import unicode_literals
import hashlib
import hmac
from urllib.parse import urlencode
from .common import InfoExtractor
from ..utils import (
int_or_none,
try_get,
traverse_obj,
)
class ZingMp3BaseIE(InfoExtractor):
_VALID_URL_TMPL = r'https?://(?:mp3\.zing|zingmp3)\.... | ```suggestion
import urllib.parse
``` | # coding: utf-8
from __future__ import unicode_literals
import hashlib
import hmac
import urllib.parse
from .common import InfoExtractor
from ..utils import (
int_or_none,
traverse_obj,
HEADRequest,
)
class ZingMp3BaseIE(InfoExtractor):
_VALID_URL_TMPL = r'https?://(?:mp3\.zing|zingmp3)\.vn/(?P<type... | @@ -1,22 +1,47 @@
# coding: utf-8
from __future__ import unicode_literals
+import hashlib
+import hmac
+from urllib.parse import urlencode | yt_dlp/extractor/zingmp3.py | 6 | Python | 0.429 | suggestion | 39 | 31 | 31 | false | Feat: update new version for zingmp3 | 2,889 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | hatienl0i2612 |
if not v:
continue
if k in ('mp4', 'hls'):
for res, video_url in v.items():
if not video_url:
continue
if k == 'hls':
formats.extend(self._extract_m3u8_formats(
... | ```suggestion
continue
elif v == 'VIP':
continue
formats.append({
'ext': 'mp3',
'format_id': k,
'tbr': int_or_none(k),
'url': self._proto_relative_url(v),
'vcodec': 'none',
... | if not v:
continue
if k in ('mp4', 'hls'):
for res, video_url in v.items():
if not video_url:
continue
if k == 'hls':
formats.extend(self._extract_m3u8_formats(
... | @@ -35,61 +60,82 @@ def _extract_item(self, item, fatal):
r'^(\d+)p', res, 'resolution', default=None)),
})
else:
- formats.append({
- 'ext': 'mp3',
- 'format_id': k,
- 'tbr': i... | yt_dlp/extractor/zingmp3.py | 26 | Python | 0.786 | suggestion | 338 | 51 | 51 | false | Feat: update new version for zingmp3 | 2,889 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | hatienl0i2612 |
}],
} if lyric else None
album = item.get('album') or {}
return {
'id': item_id,
'title': title,
'formats': formats,
'thumbnail': try_get(item, lambda x: x['thumbnail']) or try_get(item, lambda x: x['thumbnailM']),
'subtit... | if user does `yt-dlp URL1 URL2`, this should only happen once, right? In that case, move it to `_real_initialize`.
Also, the check should be `not self.get_param('cookiefile') and not self.get_param('cookiesfrombrowser')` | 'url': lyric,
}],
} if lyric else None
album = item.get('album') or {}
return {
'id': item_id,
'title': title,
'formats': formats,
'thumbnail': traverse_obj(item, 'thumbnail', 'thumbnailM'),
'subtitles': su... | @@ -35,61 +60,82 @@ def _extract_item(self, item, fatal):
r'^(\d+)p', res, 'resolution', default=None)),
})
else:
- formats.append({
- 'ext': 'mp3',
- 'format_id': k,
- 'tbr': i... | yt_dlp/extractor/zingmp3.py | 26 | Python | 0.643 | suggestion | 223 | 51 | 51 | false | Feat: update new version for zingmp3 | 2,889 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | hatienl0i2612 |
album = item.get('album') or {}
return {
'id': item_id,
'title': title,
'formats': formats,
'thumbnail': try_get(item, lambda x: x['thumbnail']) or try_get(item, lambda x: x['thumbnailM']),
'subtitles': subtitles,
'duration': int_o... | ```suggestion
return self._process_data(self._download_json(api, song_id)['data'], song_id, type_url)
``` |
album = item.get('album') or {}
return {
'id': item_id,
'title': title,
'formats': formats,
'thumbnail': traverse_obj(item, 'thumbnail', 'thumbnailM'),
'subtitles': subtitles,
'duration': int_or_none(item.get('duration')),
... | @@ -35,61 +60,82 @@ def _extract_item(self, item, fatal):
r'^(\d+)p', res, 'resolution', default=None)),
})
else:
- formats.append({
- 'ext': 'mp3',
- 'format_id': k,
- 'tbr': i... | yt_dlp/extractor/zingmp3.py | 26 | Python | 0.857 | suggestion | 115 | 51 | 51 | false | Feat: update new version for zingmp3 | 2,889 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | hatienl0i2612 |
'track': title,
'artist': try_get(item, lambda x: x['artistsNames']) or try_get(item, lambda x: x['artists_names']),
'album': try_get(album, lambda x: x['name']) or try_get(album, lambda x: x['title']),
'album_artist': try_get(album, lambda x: x['artistsNames']) or try_ge... | ```suggestion
data = {
'apiKey': self._API_KEY,
'sig': self.hmac512_string(f'{name_api}{sha256}'),
**param,
}
``` | 'duration': int_or_none(item.get('duration')),
'track': title,
'artist': traverse_obj(item, 'artistsNames', 'artists_names'),
'album': traverse_obj(album, 'name', 'title'),
'album_artist': traverse_obj(album, 'artistsNames', 'artists_names'),
}
de... | @@ -35,61 +60,82 @@ def _extract_item(self, item, fatal):
r'^(\d+)p', res, 'resolution', default=None)),
})
else:
- formats.append({
- 'ext': 'mp3',
- 'format_id': k,
- 'tbr': i... | yt_dlp/extractor/zingmp3.py | 26 | Python | 0.714 | suggestion | 171 | 51 | 51 | false | Feat: update new version for zingmp3 | 2,889 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | hatienl0i2612 |
song_id, type_url = self._match_valid_url(url).group('id', 'type')
api = self.get_api_with_signature(name_api=self._SLUG_API[type_url], param={'id': song_id})
# Check the cookie file, if cookie file doesn't exist, create a dummy request to update the cookie
if not self._downloader.para... | only used once. Doesn't need to be functions | def _real_initialize(self):
if not self.get_param('cookiefile') and not self.get_param('cookiesfrombrowser'):
self._request_webpage(HEADRequest(self._DOMAIN), None, note='Updating cookies')
def _real_extract(self, url):
song_id, type_url = self._match_valid_url(url).group('id', 'typ... | @@ -35,61 +60,82 @@ def _extract_item(self, item, fatal):
r'^(\d+)p', res, 'resolution', default=None)),
})
else:
- formats.append({
- 'ext': 'mp3',
- 'format_id': k,
- 'tbr': i... | yt_dlp/extractor/zingmp3.py | 26 | Python | 0.143 | suggestion | 44 | 51 | 51 | false | Feat: update new version for zingmp3 | 2,889 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | hatienl0i2612 |
self._download_json(api, video_id=song_id, note='Dummy request to update cookie')
info = self._download_json(api, video_id=song_id)
return self._process_data(info.get('data'), song_id, type_url)
def get_api_with_signature(self, name_api, param):
sha256 = self.sha256_params(''.j... | Why change existing tests? The old URL still works in browser |
api = self.get_api_with_signature(name_api=self._SLUG_API[type_url], param={'id': song_id})
return self._process_data(self._download_json(api, song_id)['data'], song_id, type_url)
def get_api_with_signature(self, name_api, param):
sha256 = hashlib.sha256(''.join(f'{k}={v}' for k, v in par... | @@ -35,61 +60,82 @@ def _extract_item(self, item, fatal):
r'^(\d+)p', res, 'resolution', default=None)),
})
else:
- formats.append({
- 'ext': 'mp3',
- 'format_id': k,
- 'tbr': i... | yt_dlp/extractor/zingmp3.py | 26 | Python | 0.286 | question | 61 | 51 | 51 | false | Feat: update new version for zingmp3 | 2,889 | yt-dlp/yt-dlp | 132,642 | Python | pukkandan | hatienl0i2612 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.