From da9ec3b93246c2b0361796a375e496ebb14d39e9 Mon Sep 17 00:00:00 2001 From: Philipp Hagemeister Date: Wed, 27 Aug 2014 01:44:47 +0200 Subject: [PATCH] [muscivault] Add extractor (Fixes #3593) --- youtube_dl/extractor/__init__.py | 1 + youtube_dl/extractor/common.py | 2 +- youtube_dl/extractor/musicvault.py | 78 ++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 youtube_dl/extractor/musicvault.py diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index 4a1bcfa35..d26454396 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -209,6 +209,7 @@ from .mtv import ( MTVIggyIE, ) from .musicplayon import MusicPlayOnIE +from .musicvault import MusicVaultIE from .muzu import MuzuTVIE from .myspace import MySpaceIE from .myspass import MySpassIE diff --git a/youtube_dl/extractor/common.py b/youtube_dl/extractor/common.py index 9ece30308..b6a7cd5e2 100644 --- a/youtube_dl/extractor/common.py +++ b/youtube_dl/extractor/common.py @@ -114,7 +114,7 @@ class InfoExtractor(object): upload_date: Video upload date (YYYYMMDD). If not explicitly set, calculated from timestamp. uploader_id: Nickname or id of the video uploader. - location: Physical location of the video. + location: Physical location where the video was filmed. subtitles: The subtitle file contents as a dictionary in the format {language: subtitles}. duration: Length of the video in seconds, as an integer. diff --git a/youtube_dl/extractor/musicvault.py b/youtube_dl/extractor/musicvault.py new file mode 100644 index 000000000..329bf61e0 --- /dev/null +++ b/youtube_dl/extractor/musicvault.py @@ -0,0 +1,78 @@ +from __future__ import unicode_literals + +import json +import re + +from .common import InfoExtractor +from ..utils import ( + strip_jsonp, + parse_duration, + unified_strdate, +) + + +class MusicVaultIE(InfoExtractor): + _VALID_URL = r'https?://www\.musicvault\.com/(?P[^/?#]*)/video/(?P[^/?#]*)_(?P[0-9]+)\.html' + _TEST = { + 'url': 'http://www.musicvault.com/the-allman-brothers-band/video/straight-from-the-heart_1010863.html', + 'md5': '2cdbb3ae75f7fb3519821507d2fb3c15', + 'info_dict': { + 'id': '1010863', + 'ext': 'mp4', + 'uploader_id': 'the-allman-brothers-band', + 'title': 'Straight from the Heart', + 'duration': 244, + 'uploader': 'The Allman Brothers Band', + 'thumbnail': 're:^https?://.*/thumbnail/.*', + 'upload_date': '19811216', + 'location': 'Capitol Theatre (Passaic, NJ)', + 'description': 'Listen to The Allman Brothers Band perform Straight from the Heart at Capitol Theatre (Passaic, NJ) on Dec 16, 1981', + } + } + + def _real_extract(self, url): + mobj = re.match(self._VALID_URL, url) + display_id = mobj.group('display_id') + webpage = self._download_webpage(url, display_id) + + thumbnail = self._search_regex( + r'(.*?)', webpage, 'data fields') + uploader = self._html_search_regex( + r'(.*?)', data_div, 'uploader', fatal=False) + title = self._html_search_regex( + r'(.*?)', data_div, 'title') + upload_date = unified_strdate(self._html_search_regex( + r'(.*?)', data_div, 'uploader', fatal=False)) + location = self._html_search_regex( + r'(.*?)', data_div, 'location', fatal=False) + + duration = parse_duration(self._html_search_meta('duration', webpage)) + + VIDEO_URL_TEMPLATE = 'http://cdnapi.kaltura.com/p/%(uid)s/sp/%(wid)s/playManifest/entryId/%(entry_id)s/format/url/protocol/http' + kaltura_id = self._search_regex( + r'