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

[voe] Add new extractor #29616

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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 @@ -1484,6 +1484,7 @@
VoxMediaVolumeIE,
VoxMediaIE,
)
from .voe import VOEIE
from .vrt import VRTIE
from .vrak import VrakIE
from .vrv import (
Expand Down
65 changes: 65 additions & 0 deletions youtube_dl/extractor/voe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# coding: utf-8
from __future__ import unicode_literals

dirkf marked this conversation as resolved.
Show resolved Hide resolved
from .common import InfoExtractor
from ..utils import (
dirkf marked this conversation as resolved.
Show resolved Hide resolved
int_or_none,
js_to_json,
url_or_none,
)

dirkf marked this conversation as resolved.
Show resolved Hide resolved

class VOEIE(InfoExtractor):
IE_NAME = 'voe'
IE_DESC = 'VOE.SX'
_VALID_URL = r'https?://voe\.sx/(e/)?(?P<id>[a-z0-9]+)'
dirkf marked this conversation as resolved.
Show resolved Hide resolved
_TEST = {
'url': 'https://voe.sx/e/ng7ja5n5n2y8',
'info_dict': {
'id': 'ng7ja5n5n2y8',
'title': 'md5:a86687fb962742f04652aee19ad34e06',
dirkf marked this conversation as resolved.
Show resolved Hide resolved
'thumbnail': r're:^https?://.*\.jpg$',
'ext': 'm3u8',
},
}
dirkf marked this conversation as resolved.
Show resolved Hide resolved

def _real_extract(self, url):
video_id = self._match_id(url)
dirkf marked this conversation as resolved.
Show resolved Hide resolved

webpage = self._download_webpage(
'https://voe.sx/e/%s' % video_id, video_id)
dirkf marked this conversation as resolved.
Show resolved Hide resolved

sources = self._parse_json(
self._search_regex(r'\bsources\s*=\s*(\{[^}]+\})', webpage, 'sources'),
video_id, transform_source=js_to_json)
dirkf marked this conversation as resolved.
Show resolved Hide resolved

title = self._search_regex(
r'<title>(?:Watch\s+)?(?P<title>.+?)(?:-\s+VOE\s+\|.+)?</title>',
webpage, 'title', group='title')

formats = []

f_url = url_or_none(sources.get('hls'))
dirkf marked this conversation as resolved.
Show resolved Hide resolved
if f_url:
formats.extend(self._extract_m3u8_formats(
f_url, video_id, entry_protocol='m3u8_native', fatal=False))
f_url = url_or_none(sources.get('mp4'))
dirkf marked this conversation as resolved.
Show resolved Hide resolved
if f_url:
formats.append({
'url': f_url,
'ext': 'mp4',
'height': int_or_none(sources.get('video_height')),
})

self._sort_formats(formats)

thumbnail = url_or_none(self._search_regex(
r'(?:VOEPlayer.|data-)poster\s*=\s*(["\'])(?P<thumbnail>(?:(?!\1)\S)+)\1',
dirkf marked this conversation as resolved.
Show resolved Hide resolved
webpage, 'thumbnail', group='thumbnail', default=None))

return {
'id': video_id,
'title': title,
'formats': formats,
'thumbnail': thumbnail,
}