From 88f23a18e0a0f5f18ed167b6a319c54255c5dd13 Mon Sep 17 00:00:00 2001 From: pukkandan Date: Mon, 24 Jan 2022 01:21:39 +0530 Subject: [PATCH] [docs,cleanup] Fix linter and misc cleanup Closes #2419 --- .github/ISSUE_TEMPLATE/config.yml | 3 +++ README.md | 7 ++++--- test/helper.py | 2 +- yt_dlp/YoutubeDL.py | 3 ++- yt_dlp/extractor/abc.py | 2 +- yt_dlp/extractor/archiveorg.py | 2 +- yt_dlp/extractor/litv.py | 2 +- yt_dlp/extractor/orf.py | 1 - yt_dlp/options.py | 2 +- yt_dlp/postprocessor/metadataparser.py | 4 ++-- 10 files changed, 16 insertions(+), 12 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 3d168fc736..9cdffa4b19 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -3,3 +3,6 @@ contact_links: - name: Get help from the community on Discord url: https://discord.gg/H5MNcFW63r about: Join the yt-dlp Discord for community-powered support! + - name: Matrix Bridge to the Discord server + url: https://matrix.to/#/#yt-dlp:matrix.org + about: For those who do not want to use Discord diff --git a/README.md b/README.md index 5641a868f7..db31c55ee0 100644 --- a/README.md +++ b/README.md @@ -379,8 +379,9 @@ ## Network Options: --proxy URL Use the specified HTTP/HTTPS/SOCKS proxy. To enable SOCKS proxy, specify a proper scheme. For example - socks5://127.0.0.1:1080/. Pass in an empty - string (--proxy "") for direct connection + socks5://user:pass@127.0.0.1:1080/. Pass in + an empty string (--proxy "") for direct + connection --socket-timeout SECONDS Time to wait before giving up, in seconds --source-address IP Client-side IP address to bind to -4, --force-ipv4 Make all connections via IPv4 @@ -1049,7 +1050,7 @@ # CONFIGURATION 1. **Main Configuration**: The file given by `--config-location` 1. **Portable Configuration**: `yt-dlp.conf` in the same directory as the bundled binary. If you are running from source-code (`/yt_dlp/__main__.py`), the root directory is used instead. -1. **Home Configuration**: `yt-dlp.conf` in the home path given by `-P "home:"`, or in the current directory if no such path is given +1. **Home Configuration**: `yt-dlp.conf` in the home path given by `-P`, or in the current directory if no such path is given 1. **User Configuration**: * `%XDG_CONFIG_HOME%/yt-dlp/config` (recommended on Linux/macOS) * `%XDG_CONFIG_HOME%/yt-dlp.conf` diff --git a/test/helper.py b/test/helper.py index ce751462e5..1070e0668f 100644 --- a/test/helper.py +++ b/test/helper.py @@ -220,7 +220,7 @@ def sanitize_got_info_dict(got_dict): IGNORED_PREFIXES = ('', 'playlist', 'requested', 'webpage') def sanitize(key, value): - if isinstance(value, str) and len(value) > 100: + if isinstance(value, str) and len(value) > 100 and key != 'thumbnail': return f'md5:{md5(value)}' elif isinstance(value, list) and len(value) > 10: return f'count:{len(value)}' diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py index 97f9099ff5..4af77cae29 100644 --- a/yt_dlp/YoutubeDL.py +++ b/yt_dlp/YoutubeDL.py @@ -484,6 +484,7 @@ class YoutubeDL(object): extractor_args: A dictionary of arguments to be passed to the extractors. See "EXTRACTOR ARGUMENTS" for details. Eg: {'youtube': {'skip': ['dash', 'hls']}} + mark_watched: Mark videos watched (even with --simulate). Only for YouTube youtube_include_dash_manifest: Deprecated - Use extractor_args instead. If True (default), DASH manifests and related data will be downloaded and processed by extractor. @@ -3504,7 +3505,7 @@ def render_formats_table(self, info_dict): delim=self._format_screen('\u2500', self.Styles.DELIM, '-', test_encoding=True)) def render_thumbnails_table(self, info_dict): - thumbnails = list(info_dict.get('thumbnails')) + thumbnails = list(info_dict.get('thumbnails') or []) if not thumbnails: return None return render_table( diff --git a/yt_dlp/extractor/abc.py b/yt_dlp/extractor/abc.py index 0dde4a9a57..9d6f5a4351 100644 --- a/yt_dlp/extractor/abc.py +++ b/yt_dlp/extractor/abc.py @@ -300,7 +300,7 @@ def _real_extract(self, url): unescapeHTML(webpage_data).encode('utf-8').decode('unicode_escape'), show_id) video_data = video_data['route']['pageData']['_embedded'] - highlight = try_get(video_data, lambda x: ['highlightVideo']['shareUrl']) + highlight = try_get(video_data, lambda x: x['highlightVideo']['shareUrl']) if not self._yes_playlist(show_id, bool(highlight), video_label='highlight video'): return self.url_result(highlight, ie=ABCIViewIE.ie_key()) diff --git a/yt_dlp/extractor/archiveorg.py b/yt_dlp/extractor/archiveorg.py index 85d5c29fa3..2a25c0713f 100644 --- a/yt_dlp/extractor/archiveorg.py +++ b/yt_dlp/extractor/archiveorg.py @@ -440,7 +440,7 @@ class YoutubeWebArchiveIE(InfoExtractor): }, { 'url': 'ytarchive:BaW_jenozKc:20050214000000', 'only_matching': True - },{ + }, { 'url': 'ytarchive:BaW_jenozKc', 'only_matching': True }, diff --git a/yt_dlp/extractor/litv.py b/yt_dlp/extractor/litv.py index 73822def18..16b475a441 100644 --- a/yt_dlp/extractor/litv.py +++ b/yt_dlp/extractor/litv.py @@ -65,7 +65,7 @@ def _extract_playlist(self, season_list, video_id, program_info, prompt=True): return self.playlist_result(all_episodes, content_id, episode_title) def _real_extract(self, url): - url, data = unsmuggle_url(url, {}) + url, smuggled_data = unsmuggle_url(url, {}) video_id = self._match_id(url) diff --git a/yt_dlp/extractor/orf.py b/yt_dlp/extractor/orf.py index 3c68326bc3..0628977a02 100644 --- a/yt_dlp/extractor/orf.py +++ b/yt_dlp/extractor/orf.py @@ -22,7 +22,6 @@ unified_strdate, unsmuggle_url, url_or_none, - urljoin, ) diff --git a/yt_dlp/options.py b/yt_dlp/options.py index df8fb6f631..5622100bb9 100644 --- a/yt_dlp/options.py +++ b/yt_dlp/options.py @@ -345,7 +345,7 @@ def _dict_from_options_callback( help=( 'Use the specified HTTP/HTTPS/SOCKS proxy. To enable ' 'SOCKS proxy, specify a proper scheme. For example ' - 'socks5://127.0.0.1:1080/. Pass in an empty string (--proxy "") ' + 'socks5://user:pass@127.0.0.1:1080/. Pass in an empty string (--proxy "") ' 'for direct connection')) network.add_option( '--socket-timeout', diff --git a/yt_dlp/postprocessor/metadataparser.py b/yt_dlp/postprocessor/metadataparser.py index 646659e759..5452b92d8b 100644 --- a/yt_dlp/postprocessor/metadataparser.py +++ b/yt_dlp/postprocessor/metadataparser.py @@ -66,7 +66,7 @@ def f(info): self.write_debug(f'Searching for {out_re.pattern!r} in {template!r}') match = out_re.search(data_to_parse) if match is None: - self.report_warning(f'Could not interpret {inp!r} as {out!r}') + self.to_screen(f'Could not interpret {inp!r} as {out!r}') return for attribute, value in match.groupdict().items(): info[attribute] = value @@ -80,7 +80,7 @@ def replacer(self, field, search, replace): def f(info): val = info.get(field) if val is None: - self.report_warning(f'Video does not have a {field}') + self.to_screen(f'Video does not have a {field}') return elif not isinstance(val, str): self.report_warning(f'Cannot replace in field {field} since it is a {type(val).__name__}')