mirror of
				https://github.com/yt-dlp/yt-dlp.git
				synced 2025-10-31 06:35:12 +00:00 
			
		
		
		
	[extractor/generic] Accept values for fragment_query, variant_query (#6600)
				
					
				
			Closes #6593 Authored by: bashonly
This commit is contained in:
		| @@ -1797,8 +1797,8 @@ The following extractors use this feature: | |||||||
| * `approximate_date`: Extract approximate `upload_date` and `timestamp` in flat-playlist. This may cause date-based filters to be slightly off | * `approximate_date`: Extract approximate `upload_date` and `timestamp` in flat-playlist. This may cause date-based filters to be slightly off | ||||||
| 
 | 
 | ||||||
| #### generic | #### generic | ||||||
| * `fragment_query`: Passthrough any query in mpd/m3u8 manifest URLs to their fragments. Does not apply to ffmpeg | * `fragment_query`: Passthrough any query in mpd/m3u8 manifest URLs to their fragments if no value is provided, or else apply the query string given as `fragment_query=VALUE`. Does not apply to ffmpeg | ||||||
| * `variant_query`: Passthrough the master m3u8 URL query to its variant playlist URLs | * `variant_query`: Passthrough the master m3u8 URL query to its variant playlist URLs if no value is provided, or else apply the query string given as `variant_query=VALUE` | ||||||
| * `hls_key`: An HLS AES-128 key URI *or* key (as hex), and optionally the IV (as hex), in the form of `(URI|KEY)[,IV]`; e.g. `generic:hls_key=ABCDEF1234567980,0xFEDCBA0987654321`. Passing any of these values will force usage of the native HLS downloader and override the corresponding values found in the m3u8 playlist | * `hls_key`: An HLS AES-128 key URI *or* key (as hex), and optionally the IV (as hex), in the form of `(URI|KEY)[,IV]`; e.g. `generic:hls_key=ABCDEF1234567980,0xFEDCBA0987654321`. Passing any of these values will force usage of the native HLS downloader and override the corresponding values found in the m3u8 playlist | ||||||
| 
 | 
 | ||||||
| #### funimation | #### funimation | ||||||
|   | |||||||
| @@ -24,7 +24,6 @@ from ..utils import ( | |||||||
|     mimetype2ext, |     mimetype2ext, | ||||||
|     orderedSet, |     orderedSet, | ||||||
|     parse_duration, |     parse_duration, | ||||||
|     parse_qs, |  | ||||||
|     parse_resolution, |     parse_resolution, | ||||||
|     smuggle_url, |     smuggle_url, | ||||||
|     str_or_none, |     str_or_none, | ||||||
| @@ -2187,18 +2186,23 @@ class GenericIE(InfoExtractor): | |||||||
|         self._downloader.write_debug(f'Identified {num} {name}{format_field(note, None, "; %s")}') |         self._downloader.write_debug(f'Identified {num} {name}{format_field(note, None, "; %s")}') | ||||||
| 
 | 
 | ||||||
|     def _extra_manifest_info(self, info, manifest_url): |     def _extra_manifest_info(self, info, manifest_url): | ||||||
|         if self._configuration_arg('fragment_query'): |         fragment_query = self._configuration_arg('fragment_query', [None], casesense=True)[0] | ||||||
|             query_string = urllib.parse.urlparse(manifest_url).query |         if fragment_query is not None: | ||||||
|             if query_string: |             fragment_query = self._configuration_arg('fragment_query', casesense=True)[0] | ||||||
|                 info['extra_param_to_segment_url'] = query_string |             info['extra_param_to_segment_url'] = ( | ||||||
|  |                 urllib.parse.urlparse(fragment_query).query or fragment_query | ||||||
|  |                 or urllib.parse.urlparse(manifest_url).query or None) | ||||||
| 
 | 
 | ||||||
|         hex_or_none = lambda x: x if re.fullmatch(r'(0x)?[\da-f]+', x, re.IGNORECASE) else None |         hex_or_none = lambda x: x if re.fullmatch(r'(0x)?[\da-f]+', x, re.IGNORECASE) else None | ||||||
|         info['hls_aes'] = traverse_obj(self._configuration_arg('hls_key'), { |         info['hls_aes'] = traverse_obj(self._configuration_arg('hls_key', casesense=True), { | ||||||
|             'uri': (0, {url_or_none}), 'key': (0, {hex_or_none}), 'iv': (1, {hex_or_none}), |             'uri': (0, {url_or_none}), 'key': (0, {hex_or_none}), 'iv': (1, {hex_or_none}), | ||||||
|         }) or None |         }) or None | ||||||
| 
 | 
 | ||||||
|         if self._configuration_arg('variant_query'): |         variant_query = self._configuration_arg('variant_query', [None], casesense=True)[0] | ||||||
|             query = parse_qs(manifest_url) |         if variant_query is not None: | ||||||
|  |             query = urllib.parse.parse_qs( | ||||||
|  |                 urllib.parse.urlparse(variant_query).query or variant_query | ||||||
|  |                 or urllib.parse.urlparse(manifest_url).query) | ||||||
|             for fmt in self._downloader._get_formats(info): |             for fmt in self._downloader._get_formats(info): | ||||||
|                 fmt['url'] = update_url_query(fmt['url'], query) |                 fmt['url'] = update_url_query(fmt['url'], query) | ||||||
| 
 | 
 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 bashonly
					bashonly