Skip to content

Commit

Permalink
[cleanup] Misc (yt-dlp#8968)
Browse files Browse the repository at this point in the history
Authored by: pukkandan, bashonly, seproDev
  • Loading branch information
pukkandan committed Mar 10, 2024
1 parent ed3bb2b commit 615a844
Show file tree
Hide file tree
Showing 19 changed files with 80 additions and 94 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,23 @@ cookies
*.gif
*.jpeg
*.jpg
*.lrc
*.m4a
*.m4v
*.mhtml
*.mkv
*.mov
*.mp3
*.mp4
*.mpg
*.mpga
*.oga
*.ogg
*.opus
*.png
*.sbv
*.srt
*.ssa
*.swf
*.swp
*.tt
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ pypi-files: AUTHORS Changelog.md LICENSE README.md README.txt supportedsites \
clean-test:
rm -rf test/testdata/sigs/player-*.js tmp/ *.annotations.xml *.aria2 *.description *.dump *.frag \
*.frag.aria2 *.frag.urls *.info.json *.live_chat.json *.meta *.part* *.tmp *.temp *.unknown_video *.ytdl \
*.3gp *.ape *.ass *.avi *.desktop *.f4v *.flac *.flv *.gif *.jpeg *.jpg *.m4a *.m4v *.mhtml *.mkv *.mov *.mp3 \
*.mp4 *.mpga *.oga *.ogg *.opus *.png *.sbv *.srt *.swf *.swp *.tt *.ttml *.url *.vtt *.wav *.webloc *.webm *.webp
*.3gp *.ape *.ass *.avi *.desktop *.f4v *.flac *.flv *.gif *.jpeg *.jpg *.lrc *.m4a *.m4v *.mhtml *.mkv *.mov *.mp3 *.mp4 \
*.mpg *.mpga *.oga *.ogg *.opus *.png *.sbv *.srt *.ssa *.swf *.swp *.tt *.ttml *.url *.vtt *.wav *.webloc *.webm *.webp
clean-dist:
rm -rf yt-dlp.1.temp.md yt-dlp.1 README.txt MANIFEST build/ dist/ .coverage cover/ yt-dlp.tar.gz completions/ \
yt_dlp/extractor/lazy_extractors.py *.spec CONTRIBUTING.md.tmp yt-dlp yt-dlp.exe yt_dlp.egg-info/ AUTHORS
Expand Down
1 change: 0 additions & 1 deletion bundle/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
# Empty file
2 changes: 1 addition & 1 deletion bundle/py2exe.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def main():
'py2exe builds do not support pycryptodomex and needs VC++14 to run. '
'It is recommended to run "pyinst.py" to build using pyinstaller instead')

return freeze(
freeze(
console=[{
'script': './yt_dlp/__main__.py',
'dest_base': 'yt-dlp',
Expand Down
1 change: 0 additions & 1 deletion devscripts/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
# Empty file needed to make devscripts.utils properly importable from outside
6 changes: 6 additions & 0 deletions devscripts/changelog_override.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,11 @@
"when": "15f22b4880b6b3f71f350c64d70976ae65b9f1ca",
"short": "[webvtt] Allow spaces before newlines for CueBlock (#7681)",
"authors": ["TSRBerry"]
},
{
"action": "change",
"when": "4ce57d3b873c2887814cbec03d029533e82f7db5",
"short": "[ie] Support multi-period MPD streams (#6654)",
"authors": ["alard", "pukkandan"]
}
]
2 changes: 1 addition & 1 deletion devscripts/make_changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ class CommitRange:
''', re.VERBOSE | re.DOTALL)
EXTRACTOR_INDICATOR_RE = re.compile(r'(?:Fix|Add)\s+Extractors?', re.IGNORECASE)
REVERT_RE = re.compile(r'(?:\[[^\]]+\]\s+)?(?i:Revert)\s+([\da-f]{40})')
FIXES_RE = re.compile(r'(?i:Fix(?:es)?(?:\s+bugs?)?(?:\s+in|\s+for)?|Revert)\s+([\da-f]{40})')
FIXES_RE = re.compile(r'(?i:Fix(?:es)?(?:\s+bugs?)?(?:\s+in|\s+for)?|Revert|Improve)\s+([\da-f]{40})')
UPSTREAM_MERGE_RE = re.compile(r'Update to ytdl-commit-([\da-f]+)')

def __init__(self, start, end, default_author=None):
Expand Down
2 changes: 1 addition & 1 deletion test/test_networking.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def do_GET(self):
self.send_response(200)
self.send_header('Content-Type', 'text/plain; charset=utf-8')
self.end_headers()
self.wfile.write('{self.proxy_name}: {self.path}'.format(self=self).encode())
self.wfile.write(f'{self.proxy_name}: {self.path}'.encode())
return HTTPTestRequestHandler


Expand Down
2 changes: 1 addition & 1 deletion yt_dlp/YoutubeDL.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ class YoutubeDL:
'url', 'manifest_url', 'manifest_stream_number', 'ext', 'format', 'format_id', 'format_note',
'width', 'height', 'aspect_ratio', 'resolution', 'dynamic_range', 'tbr', 'abr', 'acodec', 'asr', 'audio_channels',
'vbr', 'fps', 'vcodec', 'container', 'filesize', 'filesize_approx', 'rows', 'columns',
'player_url', 'protocol', 'fragment_base_url', 'fragments', 'is_from_start',
'player_url', 'protocol', 'fragment_base_url', 'fragments', 'is_from_start', 'is_dash_periods', 'request_data',
'preference', 'language', 'language_preference', 'quality', 'source_preference', 'cookies',
'http_headers', 'stretched_ratio', 'no_resume', 'has_drm', 'extra_param_to_segment_url', 'hls_aes', 'downloader_options',
'page_url', 'app', 'play_path', 'tc_url', 'flash_version', 'rtmp_live', 'rtmp_conn', 'rtmp_protocol', 'rtmp_real_time'
Expand Down
9 changes: 5 additions & 4 deletions yt_dlp/extractor/altcensored.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from .common import InfoExtractor
from ..utils import (
InAdvancePagedList,
clean_html,
int_or_none,
orderedSet,
str_to_int,
Expand Down Expand Up @@ -32,23 +33,23 @@ class AltCensoredIE(InfoExtractor):
'duration': 926.09,
'thumbnail': 'https://archive.org/download/youtube-k0srjLSkga8/youtube-k0srjLSkga8.thumbs/k0srjLSkga8_000925.jpg',
'view_count': int,
'categories': ['News & Politics'], # FIXME
'categories': ['News & Politics'],
}
}]

def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
category = clean_html(self._html_search_regex(
r'<a href="/category/\d+">([^<]+)</a>', webpage, 'category', default=None))

return {
'_type': 'url_transparent',
'url': f'https://archive.org/details/youtube-{video_id}',
'ie_key': ArchiveOrgIE.ie_key(),
'view_count': str_to_int(self._html_search_regex(
r'YouTube Views:(?:\s|&nbsp;)*([\d,]+)', webpage, 'view count', default=None)),
'categories': self._html_search_regex(
r'<a href="/category/\d+">\s*\n?\s*([^<]+)</a>',
webpage, 'category', default='').split() or None,
'categories': [category] if category else None,
}


Expand Down
6 changes: 3 additions & 3 deletions yt_dlp/extractor/arte.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ class ArteTVIE(ArteTVBaseIE):
def _fix_accessible_subs_locale(subs):
updated_subs = {}
for lang, sub_formats in subs.items():
for format in sub_formats:
if format.get('url', '').endswith('-MAL.m3u8'):
for fmt in sub_formats:
if fmt.get('url', '').endswith('-MAL.m3u8'):
lang += '-acc'
updated_subs.setdefault(lang, []).append(format)
updated_subs.setdefault(lang, []).append(fmt)
return updated_subs

def _real_extract(self, url):
Expand Down
5 changes: 2 additions & 3 deletions yt_dlp/extractor/getcourseru.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,8 @@ def _real_extract(self, url):
self._login(hostname, username, password)

display_id = self._match_id(url)
# NB: 404 is returned due to yt-dlp not properly following redirects #9020
webpage, urlh = self._download_webpage_handle(url, display_id, expected_status=404)
if self._LOGIN_URL_PATH in urlh.url or urlh.status == 404:
webpage, urlh = self._download_webpage_handle(url, display_id)
if self._LOGIN_URL_PATH in urlh.url:
raise ExtractorError(
f'This video is only available for registered users. {self._login_hint("any", netrc=hostname)}',
expected=True)
Expand Down
3 changes: 1 addition & 2 deletions yt_dlp/extractor/medaltv.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
int_or_none,
str_or_none,
traverse_obj,
update_url_query,
)


Expand Down Expand Up @@ -82,7 +81,7 @@ class MedalTVIE(InfoExtractor):
def _real_extract(self, url):
video_id = self._match_id(url)

webpage = self._download_webpage(update_url_query(url, {'mobilebypass': 'true'}), video_id)
webpage = self._download_webpage(url, video_id, query={'mobilebypass': 'true'})

hydration_data = self._search_json(
r'<script[^>]*>[^<]*\bhydrationData\s*=', webpage,
Expand Down
10 changes: 4 additions & 6 deletions yt_dlp/extractor/radiko.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,8 @@ def _extract_formats(self, video_id, station, is_onair, ft, cursor, auth_token,
return formats

def _extract_performers(self, prog):
performers = traverse_obj(prog, (
'pfm/text()', ..., {lambda x: re.split(r'[//、 ,,]', x)}, ..., {str.strip}))
# TODO: change 'artist' fields to 'artists' and return traversal list instead of str
return ', '.join(performers) or None
return traverse_obj(prog, (
'pfm/text()', ..., {lambda x: re.split(r'[//、 ,,]', x)}, ..., {str.strip})) or None


class RadikoIE(RadikoBaseIE):
Expand Down Expand Up @@ -194,7 +192,7 @@ def _real_extract(self, url):
return {
'id': video_id,
'title': try_call(lambda: prog.find('title').text),
'artist': self._extract_performers(prog),
'cast': self._extract_performers(prog),
'description': clean_html(try_call(lambda: prog.find('info').text)),
'uploader': try_call(lambda: station_program.find('.//name').text),
'uploader_id': station,
Expand Down Expand Up @@ -253,7 +251,7 @@ def _real_extract(self, url):
return {
'id': station,
'title': title,
'artist': self._extract_performers(prog),
'cast': self._extract_performers(prog),
'description': description,
'uploader': station_name,
'uploader_id': station,
Expand Down
Loading

0 comments on commit 615a844

Please sign in to comment.