1
0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2025-07-12 21:36:19 +00:00

[paramount] Add new extractor

This commit is contained in:
Marco Migliori 2017-09-20 18:09:06 +02:00
parent 3b65a6fbf3
commit 5ec34dc1f3
2 changed files with 93 additions and 0 deletions

View File

@ -778,6 +778,7 @@ from .packtpub import (
) )
from .pandatv import PandaTVIE from .pandatv import PandaTVIE
from .pandoratv import PandoraTVIE from .pandoratv import PandoraTVIE
from .paramount import ParamountIE
from .parliamentliveuk import ParliamentLiveUKIE from .parliamentliveuk import ParliamentLiveUKIE
from .patreon import PatreonIE from .patreon import PatreonIE
from .pbs import PBSIE from .pbs import PBSIE

View File

@ -0,0 +1,92 @@
# youtube_dl extractor for www.paramountchannel.it
# copy to youtube_dl/extractors
# add a line to extractors.py:
# from .paramount import ParamountIE
# can use functions from common.py, as _self.function(...)
# also import from other modules
# to test:
# python -m youtube_dl --verbose "http://www.paramountchannel.it/playlist/speciali-paramount-channel/o3gr12/backstage-sigla-paramount/tqvbxd" >| x
# python test/test_download.py TestDownload.test_Paramount
# coding: utf-8
from __future__ import unicode_literals
from .common import InfoExtractor
from ..utils import int_or_none
class ParamountIE(InfoExtractor):
IE_DESC = 'Paramount Channel'
_VALID_URL = r'http://(www\.)?paramountchannel\.it/.*/[0-9a-z]{6}'
_TEST = {
'url': 'http://www.paramountchannel.it/playlist/speciali-paramount-channel/o3gr12/backstage-sigla-paramount/tqvbxd',
'md5': '433666e341a57bb76dc50b6ff87e5c63',
'info_dict': {
'id': '9cb5ad60-9d34-4a9a-99df-157fdd1a5310',
'ext': 'mp4',
'title': 'Speciali video, Paramount Channel',
'description': 'Tutti gli speciali di Paramount Channel: curiosità, approfondimenti e aggiornamenti su film, serie tv e personaggi del cinema.'
}
}
def _obtain_akamaihd_formats(self, url):
if self._downloader.params.get('verbose', False):
listpage = self._download_webpage(url, 'akamaihd format list')
self.to_screen('formats page = %s' % (listpage))
listpage = self._download_xml(url, 'akamaihd format list')
formats = []
for rendition in listpage.findall('./video/item/rendition'):
fmt = {
'width': int_or_none(rendition.get('width')),
'height': int_or_none(rendition.get('height')),
'url': rendition.find('./src').text
}
formats.append(fmt)
return formats
def _real_extract(self, url):
# webpage
webpage = self._download_webpage(url, 'webpage')
id = self._html_search_regex(
r'data-mtv-id="([0-9a-f-]*)"',
webpage, 'id', fatal=False) \
or \
self._html_search_regex(
r'"item_longId" *: *"([0-9a-f-]*)"',
webpage, 'id')
self.to_screen('id = %s' % (id))
uri = self._html_search_regex(
r'data-mtv-uri="([0-9a-z:\.-]*)"',
webpage, 'uri', fatal=False) \
or \
'mgid:arc:video:paramountchannel.it:' + id
self.to_screen('uri = %s' % (uri))
title = self._og_search_title(webpage)
self.to_screen('title = %s' % (title))
# list of formats
server = 'https://mediautilssvcs-a.akamaihd.net'
prefix = '/services/MediaGenerator/'
arguments = 'accountOverride=esperanto.mtvi.com'
listurl = '%s%s%s?%s' % (server, prefix, uri, arguments)
self.to_screen('listurl = %s' % (listurl))
formats = self._obtain_akamaihd_formats(listurl)
if self._downloader.params.get('verbose', False):
self.to_screen('formats = %s' % (formats))
return {
'id': id,
'formats': formats,
'title': title,
'description': self._og_search_description(webpage),
'thumbnail': self._html_search_meta('thumbnail', webpage, fatal=False)
}