[muenchentv] Move live title generation to common
authorPhilipp Hagemeister <phihag@phihag.de>
Sun, 28 Sep 2014 06:53:52 +0000 (08:53 +0200)
committerPhilipp Hagemeister <phihag@phihag.de>
Sun, 28 Sep 2014 06:53:52 +0000 (08:53 +0200)
youtube_dl/extractor/common.py
youtube_dl/extractor/muenchentv.py

index 60cab6f4e731df18a7e828d64cf5f471ccda9e25..403791e6b7252f2f7432d5aa98d9aab8f8a7da55 100644 (file)
@@ -1,6 +1,7 @@
 from __future__ import unicode_literals
 
 import base64
+import datetime
 import hashlib
 import json
 import netrc
@@ -705,6 +706,12 @@ class InfoExtractor(object):
         self._sort_formats(formats)
         return formats
 
+    def _live_title(self, name):
+        """ Generate the title for a live video """
+        now = datetime.datetime.now()
+        now_str = now.strftime("%Y-%m-%d %H:%M")
+        return name + ' ' + now_str
+
 
 class SearchInfoExtractor(InfoExtractor):
     """
index 3a938861bbfb38b70ee9ad18621769af8bf9c367..7cb6749bee4eda9b8767fa6d1eb246b8eb6f56e3 100644 (file)
@@ -1,7 +1,6 @@
 # coding: utf-8
 from __future__ import unicode_literals
 
-import datetime
 import json
 
 from .common import InfoExtractor
@@ -33,9 +32,7 @@ class MuenchenTVIE(InfoExtractor):
         display_id = 'live'
         webpage = self._download_webpage(url, display_id)
 
-        now = datetime.datetime.now()
-        now_str = now.strftime("%Y-%m-%d %H:%M")
-        title = self._og_search_title(webpage) + ' ' + now_str
+        title = self._live_title(self._og_search_title(webpage))
 
         data_js = self._search_regex(
             r'(?s)\nplaylist:\s*(\[.*?}\]),related:',