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

[narando] add new extractor #18268

Closed
wants to merge 14 commits into from
Closed
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
4 changes: 4 additions & 0 deletions youtube_dl/extractor/extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,10 @@
MyviEmbedIE,
)
from .myvidster import MyVidsterIE
from .narando import (
NarandoIE,
NarandoArticleIE,
)
from .nationalgeographic import (
NationalGeographicVideoIE,
NationalGeographicIE,
Expand Down
81 changes: 81 additions & 0 deletions youtube_dl/extractor/narando.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# coding: utf-8
from __future__ import unicode_literals

from .common import InfoExtractor


class NarandoIE(InfoExtractor):
IE_NAME = 'narando'
_THUMB_SIZES = ('small', 'square', 'medium', 'big', 'original')
_VALID_URL = r'https?://narando\.com/widget\?.*?r=(?P<id>\w+)&?'
_TEST = {
'url': 'https://narando.com/widget?r=b2t4t789kxgy9g7ms4rwjvvw',
'md5': 'd20f671f0395bab8f8285d1f6e8f965e',
'info_dict': {
'id': 'b2t4t789kxgy9g7ms4rwjvvw',
'ext': 'mp3',
'title': 'An ihrem Selbstlob erkennt man sie',
}
}

def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
title = self._html_search_regex(r'<span class="clip-title">(.+?)</span>', webpage, 'title')
download_url = self._html_search_regex(r'<div class="stream_url hide">(.+)</div>', webpage, 'download_url')
thumbnail_id = self._html_search_regex(r'article_picture\/(.+?)\/small\.jpg', webpage, 'thumbnail_id', fatal=False)
thumbnail_dict = []
thumb_id = 0
for size in self._THUMB_SIZES:
thumbnail_dict.append({
'url': 'https://static.narando.com/article_picture/' + thumbnail_id + '/' + size + '.jpg',
'id': size,
'preference': thumb_id,
})
thumb_id += 1
return {
'id': video_id,
'title': title,
'url': download_url,
'vcodec': 'none',
'thumbnails': thumbnail_dict,
}
ealgase marked this conversation as resolved.
Show resolved Hide resolved


class NarandoArticleIE(InfoExtractor):
IE_NAME = "narando:article"
_VALID_URL = r'https?://(?:www\.)?narando\.com/(articles|r)/(?P<id>.+)'
_TESTS = [
{
'url': 'https://narando.com/articles/an-ihrem-selbstlob-erkennt-man-sie',
'md5': 'd20f671f0395bab8f8285d1f6e8f965e',
'info_dict': {
'id': 'b2t4t789kxgy9g7ms4rwjvvw',
'ext': 'mp3',
'title': 'An ihrem Selbstlob erkennt man sie',
}
},
{
'url': 'https://narando.com/r/b2t4t789kxgy9g7ms4rwjvvw', # alternate URL format
'md5': 'd20f671f0395bab8f8285d1f6e8f965e',
'info_dict': {
'id': 'b2t4t789kxgy9g7ms4rwjvvw',
'ext': 'mp3',
'title': 'An ihrem Selbstlob erkennt man sie',
}
}
]

def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
title = self._html_search_regex(r'<h1 class="visible-xs h3">(.+?)</h1>', webpage, 'title')
player_id = self._html_search_regex(r'https://narando.com/r/(.+?)\"', webpage, 'player_id')
url_result = 'https://narando.com/widget?r=' + player_id

return {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

url_result.

'id': player_id,
'title': title,
'url': url_result,
'_type': 'url',
}