Commits

Anonymous committed 9772ac4

Added duration for each video

Comments (0)

Files changed (3)

podcaster/lib/podcast.py

 from podcaster.lib.renderers import RssRenderer, ItunesRenderer
 
 
-VideoFeed = collections.namedtuple('VideoFeed', 'id,guid,title,published,updated')
+VideoFeed = collections.namedtuple('VideoFeed', 'id,guid,title,published,updated,duration')
 UserFeed = collections.namedtuple('UserFeed', 'username,title,videos')
 VideoDetails = collections.namedtuple('VideoDetails', 'id,urls')
 VideoFormat = collections.namedtuple('VideoFormat', 'id,description,extension,content_type,supported')
                     r << r.enclosure(url=request.relative_url('%s/video.%s?id=%s&fmt=%s' % (self.PREFIX, format.extension, v.id, format.id), to_application=True),
                                      length=10,
                                      type=format.content_type)
+                    r << i.duration(v.duration)
     raise HTTPOk(body=r.root.write_xmlstring(xml_declaration=True, encoding='utf-8', pretty_print=True),
                  content_type='text/xml')
 

podcaster/platforms/dailymotion/comp.py

 
     def get_user_feed(self, username, max_results=25):
         ress = restkit.Resource("https://api.dailymotion.com")
-        resp = ress.get("/videos", user=username, fields='id,title,created_time,modified_time').body_string()
+        resp = ress.get("/videos", user=username, fields='id,title,created_time,modified_time,duration').body_string()
         data = json.loads(resp)
 
         videos = []
             guid = '%s:%s' % (username, id)
             published = datetime.fromtimestamp(float(v['created_time']))
             updated = datetime.fromtimestamp(float(v['modified_time']))
-            videos.append(VideoFeed(id, guid, title, published, updated))
+            duration = int(v['duration'])
+            videos.append(VideoFeed(id, guid, title, published, updated, duration))
 
         return UserFeed(username, username, videos)
 

podcaster/platforms/youtube/comp.py

             updated = parse_date(vtag.find('{%s}updated' % ns).text)
             title = vtag.find('{%s}title' % ns).text
             id = vtag.find('{%s}group/{%s}videoid' % (nsmedia, nsyt)).text
-            videos.append(VideoFeed(id, guid, title, published, updated))
+            duration = int(vtag.find('{%s}group/{%s}duration' % (nsmedia, nsyt)).get('seconds'))
+            videos.append(VideoFeed(id, guid, title, published, updated, duration))
         return UserFeed(username.lower(), feed_title, videos)
 
     def get_video_details(self, id):