Ejemplo n.º 1
0
        def gotPlaylists(playlist_video_feed):
           if playlist_video_feed is None:
               self.warning("Unable to retrieve subscriptions feed")
               return
           for entry in playlist_video_feed.entry:
               type = entry.GetSubscriptionType()
               title = entry.title.text
               uri = entry.id.text
               name = "[%s] %s" % (type,title)

               item = LazyContainer(parent, name, uri, self.refresh, self.retrieveSubscriptionFeedItems, uri=uri)
               item.parent = parent
               parent.add_child(item, external_id=uri)
Ejemplo n.º 2
0
        def gotPlaylists(playlist_video_feed):
            if playlist_video_feed is None:
                self.warning('Unable to retrieve subscriptions feed')
                return
            for entry in playlist_video_feed.entry:
                type = entry.GetSubscriptionType()
                title = entry.title.text
                uri = entry.id.text
                name = f'[{type}] {title}'

                item = LazyContainer(parent, name, uri, self.refresh,
                                     self.retrieveSubscriptionFeedItems,
                                     uri=uri)
                item.parent = parent
                parent.add_child(item, external_id=uri)
Ejemplo n.º 3
0
 def appendFeed(self, name, feed_uri, parent):
     item = LazyContainer(parent,
                          name,
                          None,
                          self.refresh,
                          self.retrieveFeedItems,
                          feed_uri=feed_uri)
     parent.add_child(item, external_id=feed_uri)
Ejemplo n.º 4
0
        def gotPlaylists(playlist_video_feed):
            if playlist_video_feed is None:
                self.warning('Unable to retrieve playlists feed')
                return
            for playlist_video_entry in playlist_video_feed.entry:
                title = playlist_video_entry.title.text
                playlist_id = playlist_video_entry.id.text.split('/')[
                    -1]  # FIXME find better way to retrieve the playlist ID

                item = LazyContainer(
                    parent, title, playlist_id, self.refresh,
                    self.retrievePlaylistFeedItems,
                    playlist_id=playlist_id)
                parent.add_child(item, external_id=playlist_id)
Ejemplo n.º 5
0
    def __init__(self, server, **kwargs):
        AbstractBackendStore.__init__(self, server, **kwargs)

        self.name = kwargs.get('name', 'YouTube')

        self.login = kwargs.get('userid', kwargs.get('login', ''))
        self.password = kwargs.get('password', '')
        self.locale = kwargs.get('location', None)
        self.quality = kwargs.get('quality', 'sd')
        self.showStandardFeeds = \
            (kwargs.get('standard_feeds', 'True') in [
                'Yes', 'yes', 'true', 'True', '1'])
        self.refresh = int(kwargs.get('refresh', 60)) * 60
        self.proxy_mode = kwargs.get('proxy_mode', 'redirect')
        self.cache_directory = kwargs.get('cache_directory',
                                          '/tmp/coherence-cache')
        try:
            if self.proxy_mode != 'redirect':
                os.mkdir(self.cache_directory)
        except Exception:
            pass
        self.cache_maxsize = kwargs.get('cache_maxsize', 100000000)
        self.buffer_size = kwargs.get('buffer_size', 750000)

        rootItem = Container(None, self.name)
        self.set_root_item(rootItem)

        if self.showStandardFeeds:
            base_uri = 'http://gdata.youtube.com/feeds/api/standardfeeds'
            if self.locale is not None:
                base_uri += f'/{self.locale}'
            self.appendFeed(
                'Most Viewed', base_uri + '/most_viewed', rootItem)
            self.appendFeed(
                'Top Rated', base_uri + '/top_rated', rootItem)
            self.appendFeed(
                'Recently Featured', base_uri + '/recently_featured', rootItem)
            self.appendFeed(
                'Watch On Mobile', base_uri + '/watch_on_mobile', rootItem)
            self.appendFeed(
                'Most Discussed', base_uri + '/most_discussed', rootItem)
            self.appendFeed(
                'Top Favorites', base_uri + '/top_favorites', rootItem)
            self.appendFeed(
                'Most Linked', base_uri + '/most_linked', rootItem)
            self.appendFeed(
                'Most Responded', base_uri + '/most_responded', rootItem)
            self.appendFeed(
                'Most Recent', base_uri + '/most_recent', rootItem)

        if len(self.login) > 0:
            user_uri = f'http://gdata.youtube.com/feeds/api/users/{self.login}'
            self.appendFeed('My Uploads', user_uri + '/uploads', rootItem)
            self.appendFeed('My Favorites', user_uri + '/favorites', rootItem)
            playlistsItem = LazyContainer(
                rootItem, 'My Playlists', None,
                self.refresh,
                self.retrievePlaylistFeeds)
            rootItem.add_child(playlistsItem)
            subscriptionsItem = LazyContainer(
                rootItem, 'My Subscriptions',
                None, self.refresh,
                self.retrieveSubscriptionFeeds)
            rootItem.add_child(subscriptionsItem)

        self.init_completed()