From 6cb7cf868f0b78e3ca7b3becb81e895af8fd67f2 Mon Sep 17 00:00:00 2001 From: Nicolas Koch Date: Wed, 3 Dec 2014 03:41:04 +0000 Subject: [PATCH 1/2] [TheOffice] add support for theoffice.so --- youtube_dl/extractor/__init__.py | 1 + youtube_dl/extractor/theoffice.py | 48 +++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 youtube_dl/extractor/theoffice.py diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index 8b513ffd1..726ff6ab1 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -1,5 +1,6 @@ from __future__ import unicode_literals +from .theoffice import TheOfficeIE from .abc import ABCIE from .academicearth import AcademicEarthCourseIE from .addanime import AddAnimeIE diff --git a/youtube_dl/extractor/theoffice.py b/youtube_dl/extractor/theoffice.py new file mode 100644 index 000000000..99083c8bc --- /dev/null +++ b/youtube_dl/extractor/theoffice.py @@ -0,0 +1,48 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from .common import InfoExtractor + +import re + + +class TheOfficeIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?theoffice\.so/(?P[0-9]{4}).html$' + _TESTS = [ + { + 'url': 'http://theoffice.so/0304.html', + 'md5': '0abec1d2d91d75b2f331fc426f7fb0d4', + 'info_dict': { + 'id': '0304', + 'ext': 'mp4', + 'title': 'Episode 4: Grief Counseling', + }, + }, + { + 'url': 'http://theoffice.so/0607.html', + 'md5': '1b2d4dab2e1af3f855c5f55a63a1ba70', + 'info_dict': { + 'id': '0607', + 'ext': 'mp4', + 'title': 'Episode 7: The Lover', + } + }, + ] + + def _real_extract(self, url): + mobj = re.match(self._VALID_URL, url) + video_id = mobj.group('id') + info_page = self._download_webpage('http://www.theoffice.so/index.html', video_id, 'Requesting video overview page') + + # look which link on the info page refers to our video + pattern = r'(.*?)' + title = self._html_search_regex(pattern, info_page, 'title') + + # the videos are hosted statically on a single server + url = 'http://94.242.228.164/T' + video_id + '.mp4' + return { + 'id': video_id, + 'title': title, + 'url': url, + 'ext': 'mp4' + } From 27866d211d31ecdcfa57735bb731d0ec40178778 Mon Sep 17 00:00:00 2001 From: Nicolas Koch Date: Wed, 3 Dec 2014 03:47:38 +0000 Subject: [PATCH 2/2] fix import order --- youtube_dl/extractor/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index 726ff6ab1..61c523acd 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -1,6 +1,5 @@ from __future__ import unicode_literals -from .theoffice import TheOfficeIE from .abc import ABCIE from .academicearth import AcademicEarthCourseIE from .addanime import AddAnimeIE @@ -392,6 +391,7 @@ from .telemb import TeleMBIE from .tenplay import TenPlayIE from .testurl import TestURLIE from .tf1 import TF1IE +from .theoffice import TheOfficeIE from .theonion import TheOnionIE from .theplatform import ThePlatformIE from .thesixtyone import TheSixtyOneIE