mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2026-10-27 01:56:50 +09:00
+32









Aakash Gajjar
Remita Amine
Sergey M․
nmeum
Roxedus
Singwai Chan
cdarlint
Johannes N
jnozsc
Moritz Patelscheck
PB
Philipp Hagemeister
Xaver Hellauer
d2au
Jan 'Yenda' Trmal
jxu
Martin Ström
The Hatsune Daishi
tsia
3risian
Tristan Waddington
Devon Meunier
Felix Stupp
tom
AndrewMBL
willbeaufoy
Philipp Stehle
hh0rva1h
comsomisha
TotalCaesar659
Juan Francisco Cantero Hurtado
Dave Loyall
tlsssl
Rob
Michael Klein
JordanWeatherby
striker.sh
Matej Dujava
Glenn Slayden
MRWITEK
JChris246
TheRealDude2
b827ee921f
* [scrippsnetworks] Add new extractor(closes #19857)(closes #22981) * [teachable] Improve locked lessons detection (#23528) * [teachable] Fail with error message if no video URL found * [extractors] add missing import for ScrippsNetworksIE * [brightcove] cache brightcove player policy keys * [prosiebensat1] improve geo restriction handling(closes #23571) * [soundcloud] automatically update client id on failing requests * [spankbang] Fix extraction (closes #23307, closes #23423, closes #23444) * [spankbang] Improve removed video detection (#23423) * [brightcove] update policy key on failing requests * [pornhub] Fix extraction and add support for m3u8 formats (closes #22749, closes #23082) * [pornhub] Improve locked videos detection (closes #22449, closes #22780) * [brightcove] invalidate policy key cache on failing requests * [soundcloud] fix client id extraction for non fatal requests * [ChangeLog] Actualize [ci skip] * [devscripts/create-github-release] Switch to using PAT for authentication Basic authentication will be deprecated soon * release 2020.01.01 * [redtube] Detect private videos (#23518) * [vice] improve extraction(closes #23631) * [devscripts/create-github-release] Remove unused import * [wistia] improve format extraction and extract subtitles(closes #22590) * [nrktv:seriebase] Fix extraction (closes #23625) (#23537) * [discovery] fix anonymous token extraction(closes #23650) * [scrippsnetworks] add support for www.discovery.com videos * [scrippsnetworks] correct test case URL * [dctp] fix format extraction(closes #23656) * [pandatv] Remove extractor (#23630) * [naver] improve extraction - improve geo-restriction handling - extract automatic captions - extract uploader metadata - extract VLive HLS formats * [naver] improve metadata extraction * [cloudflarestream] improve extraction - add support for bytehighway.net domain - add support for signed URLs - extract thumbnail * [cloudflarestream] import embed URL extraction * [lego] fix extraction and extract subtitle(closes #23687) * [safari] Fix kaltura session extraction (closes #23679) (#23670) * [orf:fm4] Fix extraction (#23599) * [orf:radio] Clean description and improve extraction * [twitter] add support for promo_video_website cards(closes #23711) * [vodplatform] add support for embed.kwikmotion.com domain * [ndr:base:embed] Improve thumbnails extraction (closes #23731) * [canvas] Add support for new API endpoint and update tests (closes #17680, closes #18629) * [travis] Add flake8 job (#23720) * [yourporn] Fix extraction (closes #21645, closes #22255, closes #23459) * [ChangeLog] Actualize [ci skip] * release 2020.01.15 * [soundcloud] Restore previews extraction (closes #23739) * [orf:tvthek] Improve geo restricted videos detection (closes #23741) * [zype] improve extraction - extract subtitles(closes #21258) - support URLs with alternative keys/tokens(#21258) - extract more metadata * [americastestkitchen] fix extraction * [nbc] add support for nbc multi network URLs(closes #23049) * [ard] improve extraction(closes #23761) - simplify extraction - extract age limit and series - bypass geo-restriction * [ivi:compilation] Fix entries extraction (closes #23770) * [24video] Add support for 24video.vip (closes #23753) * [businessinsider] Fix jwplatform id extraction (closes #22929) (#22954) * [ard] add a missing condition * [azmedien] fix extraction(closes #23783) * [voicerepublic] fix extraction * [stretchinternet] fix extraction(closes #4319) * [youtube] Fix sigfunc name extraction (closes #23819) * [ChangeLog] Actualize [ci skip] * release 2020.01.24 * [soundcloud] imporve private playlist/set tracks extraction https://github.com/ytdl-org/youtube-dl/issues/3707#issuecomment-577873539 * [svt] fix article extraction(closes #22897)(closes #22919) * [svt] fix series extraction(closes #22297) * [viewlift] improve extraction - fix extraction(closes #23851) - add add support for authentication - add support for more domains * [vimeo] fix album extraction(closes #23864) * [tva] Relax _VALID_URL (closes #23903) * [tv5mondeplus] Fix extraction (closes #23907, closes #23911) * [twitch:stream] Lowercase channel id for stream request (closes #23917) * [sportdeutschland] Update to new sportdeutschland API They switched to SSL, but under a different host AND path... Remove the old test cases because these videos have become unavailable. * [popcorntimes] Add extractor (closes #23949) * [thisoldhouse] fix extraction(closes #23951) * [toggle] Add support for mewatch.sg (closes #23895) (#23930) * [compat] Introduce compat_realpath (refs #23991) * [update] Fix updating via symlinks (closes #23991) * [nytimes] improve format sorting(closes #24010) * [abc:iview] Support 720p (#22907) (#22921) * [nova:embed] Fix extraction (closes #23672) * [nova:embed] Improve (closes #23690) * [nova] Improve extraction (refs #23690) * [jpopsuki] Remove extractor (closes #23858) * [YoutubeDL] Fix playlist entry indexing with --playlist-items (closes #10591, closes #10622) * [test_YoutubeDL] Fix get_ids * [test_YoutubeDL] Add tests for #10591 (closes #23873) * [24video] Add support for porn.24video.net (closes #23779, closes #23784) * [npr] Add support for streams (closes #24042) * [ChangeLog] Actualize [ci skip] * release 2020.02.16 * [tv2dk:bornholm:play] Fix extraction (#24076) * [imdb] Fix extraction (closes #23443) * [wistia] Add support for multiple generic embeds (closes #8347, closes #11385) * [teachable] Add support for multiple videos per lecture (closes #24101) * [pornhd] Fix extraction (closes #24128) * [options] Remove duplicate short option -v for --version (#24162) * [extractor/common] Convert ISM manifest to unicode before processing on python 2 (#24152) * [YoutubeDL] Force redirect URL to unicode on python 2 * Remove no longer needed compat_str around geturl * [youjizz] Fix extraction (closes #24181) * [test_subtitles] Remove obsolete test * [zdf:channel] Fix tests * [zapiks] Fix test * [xtube] Fix metadata extraction (closes #21073, closes #22455) * [xtube:user] Fix test * [telecinco] Fix extraction (refs #24195) * [telecinco] Add support for article opening videos * [franceculture] Fix extraction (closes #24204) * [xhamster] Fix extraction (closes #24205) * [ChangeLog] Actualize [ci skip] * release 2020.03.01 * [vimeo] Fix subtitles URLs (#24209) * [servus] Add support for new URL schema (closes #23475, closes #23583, closes #24142) * [youtube:playlist] Fix tests (closes #23872) (#23885) * [peertube] Improve extraction * [peertube] Fix issues and improve extraction (closes #23657) * [pornhub] Improve title extraction (closes #24184) * [vimeo] fix showcase password protected video extraction(closes #24224) * [youtube] Fix age-gated videos support without login (closes #24248) * [youtube] Fix tests * [ChangeLog] Actualize [ci skip] * release 2020.03.06 * [nhk] update API version(closes #24270) * [youtube] Improve extraction in 429 error conditions (closes #24283) * [youtube] Improve age-gated videos extraction in 429 error conditions (refs #24283) * [youtube] Remove outdated code Additional get_video_info requests don't seem to provide any extra itags any longer * [README.md] Clarify 429 error * [pornhub] Add support for pornhubpremium.com (#24288) * [utils] Add support for cookies with spaces used instead of tabs * [ChangeLog] Actualize [ci skip] * release 2020.03.08 * Revert "[utils] Add support for cookies with spaces used instead of tabs" According to [1] TABs must be used as separators between fields. Files produces by some tools with spaces as separators are considered malformed. 1. https://curl.haxx.se/docs/http-cookies.html This reverts commitcff99c91d1. * [utils] Add reference to cookie file format * Revert "[vimeo] fix showcase password protected video extraction(closes #24224)" This reverts commit12ee431676. * [nhk] Relax _VALID_URL (#24329) * [nhk] Remove obsolete rtmp formats (closes #24329) * [nhk] Update m3u8 URL and use native hls (#24329) * [ndr] Fix extraction (closes #24326) * [xtube] Fix formats extraction (closes #24348) * [xtube] Fix typo * [hellporno] Fix extraction (closes #24399) * [cbc:watch] Add support for authentication * [cbc:watch] Fix authenticated device token caching (closes #19160) * [soundcloud] fix download url extraction(closes #24394) * [limelight] remove disabled API requests(closes #24255) * [bilibili] Add support for new URL schema with BV ids (closes #24439, closes #24442) * [bilibili] Add support for player.bilibili.com (closes #24402) * [teachable] Extract chapter metadata (closes #24421) * [generic] Look for teachable embeds before wistia * [teachable] Update upskillcourses domain New version does not use teachable platform any longer * [teachable] Update gns3 domain * [teachable] Update test * [ChangeLog] Actualize [ci skip] * [ChangeLog] Actualize [ci skip] * release 2020.03.24 * [spankwire] Fix extraction (closes #18924, closes #20648) * [spankwire] Add support for generic embeds (refs #24633) * [youporn] Add support form generic embeds * [mofosex] Add support for generic embeds (closes #24633) * [tele5] Fix extraction (closes #24553) * [extractor/common] Skip malformed ISM manifest XMLs while extracting ISM formats (#24667) * [tv4] Fix ISM formats extraction (closes #24667) * [twitch:clips] Extend _VALID_URL (closes #24290) (#24642) * [motherless] Fix extraction (closes #24699) * [nova:embed] Fix extraction (closes #24700) * [youtube] Skip broken multifeed videos (closes #24711) * [soundcloud] Extract AAC format * [soundcloud] Improve AAC format extraction (closes #19173, closes #24708) * [thisoldhouse] Fix video id extraction (closes #24548) Added support for: with of without "www." and either ".chorus.build" or ".com" It now validated correctly on older URL's ``` <iframe src="https://thisoldhouse.chorus.build/videos/zype/5e33baec27d2e50001d5f52f ``` and newer ones ``` <iframe src="https://www.thisoldhouse.com/videos/zype/5e2b70e95216cc0001615120 ``` * [thisoldhouse] Improve video id extraction (closes #24549) * [youtube] Fix DRM videos detection (refs #24736) * [options] Clarify doc on --exec command (closes #19087) (#24883) * [prosiebensat1] Improve extraction and remove 7tv.de support (#24948) * [prosiebensat1] Extract series metadata * [tenplay] Relax _VALID_URL (closes #25001) * [tvplay] fix Viafree extraction(closes #15189)(closes #24473)(closes #24789) * [yahoo] fix GYAO Player extraction and relax title URL regex(closes #24178)(closes #24778) * [youtube] Use redirected video id if any (closes #25063) * [youtube] Improve player id extraction and add tests * [extractor/common] Extract multiple JSON-LD entries * [crunchyroll] Fix and improve extraction (closes #25096, closes #25060) * [ChangeLog] Actualize [ci skip] * release 2020.05.03 * [puhutv] Remove no longer available HTTP formats (closes #25124) * [utils] Improve cookie files support + Add support for UTF-8 in cookie files * Skip malformed cookie file entries instead of crashing (invalid entry len, invalid expires at) * [dailymotion] Fix typo * [compat] Introduce compat_cookiejar_Cookie * [extractor/common] Use compat_cookiejar_Cookie for _set_cookie (closes #23256, closes #24776) To always ensure cookie name and value are bytestrings on python 2. * [orf] Add support for more radio stations (closes #24938) (#24968) * [uol] fix extraction(closes #22007) * [downloader/http] Finish downloading once received data length matches expected Always do this if possible, i.e. if Content-Length or expected length is known, not only in test. This will save unnecessary last extra loop trying to read 0 bytes. * [downloader/http] Request last data block of exact remaining size Always request last data block of exact size remaining to download if possible not the current block size. * [iprima] Improve extraction (closes #25138) * [youtube] Improve signature cipher extraction (closes #25188) * [ChangeLog] Actualize [ci skip] * release 2020.05.08 * [spike] fix Bellator mgid extraction(closes #25195) * [bbccouk] PEP8 * [mailru] Fix extraction (closes #24530) (#25239) * [README.md] flake8 HTTPS URL (#25230) * [youtube] Add support for yewtu.be (#25226) * [soundcloud] reduce API playlist page limit(closes #25274) * [vimeo] improve format extraction and sorting(closes #25285) * [redtube] Improve title extraction (#25208) * [indavideo] Switch to HTTPS for API request (#25191) * [utils] Fix file permissions in write_json_file (closes #12471) (#25122) * [redtube] Improve formats extraction and extract m3u8 formats (closes #25311, closes #25321) * [ard] Improve _VALID_URL (closes #25134) (#25198) * [giantbomb] Extend _VALID_URL (#25222) * [postprocessor/ffmpeg] Embed series metadata with --add-metadata * [youtube] Add support for more invidious instances (#25417) * [ard:beta] Extend _VALID_URL (closes #25405) * [ChangeLog] Actualize [ci skip] * release 2020.05.29 * [jwplatform] Improve embeds extraction (closes #25467) * [periscope] Fix untitled broadcasts (#25482) * [twitter:broadcast] Add untitled periscope broadcast test * [malltv] Add support for sk.mall.tv (#25445) * [brightcove] Fix subtitles extraction (closes #25540) * [brightcove] Sort imports * [twitch] Pass v5 accept header and fix thumbnails extraction (closes #25531) * [twitch:stream] Fix extraction (closes #25528) * [twitch:stream] Expect 400 and 410 HTTP errors from API * [tele5] Prefer jwplatform over nexx (closes #25533) * [jwplatform] Add support for bypass geo restriction * [tele5] Bypass geo restriction * [ChangeLog] Actualize [ci skip] * release 2020.06.06 * [kaltura] Add support for multiple embeds on a webpage (closes #25523) * [youtube] Extract chapters from JSON (closes #24819) * [facebook] Support single-video ID links I stumbled upon this at https://www.facebook.com/bwfbadminton/posts/10157127020046316 . No idea how prevalent it is yet. * [youtube] Fix playlist and feed extraction (closes #25675) * [youtube] Fix thumbnails extraction and remove uploader id extraction warning (closes #25676) * [youtube] Fix upload date extraction * [youtube] Improve view count extraction * [youtube] Fix uploader id and uploader URL extraction * [ChangeLog] Actualize [ci skip] * release 2020.06.16 * [youtube] Fix categories and improve tags extraction * [youtube] Force old layout (closes #25682, closes #25683, closes #25680, closes #25686) * [ChangeLog] Actualize [ci skip] * release 2020.06.16.1 * [brightcove] Improve embed detection (closes #25674) * [bellmedia] add support for cp24.com clip URLs(closes #25764) * [youtube:playlists] Extend _VALID_URL (closes #25810) * [youtube] Prevent excess HTTP 301 (#25786) * [wistia] Restrict embed regex (closes #25969) * [youtube] Improve description extraction (closes #25937) (#25980) * [youtube] Fix sigfunc name extraction (closes #26134, closes #26135, closes #26136, closes #26137) * [ChangeLog] Actualize [ci skip] * release 2020.07.28 * [xhamster] Extend _VALID_URL (closes #25789) (#25804) * [xhamster] Fix extraction (closes #26157) (#26254) * [xhamster] Extend _VALID_URL (closes #25927) Co-authored-by: Remita Amine <remitamine@gmail.com> Co-authored-by: Sergey M․ <dstftw@gmail.com> Co-authored-by: nmeum <soeren+github@soeren-tempel.net> Co-authored-by: Roxedus <me@roxedus.dev> Co-authored-by: Singwai Chan <c.singwai@gmail.com> Co-authored-by: cdarlint <cdarlint@users.noreply.github.com> Co-authored-by: Johannes N <31795504+jonolt@users.noreply.github.com> Co-authored-by: jnozsc <jnozsc@gmail.com> Co-authored-by: Moritz Patelscheck <moritz.patelscheck@campus.tu-berlin.de> Co-authored-by: PB <3854688+uno20001@users.noreply.github.com> Co-authored-by: Philipp Hagemeister <phihag@phihag.de> Co-authored-by: Xaver Hellauer <software@hellauer.bayern> Co-authored-by: d2au <d2au.dev@gmail.com> Co-authored-by: Jan 'Yenda' Trmal <jtrmal@gmail.com> Co-authored-by: jxu <7989982+jxu@users.noreply.github.com> Co-authored-by: Martin Ström <name@my-domain.se> Co-authored-by: The Hatsune Daishi <nao20010128@gmail.com> Co-authored-by: tsia <github@tsia.de> Co-authored-by: 3risian <59593325+3risian@users.noreply.github.com> Co-authored-by: Tristan Waddington <tristan.waddington@gmail.com> Co-authored-by: Devon Meunier <devon.meunier@gmail.com> Co-authored-by: Felix Stupp <felix.stupp@outlook.com> Co-authored-by: tom <tomster954@gmail.com> Co-authored-by: AndrewMBL <62922222+AndrewMBL@users.noreply.github.com> Co-authored-by: willbeaufoy <will@willbeaufoy.net> Co-authored-by: Philipp Stehle <anderschwiedu@googlemail.com> Co-authored-by: hh0rva1h <61889859+hh0rva1h@users.noreply.github.com> Co-authored-by: comsomisha <shmelev1996@mail.ru> Co-authored-by: TotalCaesar659 <14265316+TotalCaesar659@users.noreply.github.com> Co-authored-by: Juan Francisco Cantero Hurtado <iam@juanfra.info> Co-authored-by: Dave Loyall <dave@the-good-guys.net> Co-authored-by: tlsssl <63866177+tlsssl@users.noreply.github.com> Co-authored-by: Rob <ankenyr@gmail.com> Co-authored-by: Michael Klein <github@a98shuttle.de> Co-authored-by: JordanWeatherby <47519158+JordanWeatherby@users.noreply.github.com> Co-authored-by: striker.sh <19488257+strikersh@users.noreply.github.com> Co-authored-by: Matej Dujava <mdujava@gmail.com> Co-authored-by: Glenn Slayden <5589855+glenn-slayden@users.noreply.github.com> Co-authored-by: MRWITEK <mrvvitek@gmail.com> Co-authored-by: JChris246 <43832407+JChris246@users.noreply.github.com> Co-authored-by: TheRealDude2 <the.real.dude@gmx.de>
678 lines
30 KiB
Python
678 lines
30 KiB
Python
# coding: utf-8
|
|
from __future__ import unicode_literals
|
|
|
|
import base64
|
|
import re
|
|
import struct
|
|
|
|
from .adobepass import AdobePassIE
|
|
from .common import InfoExtractor
|
|
from ..compat import (
|
|
compat_etree_fromstring,
|
|
compat_HTTPError,
|
|
compat_parse_qs,
|
|
compat_urllib_parse_urlparse,
|
|
compat_urlparse,
|
|
compat_xml_parse_error,
|
|
)
|
|
from ..utils import (
|
|
clean_html,
|
|
extract_attributes,
|
|
ExtractorError,
|
|
find_xpath_attr,
|
|
fix_xml_ampersands,
|
|
float_or_none,
|
|
int_or_none,
|
|
js_to_json,
|
|
mimetype2ext,
|
|
parse_iso8601,
|
|
smuggle_url,
|
|
str_or_none,
|
|
unescapeHTML,
|
|
unsmuggle_url,
|
|
UnsupportedError,
|
|
update_url_query,
|
|
url_or_none,
|
|
)
|
|
|
|
|
|
class BrightcoveLegacyIE(InfoExtractor):
|
|
IE_NAME = 'brightcove:legacy'
|
|
_VALID_URL = r'(?:https?://.*brightcove\.com/(services|viewer).*?\?|brightcove:)(?P<query>.*)'
|
|
|
|
_TESTS = [
|
|
{
|
|
# From http://www.8tv.cat/8aldia/videos/xavier-sala-i-martin-aquesta-tarda-a-8-al-dia/
|
|
'url': 'http://c.brightcove.com/services/viewer/htmlFederated?playerID=1654948606001&flashID=myExperience&%40videoPlayer=2371591881001',
|
|
'md5': '5423e113865d26e40624dce2e4b45d95',
|
|
'note': 'Test Brightcove downloads and detection in GenericIE',
|
|
'info_dict': {
|
|
'id': '2371591881001',
|
|
'ext': 'mp4',
|
|
'title': 'Xavier Sala i Martín: “Un banc que no presta és un banc zombi que no serveix per a res”',
|
|
'uploader': '8TV',
|
|
'description': 'md5:a950cc4285c43e44d763d036710cd9cd',
|
|
'timestamp': 1368213670,
|
|
'upload_date': '20130510',
|
|
'uploader_id': '1589608506001',
|
|
},
|
|
'skip': 'The player has been deactivated by the content owner',
|
|
},
|
|
{
|
|
# From http://medianetwork.oracle.com/video/player/1785452137001
|
|
'url': 'http://c.brightcove.com/services/viewer/htmlFederated?playerID=1217746023001&flashID=myPlayer&%40videoPlayer=1785452137001',
|
|
'info_dict': {
|
|
'id': '1785452137001',
|
|
'ext': 'flv',
|
|
'title': 'JVMLS 2012: Arrays 2.0 - Opportunities and Challenges',
|
|
'description': 'John Rose speaks at the JVM Language Summit, August 1, 2012.',
|
|
'uploader': 'Oracle',
|
|
'timestamp': 1344975024,
|
|
'upload_date': '20120814',
|
|
'uploader_id': '1460825906',
|
|
},
|
|
'skip': 'video not playable',
|
|
},
|
|
{
|
|
# From http://mashable.com/2013/10/26/thermoelectric-bracelet-lets-you-control-your-body-temperature/
|
|
'url': 'http://c.brightcove.com/services/viewer/federated_f9?&playerID=1265504713001&publisherID=AQ%7E%7E%2CAAABBzUwv1E%7E%2CxP-xFHVUstiMFlNYfvF4G9yFnNaqCw_9&videoID=2750934548001',
|
|
'info_dict': {
|
|
'id': '2750934548001',
|
|
'ext': 'mp4',
|
|
'title': 'This Bracelet Acts as a Personal Thermostat',
|
|
'description': 'md5:547b78c64f4112766ccf4e151c20b6a0',
|
|
# 'uploader': 'Mashable',
|
|
'timestamp': 1382041798,
|
|
'upload_date': '20131017',
|
|
'uploader_id': '1130468786001',
|
|
},
|
|
},
|
|
{
|
|
# test that the default referer works
|
|
# from http://national.ballet.ca/interact/video/Lost_in_Motion_II/
|
|
'url': 'http://link.brightcove.com/services/player/bcpid756015033001?bckey=AQ~~,AAAApYJi_Ck~,GxhXCegT1Dp39ilhXuxMJxasUhVNZiil&bctid=2878862109001',
|
|
'info_dict': {
|
|
'id': '2878862109001',
|
|
'ext': 'mp4',
|
|
'title': 'Lost in Motion II',
|
|
'description': 'md5:363109c02998fee92ec02211bd8000df',
|
|
'uploader': 'National Ballet of Canada',
|
|
},
|
|
'skip': 'Video gone',
|
|
},
|
|
{
|
|
# test flv videos served by akamaihd.net
|
|
# From http://www.redbull.com/en/bike/stories/1331655643987/replay-uci-dh-world-cup-2014-from-fort-william
|
|
'url': 'http://c.brightcove.com/services/viewer/htmlFederated?%40videoPlayer=ref%3Aevent-stream-356&linkBaseURL=http%3A%2F%2Fwww.redbull.com%2Fen%2Fbike%2Fvideos%2F1331655630249%2Freplay-uci-fort-william-2014-dh&playerKey=AQ%7E%7E%2CAAAApYJ7UqE%7E%2Cxqr_zXk0I-zzNndy8NlHogrCb5QdyZRf&playerID=1398061561001#__youtubedl_smuggle=%7B%22Referer%22%3A+%22http%3A%2F%2Fwww.redbull.com%2Fen%2Fbike%2Fstories%2F1331655643987%2Freplay-uci-dh-world-cup-2014-from-fort-william%22%7D',
|
|
# The md5 checksum changes on each download
|
|
'info_dict': {
|
|
'id': '3750436379001',
|
|
'ext': 'flv',
|
|
'title': 'UCI MTB World Cup 2014: Fort William, UK - Downhill Finals',
|
|
'uploader': 'RBTV Old (do not use)',
|
|
'description': 'UCI MTB World Cup 2014: Fort William, UK - Downhill Finals',
|
|
'timestamp': 1409122195,
|
|
'upload_date': '20140827',
|
|
'uploader_id': '710858724001',
|
|
},
|
|
'skip': 'Video gone',
|
|
},
|
|
{
|
|
# playlist with 'videoList'
|
|
# from http://support.brightcove.com/en/video-cloud/docs/playlist-support-single-video-players
|
|
'url': 'http://c.brightcove.com/services/viewer/htmlFederated?playerID=3550052898001&playerKey=AQ%7E%7E%2CAAABmA9XpXk%7E%2C-Kp7jNgisre1fG5OdqpAFUTcs0lP_ZoL',
|
|
'info_dict': {
|
|
'title': 'Sealife',
|
|
'id': '3550319591001',
|
|
},
|
|
'playlist_mincount': 7,
|
|
'skip': 'Unsupported URL',
|
|
},
|
|
{
|
|
# playlist with 'playlistTab' (https://github.com/ytdl-org/youtube-dl/issues/9965)
|
|
'url': 'http://c.brightcove.com/services/json/experience/runtime/?command=get_programming_for_experience&playerKey=AQ%7E%7E,AAABXlLMdok%7E,NJ4EoMlZ4rZdx9eU1rkMVd8EaYPBBUlg',
|
|
'info_dict': {
|
|
'id': '1522758701001',
|
|
'title': 'Lesson 08',
|
|
},
|
|
'playlist_mincount': 10,
|
|
'skip': 'Unsupported URL',
|
|
},
|
|
{
|
|
# playerID inferred from bcpid
|
|
# from http://www.un.org/chinese/News/story.asp?NewsID=27724
|
|
'url': 'https://link.brightcove.com/services/player/bcpid1722935254001/?bctid=5360463607001&autoStart=false&secureConnections=true&width=650&height=350',
|
|
'only_matching': True, # Tested in GenericIE
|
|
}
|
|
]
|
|
|
|
@classmethod
|
|
def _build_brighcove_url(cls, object_str):
|
|
"""
|
|
Build a Brightcove url from a xml string containing
|
|
<object class="BrightcoveExperience">{params}</object>
|
|
"""
|
|
|
|
# Fix up some stupid HTML, see https://github.com/ytdl-org/youtube-dl/issues/1553
|
|
object_str = re.sub(r'(<param(?:\s+[a-zA-Z0-9_]+="[^"]*")*)>',
|
|
lambda m: m.group(1) + '/>', object_str)
|
|
# Fix up some stupid XML, see https://github.com/ytdl-org/youtube-dl/issues/1608
|
|
object_str = object_str.replace('<--', '<!--')
|
|
# remove namespace to simplify extraction
|
|
object_str = re.sub(r'(<object[^>]*)(xmlns=".*?")', r'\1', object_str)
|
|
object_str = fix_xml_ampersands(object_str)
|
|
|
|
try:
|
|
object_doc = compat_etree_fromstring(object_str.encode('utf-8'))
|
|
except compat_xml_parse_error:
|
|
return
|
|
|
|
fv_el = find_xpath_attr(object_doc, './param', 'name', 'flashVars')
|
|
if fv_el is not None:
|
|
flashvars = dict(
|
|
(k, v[0])
|
|
for k, v in compat_parse_qs(fv_el.attrib['value']).items())
|
|
else:
|
|
flashvars = {}
|
|
|
|
data_url = object_doc.attrib.get('data', '')
|
|
data_url_params = compat_parse_qs(compat_urllib_parse_urlparse(data_url).query)
|
|
|
|
def find_param(name):
|
|
if name in flashvars:
|
|
return flashvars[name]
|
|
node = find_xpath_attr(object_doc, './param', 'name', name)
|
|
if node is not None:
|
|
return node.attrib['value']
|
|
return data_url_params.get(name)
|
|
|
|
params = {}
|
|
|
|
playerID = find_param('playerID') or find_param('playerId')
|
|
if playerID is None:
|
|
raise ExtractorError('Cannot find player ID')
|
|
params['playerID'] = playerID
|
|
|
|
playerKey = find_param('playerKey')
|
|
# Not all pages define this value
|
|
if playerKey is not None:
|
|
params['playerKey'] = playerKey
|
|
# These fields hold the id of the video
|
|
videoPlayer = find_param('@videoPlayer') or find_param('videoId') or find_param('videoID') or find_param('@videoList')
|
|
if videoPlayer is not None:
|
|
if isinstance(videoPlayer, list):
|
|
videoPlayer = videoPlayer[0]
|
|
videoPlayer = videoPlayer.strip()
|
|
# UUID is also possible for videoPlayer (e.g.
|
|
# http://www.popcornflix.com/hoodies-vs-hooligans/7f2d2b87-bbf2-4623-acfb-ea942b4f01dd
|
|
# or http://www8.hp.com/cn/zh/home.html)
|
|
if not (re.match(
|
|
r'^(?:\d+|[\da-fA-F]{8}-?[\da-fA-F]{4}-?[\da-fA-F]{4}-?[\da-fA-F]{4}-?[\da-fA-F]{12})$',
|
|
videoPlayer) or videoPlayer.startswith('ref:')):
|
|
return None
|
|
params['@videoPlayer'] = videoPlayer
|
|
linkBase = find_param('linkBaseURL')
|
|
if linkBase is not None:
|
|
params['linkBaseURL'] = linkBase
|
|
return cls._make_brightcove_url(params)
|
|
|
|
@classmethod
|
|
def _build_brighcove_url_from_js(cls, object_js):
|
|
# The layout of JS is as follows:
|
|
# customBC.createVideo = function (width, height, playerID, playerKey, videoPlayer, VideoRandomID) {
|
|
# // build Brightcove <object /> XML
|
|
# }
|
|
m = re.search(
|
|
r'''(?x)customBC\.createVideo\(
|
|
.*? # skipping width and height
|
|
["\'](?P<playerID>\d+)["\']\s*,\s* # playerID
|
|
["\'](?P<playerKey>AQ[^"\']{48})[^"\']*["\']\s*,\s* # playerKey begins with AQ and is 50 characters
|
|
# in length, however it's appended to itself
|
|
# in places, so truncate
|
|
["\'](?P<videoID>\d+)["\'] # @videoPlayer
|
|
''', object_js)
|
|
if m:
|
|
return cls._make_brightcove_url(m.groupdict())
|
|
|
|
@classmethod
|
|
def _make_brightcove_url(cls, params):
|
|
return update_url_query(
|
|
'http://c.brightcove.com/services/viewer/htmlFederated', params)
|
|
|
|
@classmethod
|
|
def _extract_brightcove_url(cls, webpage):
|
|
"""Try to extract the brightcove url from the webpage, returns None
|
|
if it can't be found
|
|
"""
|
|
urls = cls._extract_brightcove_urls(webpage)
|
|
return urls[0] if urls else None
|
|
|
|
@classmethod
|
|
def _extract_brightcove_urls(cls, webpage):
|
|
"""Return a list of all Brightcove URLs from the webpage """
|
|
|
|
url_m = re.search(
|
|
r'''(?x)
|
|
<meta\s+
|
|
(?:property|itemprop)=([\'"])(?:og:video|embedURL)\1[^>]+
|
|
content=([\'"])(?P<url>https?://(?:secure|c)\.brightcove.com/(?:(?!\2).)+)\2
|
|
''', webpage)
|
|
if url_m:
|
|
url = unescapeHTML(url_m.group('url'))
|
|
# Some sites don't add it, we can't download with this url, for example:
|
|
# http://www.ktvu.com/videos/news/raw-video-caltrain-releases-video-of-man-almost/vCTZdY/
|
|
if 'playerKey' in url or 'videoId' in url or 'idVideo' in url:
|
|
return [url]
|
|
|
|
matches = re.findall(
|
|
r'''(?sx)<object
|
|
(?:
|
|
[^>]+?class=[\'"][^>]*?BrightcoveExperience.*?[\'"] |
|
|
[^>]*?>\s*<param\s+name="movie"\s+value="https?://[^/]*brightcove\.com/
|
|
).+?>\s*</object>''',
|
|
webpage)
|
|
if matches:
|
|
return list(filter(None, [cls._build_brighcove_url(m) for m in matches]))
|
|
|
|
matches = re.findall(r'(customBC\.createVideo\(.+?\);)', webpage)
|
|
if matches:
|
|
return list(filter(None, [
|
|
cls._build_brighcove_url_from_js(custom_bc)
|
|
for custom_bc in matches]))
|
|
return [src for _, src in re.findall(
|
|
r'<iframe[^>]+src=([\'"])((?:https?:)?//link\.brightcove\.com/services/player/(?!\1).+)\1', webpage)]
|
|
|
|
def _real_extract(self, url):
|
|
url, smuggled_data = unsmuggle_url(url, {})
|
|
|
|
# Change the 'videoId' and others field to '@videoPlayer'
|
|
url = re.sub(r'(?<=[?&])(videoI(d|D)|idVideo|bctid)', '%40videoPlayer', url)
|
|
# Change bckey (used by bcove.me urls) to playerKey
|
|
url = re.sub(r'(?<=[?&])bckey', 'playerKey', url)
|
|
mobj = re.match(self._VALID_URL, url)
|
|
query_str = mobj.group('query')
|
|
query = compat_urlparse.parse_qs(query_str)
|
|
|
|
videoPlayer = query.get('@videoPlayer')
|
|
if videoPlayer:
|
|
# We set the original url as the default 'Referer' header
|
|
referer = query.get('linkBaseURL', [None])[0] or smuggled_data.get('Referer', url)
|
|
video_id = videoPlayer[0]
|
|
if 'playerID' not in query:
|
|
mobj = re.search(r'/bcpid(\d+)', url)
|
|
if mobj is not None:
|
|
query['playerID'] = [mobj.group(1)]
|
|
publisher_id = query.get('publisherId')
|
|
if publisher_id and publisher_id[0].isdigit():
|
|
publisher_id = publisher_id[0]
|
|
if not publisher_id:
|
|
player_key = query.get('playerKey')
|
|
if player_key and ',' in player_key[0]:
|
|
player_key = player_key[0]
|
|
else:
|
|
player_id = query.get('playerID')
|
|
if player_id and player_id[0].isdigit():
|
|
headers = {}
|
|
if referer:
|
|
headers['Referer'] = referer
|
|
player_page = self._download_webpage(
|
|
'http://link.brightcove.com/services/player/bcpid' + player_id[0],
|
|
video_id, headers=headers, fatal=False)
|
|
if player_page:
|
|
player_key = self._search_regex(
|
|
r'<param\s+name="playerKey"\s+value="([\w~,-]+)"',
|
|
player_page, 'player key', fatal=False)
|
|
if player_key:
|
|
enc_pub_id = player_key.split(',')[1].replace('~', '=')
|
|
publisher_id = struct.unpack('>Q', base64.urlsafe_b64decode(enc_pub_id))[0]
|
|
if publisher_id:
|
|
brightcove_new_url = 'http://players.brightcove.net/%s/default_default/index.html?videoId=%s' % (publisher_id, video_id)
|
|
if referer:
|
|
brightcove_new_url = smuggle_url(brightcove_new_url, {'referrer': referer})
|
|
return self.url_result(brightcove_new_url, BrightcoveNewIE.ie_key(), video_id)
|
|
# TODO: figure out if it's possible to extract playlistId from playerKey
|
|
# elif 'playerKey' in query:
|
|
# player_key = query['playerKey']
|
|
# return self._get_playlist_info(player_key[0])
|
|
raise UnsupportedError(url)
|
|
|
|
|
|
class BrightcoveNewIE(AdobePassIE):
|
|
IE_NAME = 'brightcove:new'
|
|
_VALID_URL = r'https?://players\.brightcove\.net/(?P<account_id>\d+)/(?P<player_id>[^/]+)_(?P<embed>[^/]+)/index\.html\?.*(?P<content_type>video|playlist)Id=(?P<video_id>\d+|ref:[^&]+)'
|
|
_TESTS = [{
|
|
'url': 'http://players.brightcove.net/929656772001/e41d32dc-ec74-459e-a845-6c69f7b724ea_default/index.html?videoId=4463358922001',
|
|
'md5': 'c8100925723840d4b0d243f7025703be',
|
|
'info_dict': {
|
|
'id': '4463358922001',
|
|
'ext': 'mp4',
|
|
'title': 'Meet the man behind Popcorn Time',
|
|
'description': 'md5:eac376a4fe366edc70279bfb681aea16',
|
|
'duration': 165.768,
|
|
'timestamp': 1441391203,
|
|
'upload_date': '20150904',
|
|
'uploader_id': '929656772001',
|
|
'formats': 'mincount:20',
|
|
},
|
|
}, {
|
|
# with rtmp streams
|
|
'url': 'http://players.brightcove.net/4036320279001/5d112ed9-283f-485f-a7f9-33f42e8bc042_default/index.html?videoId=4279049078001',
|
|
'info_dict': {
|
|
'id': '4279049078001',
|
|
'ext': 'mp4',
|
|
'title': 'Titansgrave: Chapter 0',
|
|
'description': 'Titansgrave: Chapter 0',
|
|
'duration': 1242.058,
|
|
'timestamp': 1433556729,
|
|
'upload_date': '20150606',
|
|
'uploader_id': '4036320279001',
|
|
'formats': 'mincount:39',
|
|
},
|
|
'params': {
|
|
# m3u8 download
|
|
'skip_download': True,
|
|
}
|
|
}, {
|
|
# playlist stream
|
|
'url': 'https://players.brightcove.net/1752604059001/S13cJdUBz_default/index.html?playlistId=5718313430001',
|
|
'info_dict': {
|
|
'id': '5718313430001',
|
|
'title': 'No Audio Playlist',
|
|
},
|
|
'playlist_count': 7,
|
|
'params': {
|
|
# m3u8 download
|
|
'skip_download': True,
|
|
}
|
|
}, {
|
|
'url': 'http://players.brightcove.net/5690807595001/HyZNerRl7_default/index.html?playlistId=5743160747001',
|
|
'only_matching': True,
|
|
}, {
|
|
# ref: prefixed video id
|
|
'url': 'http://players.brightcove.net/3910869709001/21519b5c-4b3b-4363-accb-bdc8f358f823_default/index.html?videoId=ref:7069442',
|
|
'only_matching': True,
|
|
}, {
|
|
# non numeric ref: prefixed video id
|
|
'url': 'http://players.brightcove.net/710858724001/default_default/index.html?videoId=ref:event-stream-356',
|
|
'only_matching': True,
|
|
}, {
|
|
# unavailable video without message but with error_code
|
|
'url': 'http://players.brightcove.net/1305187701/c832abfb-641b-44eb-9da0-2fe76786505f_default/index.html?videoId=4377407326001',
|
|
'only_matching': True,
|
|
}]
|
|
|
|
@staticmethod
|
|
def _extract_url(ie, webpage):
|
|
urls = BrightcoveNewIE._extract_urls(ie, webpage)
|
|
return urls[0] if urls else None
|
|
|
|
@staticmethod
|
|
def _extract_urls(ie, webpage):
|
|
# Reference:
|
|
# 1. http://docs.brightcove.com/en/video-cloud/brightcove-player/guides/publish-video.html#setvideoiniframe
|
|
# 2. http://docs.brightcove.com/en/video-cloud/brightcove-player/guides/publish-video.html#tag
|
|
# 3. http://docs.brightcove.com/en/video-cloud/brightcove-player/guides/publish-video.html#setvideousingjavascript
|
|
# 4. http://docs.brightcove.com/en/video-cloud/brightcove-player/guides/in-page-embed-player-implementation.html
|
|
# 5. https://support.brightcove.com/en/video-cloud/docs/dynamically-assigning-videos-player
|
|
|
|
entries = []
|
|
|
|
# Look for iframe embeds [1]
|
|
for _, url in re.findall(
|
|
r'<iframe[^>]+src=(["\'])((?:https?:)?//players\.brightcove\.net/\d+/[^/]+/index\.html.+?)\1', webpage):
|
|
entries.append(url if url.startswith('http') else 'http:' + url)
|
|
|
|
# Look for <video> tags [2] and embed_in_page embeds [3]
|
|
# [2] looks like:
|
|
for video, script_tag, account_id, player_id, embed in re.findall(
|
|
r'''(?isx)
|
|
(<video(?:-js)?\s+[^>]*\bdata-video-id\s*=\s*['"]?[^>]+>)
|
|
(?:.*?
|
|
(<script[^>]+
|
|
src=["\'](?:https?:)?//players\.brightcove\.net/
|
|
(\d+)/([^/]+)_([^/]+)/index(?:\.min)?\.js
|
|
)
|
|
)?
|
|
''', webpage):
|
|
attrs = extract_attributes(video)
|
|
|
|
# According to examples from [4] it's unclear whether video id
|
|
# may be optional and what to do when it is
|
|
video_id = attrs.get('data-video-id')
|
|
if not video_id:
|
|
continue
|
|
|
|
account_id = account_id or attrs.get('data-account')
|
|
if not account_id:
|
|
continue
|
|
|
|
player_id = player_id or attrs.get('data-player') or 'default'
|
|
embed = embed or attrs.get('data-embed') or 'default'
|
|
|
|
bc_url = 'http://players.brightcove.net/%s/%s_%s/index.html?videoId=%s' % (
|
|
account_id, player_id, embed, video_id)
|
|
|
|
# Some brightcove videos may be embedded with video tag only and
|
|
# without script tag or any mentioning of brightcove at all. Such
|
|
# embeds are considered ambiguous since they are matched based only
|
|
# on data-video-id and data-account attributes and in the wild may
|
|
# not be brightcove embeds at all. Let's check reconstructed
|
|
# brightcove URLs in case of such embeds and only process valid
|
|
# ones. By this we ensure there is indeed a brightcove embed.
|
|
if not script_tag and not ie._is_valid_url(
|
|
bc_url, video_id, 'possible brightcove video'):
|
|
continue
|
|
|
|
entries.append(bc_url)
|
|
|
|
return entries
|
|
|
|
def _parse_brightcove_metadata(self, json_data, video_id, headers={}):
|
|
title = json_data['name'].strip()
|
|
|
|
formats = []
|
|
for source in json_data.get('sources', []):
|
|
container = source.get('container')
|
|
ext = mimetype2ext(source.get('type'))
|
|
src = source.get('src')
|
|
# https://support.brightcove.com/playback-api-video-fields-reference#key_systems_object
|
|
if ext == 'ism' or container == 'WVM' or source.get('key_systems'):
|
|
continue
|
|
elif ext == 'm3u8' or container == 'M2TS':
|
|
if not src:
|
|
continue
|
|
formats.extend(self._extract_m3u8_formats(
|
|
src, video_id, 'mp4', 'm3u8_native', m3u8_id='hls', fatal=False))
|
|
elif ext == 'mpd':
|
|
if not src:
|
|
continue
|
|
formats.extend(self._extract_mpd_formats(src, video_id, 'dash', fatal=False))
|
|
else:
|
|
streaming_src = source.get('streaming_src')
|
|
stream_name, app_name = source.get('stream_name'), source.get('app_name')
|
|
if not src and not streaming_src and (not stream_name or not app_name):
|
|
continue
|
|
tbr = float_or_none(source.get('avg_bitrate'), 1000)
|
|
height = int_or_none(source.get('height'))
|
|
width = int_or_none(source.get('width'))
|
|
f = {
|
|
'tbr': tbr,
|
|
'filesize': int_or_none(source.get('size')),
|
|
'container': container,
|
|
'ext': ext or container.lower(),
|
|
}
|
|
if width == 0 and height == 0:
|
|
f.update({
|
|
'vcodec': 'none',
|
|
})
|
|
else:
|
|
f.update({
|
|
'width': width,
|
|
'height': height,
|
|
'vcodec': source.get('codec'),
|
|
})
|
|
|
|
def build_format_id(kind):
|
|
format_id = kind
|
|
if tbr:
|
|
format_id += '-%dk' % int(tbr)
|
|
if height:
|
|
format_id += '-%dp' % height
|
|
return format_id
|
|
|
|
if src or streaming_src:
|
|
f.update({
|
|
'url': src or streaming_src,
|
|
'format_id': build_format_id('http' if src else 'http-streaming'),
|
|
'source_preference': 0 if src else -1,
|
|
})
|
|
else:
|
|
f.update({
|
|
'url': app_name,
|
|
'play_path': stream_name,
|
|
'format_id': build_format_id('rtmp'),
|
|
})
|
|
formats.append(f)
|
|
if not formats:
|
|
# for sonyliv.com DRM protected videos
|
|
s3_source_url = json_data.get('custom_fields', {}).get('s3sourceurl')
|
|
if s3_source_url:
|
|
formats.append({
|
|
'url': s3_source_url,
|
|
'format_id': 'source',
|
|
})
|
|
|
|
errors = json_data.get('errors')
|
|
if not formats and errors:
|
|
error = errors[0]
|
|
raise ExtractorError(
|
|
error.get('message') or error.get('error_subcode') or error['error_code'], expected=True)
|
|
|
|
self._sort_formats(formats)
|
|
|
|
for f in formats:
|
|
f.setdefault('http_headers', {}).update(headers)
|
|
|
|
subtitles = {}
|
|
for text_track in json_data.get('text_tracks', []):
|
|
if text_track.get('kind') != 'captions':
|
|
continue
|
|
text_track_url = url_or_none(text_track.get('src'))
|
|
if not text_track_url:
|
|
continue
|
|
lang = (str_or_none(text_track.get('srclang'))
|
|
or str_or_none(text_track.get('label')) or 'en').lower()
|
|
subtitles.setdefault(lang, []).append({
|
|
'url': text_track_url,
|
|
})
|
|
|
|
is_live = False
|
|
duration = float_or_none(json_data.get('duration'), 1000)
|
|
if duration is not None and duration <= 0:
|
|
is_live = True
|
|
|
|
return {
|
|
'id': video_id,
|
|
'title': self._live_title(title) if is_live else title,
|
|
'description': clean_html(json_data.get('description')),
|
|
'thumbnail': json_data.get('thumbnail') or json_data.get('poster'),
|
|
'duration': duration,
|
|
'timestamp': parse_iso8601(json_data.get('published_at')),
|
|
'uploader_id': json_data.get('account_id'),
|
|
'formats': formats,
|
|
'subtitles': subtitles,
|
|
'tags': json_data.get('tags', []),
|
|
'is_live': is_live,
|
|
}
|
|
|
|
def _real_extract(self, url):
|
|
url, smuggled_data = unsmuggle_url(url, {})
|
|
self._initialize_geo_bypass({
|
|
'countries': smuggled_data.get('geo_countries'),
|
|
'ip_blocks': smuggled_data.get('geo_ip_blocks'),
|
|
})
|
|
|
|
account_id, player_id, embed, content_type, video_id = re.match(self._VALID_URL, url).groups()
|
|
|
|
policy_key_id = '%s_%s' % (account_id, player_id)
|
|
policy_key = self._downloader.cache.load('brightcove', policy_key_id)
|
|
policy_key_extracted = False
|
|
store_pk = lambda x: self._downloader.cache.store('brightcove', policy_key_id, x)
|
|
|
|
def extract_policy_key():
|
|
webpage = self._download_webpage(
|
|
'http://players.brightcove.net/%s/%s_%s/index.min.js'
|
|
% (account_id, player_id, embed), video_id)
|
|
|
|
policy_key = None
|
|
|
|
catalog = self._search_regex(
|
|
r'catalog\(({.+?})\);', webpage, 'catalog', default=None)
|
|
if catalog:
|
|
catalog = self._parse_json(
|
|
js_to_json(catalog), video_id, fatal=False)
|
|
if catalog:
|
|
policy_key = catalog.get('policyKey')
|
|
|
|
if not policy_key:
|
|
policy_key = self._search_regex(
|
|
r'policyKey\s*:\s*(["\'])(?P<pk>.+?)\1',
|
|
webpage, 'policy key', group='pk')
|
|
|
|
store_pk(policy_key)
|
|
return policy_key
|
|
|
|
api_url = 'https://edge.api.brightcove.com/playback/v1/accounts/%s/%ss/%s' % (account_id, content_type, video_id)
|
|
headers = {}
|
|
referrer = smuggled_data.get('referrer')
|
|
if referrer:
|
|
headers.update({
|
|
'Referer': referrer,
|
|
'Origin': re.search(r'https?://[^/]+', referrer).group(0),
|
|
})
|
|
|
|
for _ in range(2):
|
|
if not policy_key:
|
|
policy_key = extract_policy_key()
|
|
policy_key_extracted = True
|
|
headers['Accept'] = 'application/json;pk=%s' % policy_key
|
|
try:
|
|
json_data = self._download_json(api_url, video_id, headers=headers)
|
|
break
|
|
except ExtractorError as e:
|
|
if isinstance(e.cause, compat_HTTPError) and e.cause.code in (401, 403):
|
|
json_data = self._parse_json(e.cause.read().decode(), video_id)[0]
|
|
message = json_data.get('message') or json_data['error_code']
|
|
if json_data.get('error_subcode') == 'CLIENT_GEO':
|
|
self.raise_geo_restricted(msg=message)
|
|
elif json_data.get('error_code') == 'INVALID_POLICY_KEY' and not policy_key_extracted:
|
|
policy_key = None
|
|
store_pk(None)
|
|
continue
|
|
raise ExtractorError(message, expected=True)
|
|
raise
|
|
|
|
errors = json_data.get('errors')
|
|
if errors and errors[0].get('error_subcode') == 'TVE_AUTH':
|
|
custom_fields = json_data['custom_fields']
|
|
tve_token = self._extract_mvpd_auth(
|
|
smuggled_data['source_url'], video_id,
|
|
custom_fields['bcadobepassrequestorid'],
|
|
custom_fields['bcadobepassresourceid'])
|
|
json_data = self._download_json(
|
|
api_url, video_id, headers={
|
|
'Accept': 'application/json;pk=%s' % policy_key
|
|
}, query={
|
|
'tveToken': tve_token,
|
|
})
|
|
|
|
if content_type == 'playlist':
|
|
return self.playlist_result(
|
|
[self._parse_brightcove_metadata(vid, vid.get('id'), headers)
|
|
for vid in json_data.get('videos', []) if vid.get('id')],
|
|
json_data.get('id'), json_data.get('name'),
|
|
json_data.get('description'))
|
|
|
|
return self._parse_brightcove_metadata(
|
|
json_data, video_id, headers=headers)
|