From 455a15e2dcf29b4712d92a89a95ad5f3ddad69a1 Mon Sep 17 00:00:00 2001 From: pukkandan Date: Thu, 3 Feb 2022 20:32:10 +0530 Subject: [PATCH] [cleanup,docs] Minor fixes Closes #2541, #2484 --- .github/ISSUE_TEMPLATE/1_broken_site.yml | 2 +- .github/ISSUE_TEMPLATE/5_feature_request.yml | 2 ++ .github/ISSUE_TEMPLATE/6_question.yml | 3 ++- .github/ISSUE_TEMPLATE_tmpl/1_broken_site.yml | 2 +- .../ISSUE_TEMPLATE_tmpl/5_feature_request.yml | 2 ++ .github/ISSUE_TEMPLATE_tmpl/6_question.yml | 3 ++- CONTRIBUTING.md | 4 +++- README.md | 13 ++++++------ yt_dlp/YoutubeDL.py | 20 ++++++++----------- yt_dlp/extractor/common.py | 3 ++- yt_dlp/extractor/youtube.py | 2 +- yt_dlp/options.py | 4 ++-- yt_dlp/update.py | 2 +- yt_dlp/utils.py | 10 +++------- 14 files changed, 37 insertions(+), 35 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/1_broken_site.yml b/.github/ISSUE_TEMPLATE/1_broken_site.yml index f13ab2ebe..0ad3272aa 100644 --- a/.github/ISSUE_TEMPLATE/1_broken_site.yml +++ b/.github/ISSUE_TEMPLATE/1_broken_site.yml @@ -1,4 +1,4 @@ -name: Broken site support +name: Broken site description: Report broken or misfunctioning site labels: [triage, site-bug] body: diff --git a/.github/ISSUE_TEMPLATE/5_feature_request.yml b/.github/ISSUE_TEMPLATE/5_feature_request.yml index 476456322..3f1293d2c 100644 --- a/.github/ISSUE_TEMPLATE/5_feature_request.yml +++ b/.github/ISSUE_TEMPLATE/5_feature_request.yml @@ -11,6 +11,8 @@ body: options: - label: I'm reporting a feature request required: true + - label: I've looked through the [README](https://github.com/yt-dlp/yt-dlp#readme) + required: true - label: I've verified that I'm running yt-dlp version **2022.01.21**. ([update instructions](https://github.com/yt-dlp/yt-dlp#update)) required: true - label: I've searched the [bugtracker](https://github.com/yt-dlp/yt-dlp/issues?q=) for similar issues including closed ones. DO NOT post duplicates diff --git a/.github/ISSUE_TEMPLATE/6_question.yml b/.github/ISSUE_TEMPLATE/6_question.yml index 286281e24..061158ed3 100644 --- a/.github/ISSUE_TEMPLATE/6_question.yml +++ b/.github/ISSUE_TEMPLATE/6_question.yml @@ -25,7 +25,8 @@ body: Ask your question in an arbitrary form. Please make sure it's worded well enough to be understood, see [is-the-description-of-the-issue-itself-sufficient](https://github.com/ytdl-org/youtube-dl#is-the-description-of-the-issue-itself-sufficient). Provide any additional information and as much context and examples as possible. - If your question contains "isn't working" or "can you add", this is most likely the wrong template + If your question contains "isn't working" or "can you add", this is most likely the wrong template. + If you are in doubt if this is the right template, use another template! placeholder: WRITE QUESTION HERE validations: required: true diff --git a/.github/ISSUE_TEMPLATE_tmpl/1_broken_site.yml b/.github/ISSUE_TEMPLATE_tmpl/1_broken_site.yml index 65b6038ff..fd6435ba6 100644 --- a/.github/ISSUE_TEMPLATE_tmpl/1_broken_site.yml +++ b/.github/ISSUE_TEMPLATE_tmpl/1_broken_site.yml @@ -1,4 +1,4 @@ -name: Broken site support +name: Broken site description: Report broken or misfunctioning site labels: [triage, site-bug] body: diff --git a/.github/ISSUE_TEMPLATE_tmpl/5_feature_request.yml b/.github/ISSUE_TEMPLATE_tmpl/5_feature_request.yml index 6e8b2fd28..eb5d3d634 100644 --- a/.github/ISSUE_TEMPLATE_tmpl/5_feature_request.yml +++ b/.github/ISSUE_TEMPLATE_tmpl/5_feature_request.yml @@ -11,6 +11,8 @@ body: options: - label: I'm reporting a feature request required: true + - label: I've looked through the [README](https://github.com/yt-dlp/yt-dlp#readme) + required: true - label: I've verified that I'm running yt-dlp version **%(version)s**. ([update instructions](https://github.com/yt-dlp/yt-dlp#update)) required: true - label: I've searched the [bugtracker](https://github.com/yt-dlp/yt-dlp/issues?q=) for similar issues including closed ones. DO NOT post duplicates diff --git a/.github/ISSUE_TEMPLATE_tmpl/6_question.yml b/.github/ISSUE_TEMPLATE_tmpl/6_question.yml index 286281e24..061158ed3 100644 --- a/.github/ISSUE_TEMPLATE_tmpl/6_question.yml +++ b/.github/ISSUE_TEMPLATE_tmpl/6_question.yml @@ -25,7 +25,8 @@ body: Ask your question in an arbitrary form. Please make sure it's worded well enough to be understood, see [is-the-description-of-the-issue-itself-sufficient](https://github.com/ytdl-org/youtube-dl#is-the-description-of-the-issue-itself-sufficient). Provide any additional information and as much context and examples as possible. - If your question contains "isn't working" or "can you add", this is most likely the wrong template + If your question contains "isn't working" or "can you add", this is most likely the wrong template. + If you are in doubt if this is the right template, use another template! placeholder: WRITE QUESTION HERE validations: required: true diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c25d6a2a5..bfa8ae410 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -113,7 +113,7 @@ ### Is your question about yt-dlp? ### Are you willing to share account details if needed? -The maintainers and potential contributors of the project often do not have an account for the website you are asking support for. So any developer interested in solving your issue may ask you for account details. It is your personal discression whether you are willing to share the account in order for the developer to try and solve your issue. However, if you are unwilling or unable to provide details, they obviously cannot work on the issue and it cannot be solved unless some developer who both has an account and is willing/able to contribute decides to solve it. +The maintainers and potential contributors of the project often do not have an account for the website you are asking support for. So any developer interested in solving your issue may ask you for account details. It is your personal discretion whether you are willing to share the account in order for the developer to try and solve your issue. However, if you are unwilling or unable to provide details, they obviously cannot work on the issue and it cannot be solved unless some developer who both has an account and is willing/able to contribute decides to solve it. By sharing an account with anyone, you agree to bear all risks associated with it. The maintainers and yt-dlp can't be held responsible for any misuse of the credentials. @@ -254,6 +254,8 @@ ### Mandatory and optional metafields The aforementioned metafields are the critical data that the extraction does not make any sense without and if any of them fail to be extracted then the extractor is considered completely broken. While all extractors must return a `title`, they must also allow it's extraction to be non-fatal. +For pornographic sites, appropriate `age_limit` must also be returned. + The extractor is allowed to return the info dict without url or formats in some special cases if it allows the user to extract usefull information with `--ignore-no-formats-error` - Eg: when the video is a live stream that has not started yet. [Any field](yt_dlp/extractor/common.py#219-L426) apart from the aforementioned ones are considered **optional**. That means that extraction should be **tolerant** to situations when sources for these fields can potentially be unavailable (even if they are always available at the moment) and **future-proof** in order not to break the extraction of general purpose mandatory fields. diff --git a/README.md b/README.md index 958b9a0ed..a3cd9ba7b 100644 --- a/README.md +++ b/README.md @@ -394,7 +394,7 @@ ## Geo-restriction: option is not present) is used for the actual downloading --geo-bypass Bypass geographic restriction via faking - X-Forwarded-For HTTP header + X-Forwarded-For HTTP header (default) --no-geo-bypass Do not bypass geographic restriction via faking X-Forwarded-For HTTP header --geo-bypass-country CODE Force bypass geographic restriction with @@ -1143,6 +1143,7 @@ # OUTPUT TEMPLATE - `id` (string): Video identifier - `title` (string): Video title + - `fulltitle` (string): Video title ignoring live timestamp and generic title - `url` (string): Video URL - `ext` (string): Video filename extension - `alt_title` (string): A secondary title of the video @@ -1198,16 +1199,16 @@ # OUTPUT TEMPLATE - `protocol` (string): The protocol that will be used for the actual download - `extractor` (string): Name of the extractor - `extractor_key` (string): Key name of the extractor - - `epoch` (numeric): Unix epoch when creating the file + - `epoch` (numeric): Unix epoch of when the information extraction was completed - `autonumber` (numeric): Number that will be increased with each download, starting at `--autonumber-start` - `video_autonumber` (numeric): Number that will be increased with each video - `n_entries` (numeric): Total number of extracted items in the playlist - - `playlist` (string): Name or id of the playlist that contains the video + - `playlist_id` (string): Identifier of the playlist that contains the video + - `playlist_title` (string): Name of the playlist that contains the video + - `playlist` (string): `playlist_id` or `playlist_title` - `playlist_count` (numeric): Total number of items in the playlist. May not be known if entire playlist is not extracted - `playlist_index` (numeric): Index of the video in the playlist padded with leading zeros according the final index - `playlist_autonumber` (numeric): Position of the video in the playlist download queue padded with leading zeros according to the total length of the playlist - - `playlist_id` (string): Playlist identifier - - `playlist_title` (string): Playlist title - `playlist_uploader` (string): Full name of the playlist uploader - `playlist_uploader_id` (string): Nickname or id of the playlist uploader - `webpage_url` (string): A URL to the video webpage which if given to yt-dlp should allow to get the same result again @@ -1552,7 +1553,7 @@ # (https/ftps > http/ftp > m3u8_native > m3u8 > http_dash_segments ...) # Download the best video with h264 codec, or the best video if there is no such video -$ yt-dlp -f "(bv*+ba/b)[vcodec^=avc1] / (bv*+ba/b)" +$ yt-dlp -f "(bv*[vcodec^=avc1]+ba) / (bv*+ba/b)" # Download the best video with best codec no better than h264, # or the best video with worst codec if there is no such video diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py index e31edf50a..fd1584a7f 100644 --- a/yt_dlp/YoutubeDL.py +++ b/yt_dlp/YoutubeDL.py @@ -596,14 +596,14 @@ def check_deprecated(param, option, suggestion): else: self.params['nooverwrites'] = not self.params['overwrites'] - params.setdefault('forceprint', {}) - params.setdefault('print_to_file', {}) + self.params.setdefault('forceprint', {}) + self.params.setdefault('print_to_file', {}) # Compatibility with older syntax if not isinstance(params['forceprint'], dict): - params['forceprint'] = {'video': params['forceprint']} + self.params['forceprint'] = {'video': params['forceprint']} - if params.get('bidi_workaround', False): + if self.params.get('bidi_workaround', False): try: import pty master, slave = pty.openpty() @@ -631,7 +631,7 @@ def check_deprecated(param, option, suggestion): if (sys.platform != 'win32' and sys.getfilesystemencoding() in ['ascii', 'ANSI_X3.4-1968'] - and not params.get('restrictfilenames', False)): + and not self.params.get('restrictfilenames', False)): # Unicode filesystem API will throw errors (#1474, #13027) self.report_warning( 'Assuming --restrict-filenames since file system encoding ' @@ -2240,10 +2240,7 @@ def restore_last_token(self): def _calc_headers(self, info_dict): res = std_headers.copy() - - add_headers = info_dict.get('http_headers') - if add_headers: - res.update(add_headers) + res.update(info_dict.get('http_headers') or {}) cookies = self._calc_cookies(info_dict) if cookies: @@ -2309,6 +2306,8 @@ def process_video_result(self, info_dict, download=True): raise ExtractorError('Missing "id" field in extractor result', ie=info_dict['extractor']) elif not info_dict.get('id'): raise ExtractorError('Extractor failed to obtain "id"', ie=info_dict['extractor']) + + info_dict['fulltitle'] = info_dict.get('title') if 'title' not in info_dict: raise ExtractorError('Missing "title" field in extractor result', video_id=info_dict['id'], ie=info_dict['extractor']) @@ -2422,9 +2421,6 @@ def sanitize_numeric_fields(info): if not self.params.get('allow_unplayable_formats'): formats = [f for f in formats if not f.get('has_drm')] - # backward compatibility - info_dict['fulltitle'] = info_dict['title'] - if info_dict.get('is_live'): get_from_start = bool(self.params.get('live_from_start')) formats = [f for f in formats if bool(f.get('is_from_start')) == get_from_start] diff --git a/yt_dlp/extractor/common.py b/yt_dlp/extractor/common.py index 31b1bab3b..ac9e28560 100644 --- a/yt_dlp/extractor/common.py +++ b/yt_dlp/extractor/common.py @@ -1291,7 +1291,8 @@ def _og_search_description(self, html, **kargs): return self._og_search_property('description', html, fatal=False, **kargs) def _og_search_title(self, html, **kargs): - return self._og_search_property('title', html, fatal=False, **kargs) + kargs.setdefault('fatal', False) + return self._og_search_property('title', html, **kargs) def _og_search_video_url(self, html, name='video url', secure=True, **kargs): regexes = self._og_regexes('video') + self._og_regexes('video:url') diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.py index 452ed14d6..cd9a1b774 100644 --- a/yt_dlp/extractor/youtube.py +++ b/yt_dlp/extractor/youtube.py @@ -5353,7 +5353,7 @@ def _real_extract(self, url): class YoutubeMusicSearchURLIE(YoutubeTabBaseInfoExtractor): - IE_DESC = 'YouTube music search URLs with sorting and filter support' + IE_DESC = 'YouTube music search URLs with selectable sections (Eg: #songs)' IE_NAME = 'youtube:music:search_url' _VALID_URL = r'https?://music\.youtube\.com/search\?([^#]+&)?(?:search_query|q)=(?:[^&]+)(?:[&#]|$)' _TESTS = [{ diff --git a/yt_dlp/options.py b/yt_dlp/options.py index 5622100bb..a6d7c17eb 100644 --- a/yt_dlp/options.py +++ b/yt_dlp/options.py @@ -381,10 +381,10 @@ def _dict_from_options_callback( geo.add_option( '--geo-bypass', action='store_true', dest='geo_bypass', default=True, - help='Bypass geographic restriction via faking X-Forwarded-For HTTP header') + help='Bypass geographic restriction via faking X-Forwarded-For HTTP header (default)') geo.add_option( '--no-geo-bypass', - action='store_false', dest='geo_bypass', default=True, + action='store_false', dest='geo_bypass', help='Do not bypass geographic restriction via faking X-Forwarded-For HTTP header') geo.add_option( '--geo-bypass-country', metavar='CODE', diff --git a/yt_dlp/update.py b/yt_dlp/update.py index f3448568a..a208e163c 100644 --- a/yt_dlp/update.py +++ b/yt_dlp/update.py @@ -54,7 +54,7 @@ def detect_variant(): 'win_dir': 'Auto-update is not supported for unpackaged windows executable; Re-download the latest release', 'mac_dir': 'Auto-update is not supported for unpackaged MacOS executable; Re-download the latest release', 'source': 'You cannot update when running from source code; Use git to pull the latest changes', - 'unknown': 'It looks like you installed yt-dlp with a package manager, pip, setup.py or a tarball; Use that to update', + 'unknown': 'It looks like you installed yt-dlp with a package manager, pip or setup.py; Use that to update', } diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py index fd3912d18..fe1096168 100644 --- a/yt_dlp/utils.py +++ b/yt_dlp/utils.py @@ -1018,13 +1018,9 @@ def make_HTTPS_handler(params, **kwargs): def bug_reports_message(before=';'): - if ytdl_is_updateable(): - update_cmd = 'type yt-dlp -U to update' - else: - update_cmd = 'see https://github.com/yt-dlp/yt-dlp on how to update' - msg = 'please report this issue on https://github.com/yt-dlp/yt-dlp .' - msg += ' Make sure you are using the latest version; %s.' % update_cmd - msg += ' Be sure to call yt-dlp with the --verbose flag and include its complete output.' + msg = ('please report this issue on https://github.com/yt-dlp/yt-dlp , ' + 'filling out the "Broken site" issue template properly. ' + 'Confirm you are on the latest version using -U') before = before.rstrip() if not before or before.endswith(('.', '!', '?')):