From dd64d69b7b532f58d80438c569e82357e370e12b Mon Sep 17 00:00:00 2001 From: Cloud Chagnon Date: Thu, 11 Jan 2018 23:13:55 -0700 Subject: [PATCH] [weeklybeats] Add new extractor weeklybeats --- youtube_dl/extractor/extractors.py | 3 ++- youtube_dl/extractor/weeklybeats.py | 35 +++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 youtube_dl/extractor/weeklybeats.py diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index 37624d37a..b82ba32c1 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -1299,8 +1299,9 @@ from .webofstories import ( WebOfStoriesIE, WebOfStoriesPlaylistIE, ) +from .weeklybeats import WeeklyBeatsIE from .weibo import ( - WeiboIE, + WeiboIE, WeiboMobileIE ) from .weiqitv import WeiqiTVIE diff --git a/youtube_dl/extractor/weeklybeats.py b/youtube_dl/extractor/weeklybeats.py new file mode 100644 index 000000000..7e81572d0 --- /dev/null +++ b/youtube_dl/extractor/weeklybeats.py @@ -0,0 +1,35 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from .common import InfoExtractor + + +class WeeklyBeatsIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?weeklybeats\.com/(.+)/music/(.+)' + _TEST = { + 'url': 'https://weeklybeats.com/pulsn/music/week-1-bass-drop', + 'md5': '03465d0fa355147822d2ba1100a82c7c', + 'info_dict': { + 'id': 'week-1-bass-drop', + 'ext': 'mp3', + 'title': 'Week 1: Bass Drip ', + 'url': 'https://weeklybeats.s3.amazonaws.com/music/2012/pulsn_weeklybeats-2012_1_week-1-bass-drop.mp3', + 'uploader': 'pulsn', + 'description': 'A blend of IDM noises mixed with Berlin styled arps and ambient pads.' + } + } + + def _real_extract(self, url): + video_id = self._search_regex(r'https://weeklybeats.com/[^/]+/music/([^/]*)/?', url, 'video_id') + print(video_id) + webpage = self._download_webpage(url, video_id) + + # TODO more code goes here, for example ... + return { + 'id': video_id, + 'title': self._search_regex(r']+property="og:title"[^>]+content="([^\"]+)"[^>]*>', webpage, 'title', fatal=False), + 'description': self._search_regex(r']+property="og:description"[^>]+content="([^\"]*)"[^>]*>', webpage, 'description', fatal=False), + 'uploader': self._search_regex(r']+class="form_popular_tags ?artist"[^>]*>View by:([^<]+)<', webpage, 'uploader', fatal=False), + 'url': self._search_regex(r'mp3: \'([^\']+)\'', webpage, 'url') + # TODO more properties (see youtube_dl/extractor/common.py) + }