summary refs log tree commit diff
diff options
context:
space:
mode:
authoryac <yac@blesmrt.net>2014-11-07 23:19:26 +0100
committeryac <yac@blesmrt.net>2014-11-08 00:13:28 +0100
commit3898c8a7b2835b1632ef0e34481bdf5e006cee2b (patch)
treec27c61d2f662b2fdd06ea10c7066d45e46583ba1
parent29ed169cd63b3665a8fc4140eb698689bf656361 (diff)
downloadyoutube-dl-3898c8a7b2835b1632ef0e34481bdf5e006cee2b.tar.gz
youtube-dl-3898c8a7b2835b1632ef0e34481bdf5e006cee2b.tar.xz
youtube-dl-3898c8a7b2835b1632ef0e34481bdf5e006cee2b.zip
[FreeVideo] Add new extractor
-rw-r--r--youtube_dl/extractor/__init__.py1
-rw-r--r--youtube_dl/extractor/freevideo.py49
2 files changed, 50 insertions, 0 deletions
diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py
index 3c1807f15..db76e8870 100644
--- a/youtube_dl/extractor/__init__.py
+++ b/youtube_dl/extractor/__init__.py
@@ -127,6 +127,7 @@ from .francetv import (
 )
 from .freesound import FreesoundIE
 from .freespeech import FreespeechIE
+from .freevideo import FreeVideoIE
 from .funnyordie import FunnyOrDieIE
 from .gamekings import GamekingsIE
 from .gameone import (
diff --git a/youtube_dl/extractor/freevideo.py b/youtube_dl/extractor/freevideo.py
new file mode 100644
index 000000000..f9716c4c8
--- /dev/null
+++ b/youtube_dl/extractor/freevideo.py
@@ -0,0 +1,49 @@
+from __future__ import unicode_literals
+
+import re
+
+from .common import InfoExtractor
+from ..utils import (
+    ExtractorError,
+)
+
+
+class FreeVideoIE(InfoExtractor):
+    _VALID_URL = r'^http://www.freevideo.cz/vase-videa/(?P<videoid>[^.]+)\.html$'
+
+    _TEST = {
+        'url': 'http://www.freevideo.cz/vase-videa/vysukany-zadecek-22033.html',
+        'file': 'vysukany-zadecek-22033.mp4',
+        'info_dict': {
+            "title": "vysukany-zadecek-22033",
+            "age_limit": 18,
+        }
+    }
+
+    def _real_extract(self, url):
+        mobj = re.match(self._VALID_URL, url)
+        if mobj is None:
+            raise ExtractorError('Invalid search query "%s"' % query)
+
+        video_id = mobj.group('videoid')
+
+        # Get webpage content
+        webpage = self._download_webpage(url, video_id)
+
+        age_limit = self._rta_search(webpage)
+        if age_limit == 0:
+            # interpret 0 as mis-detection since this site is adult-content only.
+            # However, if we get non-0, assume the rtalabel started giving proper
+            # results
+            age_limit = 18
+
+        url = re.search(r'\s+url: "(http://[a-z0-9-]+.cdn.freevideo.cz/stream/.*/video.mp4)"', webpage)
+        if url is None:
+            raise ExtractorError('ERROR: unable to extract video url')
+
+        return {
+            'id': video_id,
+            'url': url.groups()[0],
+            'title': video_id,
+            'age_limit': age_limit,
+        }