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

[sonosfm] Add new extractor #17891

Closed
wants to merge 1 commit 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
1 change: 1 addition & 0 deletions youtube_dl/extractor/extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,7 @@
SmotriBroadcastIE,
)
from .snotr import SnotrIE
from .sonosfm import SonosFmIE
from .sohu import SohuIE
from .sonyliv import SonyLIVIE
from .soundcloud import (
Expand Down
39 changes: 39 additions & 0 deletions youtube_dl/extractor/sonosfm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# coding: utf-8
from __future__ import unicode_literals

from .common import InfoExtractor


class SonosFmIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?sonus\.fm/on-demand/(?P<id>[0-9_a-z-]+)'
_TEST = {
'url': 'http://sonus.fm/on-demand/4033_reifeprufung-dj-contest-live-stream',
'md5': 'fd2386c8477754087ddd4c905422e192',
'info_dict': {
'id': '4033_reifeprufung-dj-contest-live-stream',
'ext': 'm3u8',
'title': 'Reifeprüfung DJ Contest LIVE Stream - sonus.fm',
'thumbnail': 'http://sonus.fm/img/shows/311385913007047.jpg',
'description': 'md5:befa45b98c2952225effd2d7de806c38'
}
}

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

player_url = self._html_search_regex(r'<meta property=\"og:video\" content=\"(.*)\"/>', webpage, 'player_url')
Copy link
Collaborator

Choose a reason for hiding this comment

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

_og_search_video_url.

file_name = self._search_regex(
r'https://www.sonus.fm/jwplayer/player.swf\?file=mp4:([A-z0-9-.]*)&',
Copy link
Collaborator

Choose a reason for hiding this comment

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

  1. Escape dots.
  2. Do not capture empty string.
  3. Relax regex.

player_url,
'file_name'
).replace('.mov', '.mp4')
m3u8_playlist = 'http://www.sonus.fm:1935/vod/mp4:{file}/playlist.m3u8'.format(file=file_name)

return {
'id': video_id,
'title': self._html_search_regex(r'<title>(.+?)</title>', webpage, 'title'),
'description': self._og_search_description(webpage),
'url': m3u8_playlist,
Copy link
Collaborator

Choose a reason for hiding this comment

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

_extract_m3u8_formats.

'thumbnail': self._html_search_regex(r'<meta property=\"og:image\" content=\"(.*)\"\s?/>', webpage, 'image')
Copy link
Collaborator

Choose a reason for hiding this comment

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

  1. _og_search_thumbnail.
  2. Read coding conventions on optional meta fields.

}