[ie/box] Fix formats extraction (#8649)

Closes #5098
Authored by: bashonly
This commit is contained in:
bashonly 2023-11-25 20:50:23 -06:00 committed by GitHub
parent 4903f452b6
commit 5a230233d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 25 deletions

View File

@ -1,16 +1,17 @@
import json import json
import urllib.parse
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import ( from ..utils import (
determine_ext,
parse_iso8601, parse_iso8601,
# try_get,
update_url_query, update_url_query,
url_or_none,
) )
from ..utils.traversal import traverse_obj
class BoxIE(InfoExtractor): class BoxIE(InfoExtractor):
_VALID_URL = r'https?://(?:[^.]+\.)?app\.box\.com/s/(?P<shared_name>[^/]+)/file/(?P<id>\d+)' _VALID_URL = r'https?://(?:[^.]+\.)?app\.box\.com/s/(?P<shared_name>[^/?#]+)/file/(?P<id>\d+)'
_TEST = { _TEST = {
'url': 'https://mlssoccer.app.box.com/s/0evd2o3e08l60lr4ygukepvnkord1o1x/file/510727257538', 'url': 'https://mlssoccer.app.box.com/s/0evd2o3e08l60lr4ygukepvnkord1o1x/file/510727257538',
'md5': '1f81b2fd3960f38a40a3b8823e5fcd43', 'md5': '1f81b2fd3960f38a40a3b8823e5fcd43',
@ -18,11 +19,12 @@ class BoxIE(InfoExtractor):
'id': '510727257538', 'id': '510727257538',
'ext': 'mp4', 'ext': 'mp4',
'title': 'Garber St. Louis will be 28th MLS team +scarving.mp4', 'title': 'Garber St. Louis will be 28th MLS team +scarving.mp4',
'uploader': 'MLS Video', 'uploader': '',
'timestamp': 1566320259, 'timestamp': 1566320259,
'upload_date': '20190820', 'upload_date': '20190820',
'uploader_id': '235196876', 'uploader_id': '235196876',
} },
'params': {'skip_download': 'dash fragment too small'},
} }
def _real_extract(self, url): def _real_extract(self, url):
@ -58,26 +60,15 @@ def _real_extract(self, url):
formats = [] formats = []
# for entry in (try_get(f, lambda x: x['representations']['entries'], list) or []): for url_tmpl in traverse_obj(f, (
# entry_url_template = try_get( 'representations', 'entries', lambda _, v: v['representation'] == 'dash',
# entry, lambda x: x['content']['url_template']) 'content', 'url_template', {url_or_none}
# if not entry_url_template: )):
# continue manifest_url = update_url_query(url_tmpl.replace('{+asset_path}', 'manifest.mpd'), query)
# representation = entry.get('representation') fmts = self._extract_mpd_formats(manifest_url, file_id)
# if representation == 'dash': for fmt in fmts:
# TODO: append query to every fragment URL fmt['extra_param_to_segment_url'] = urllib.parse.urlparse(manifest_url).query
# formats.extend(self._extract_mpd_formats( formats.extend(fmts)
# entry_url_template.replace('{+asset_path}', 'manifest.mpd'),
# file_id, query=query))
authenticated_download_url = f.get('authenticated_download_url')
if authenticated_download_url and f.get('is_download_available'):
formats.append({
'ext': f.get('extension') or determine_ext(title),
'filesize': f.get('size'),
'format_id': 'download',
'url': update_url_query(authenticated_download_url, query),
})
creator = f.get('created_by') or {} creator = f.get('created_by') or {}