Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[globalnews] Add new extractor #13431

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions youtube_dl/extractor/extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@
from .giantbomb import GiantBombIE
from .giga import GigaIE
from .glide import GlideIE
from .globalnews import GlobalNewsIE
from .globo import (
GloboIE,
GloboArticleIE,
Expand Down
56 changes: 56 additions & 0 deletions youtube_dl/extractor/globalnews.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# coding: utf-8
from __future__ import unicode_literals

from .common import InfoExtractor


class GlobalNewsIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?globalnews\.ca/video/(?:embed/)?(?P<id>\d+)'
_TEST = {
'url': "http://globalnews.ca/video/2066998/focus-montreal-doulia-hamad-and-nebras-m-warsi",
'info_dict': {
'title': "Focus Montreal: Doulia Hamad and Nebras M. Warsi",
'id': '469088323881',
'ext': 'mp4',
'upload_date': '20150621',
'description': 'md5:2998a348701a91ddf70fbb773b016a7f',
'timestamp': 1434908705,
'uploader': 'SHWM-NEW',
},
}

def _real_extract(self, url):
display_id = self._match_id(url)
webpage = self._download_webpage(
url,
display_id
)

account_id = self._search_regex((
r'svp\.platformAccount\s*=\s*(["\']+)(?P<account>.+?)\1',
r'svp\.(?:videoSMILUrl|metadataUrl)\s*=\s*(["\']+).*?theplatform[^/]+/(?:s|f)/(?P<account>[^/]+?/).*?\1'),
webpage,
'account id',
group='account'
)[:-1]
feed_id = self._search_regex((
r'svp\.feedId\s*=\s*(["\']+)(?P<feed>.+?)\1',
r'svp\.metadataUrl\s*=\s*(["\']+).*?theplatform[^/]+/f/[^/]+?/(?P<feed>[^?/&#]+).*?\1'),
webpage,
'feed id',
group='feed'
)
platform_id = self._search_regex((
r'<span[^>]+class=(["\'])[^\'"]+?the_platform_id_(?P<platformId>\d+)\1\s+?data-v_count_id=\1\2\1',
r'svp\.setContentId\(\s*([\'"])(?P<platformId>\d+)\1.*?loadCallback'),
webpage,
'platform id',
group='platformId'
)

return {
'display_id': display_id,
'_type': 'url_transparent',
'url': 'http://feed.theplatform.com/f/%s/%s?byId=%s' % (account_id, feed_id, platform_id),
'ie_key': 'ThePlatformFeed'
}
10 changes: 10 additions & 0 deletions youtube_dl/extractor/theplatform.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,16 @@ def _extract_feed_info(self, provider_id, feed_id, filter_query, video_id, custo
if first_video_id is None:
first_video_id = cur_video_id
duration = float_or_none(item.get('plfile$duration'))
if item.get('plfile$assetTypes') is None:
query = {
'mbr': 'true',
'formats': item['plfile$format'],
}
cur_formats, cur_subtitles = self._extract_theplatform_smil(update_url_query(
main_smil_url or smil_url, query), video_id, 'Downloading SMIL data')
formats.extend(cur_formats)
subtitles = self._merge_subtitles(subtitles, cur_subtitles)
continue
for asset_type in item['plfile$assetTypes']:
if asset_type in asset_types:
continue
Expand Down