Пример #1
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:
            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):
            standardfeeds_uri = 'http://gdata.youtube.com/feeds/api/standardfeeds'
            if self.locale is not None:
                standardfeeds_uri += "/%s" % self.locale
            standardfeeds_uri += "/%s"
            self.appendFeed('Most Viewed', standardfeeds_uri % 'most_viewed', rootItem)
            self.appendFeed('Top Rated', standardfeeds_uri % 'top_rated', rootItem)
            self.appendFeed('Recently Featured', standardfeeds_uri % 'recently_featured', rootItem)
            self.appendFeed('Watch On Mobile', standardfeeds_uri % 'watch_on_mobile', rootItem)
            self.appendFeed('Most Discussed', standardfeeds_uri % 'most_discussed', rootItem)
            self.appendFeed('Top Favorites', standardfeeds_uri % 'top_favorites', rootItem)
            self.appendFeed('Most Linked', standardfeeds_uri % 'most_linked', rootItem)
            self.appendFeed('Most Responded', standardfeeds_uri % 'most_responded', rootItem)
            self.appendFeed('Most Recent', standardfeeds_uri % 'most_recent', rootItem)

        if len(self.login) > 0:
            userfeeds_uri = 'http://gdata.youtube.com/feeds/api/users/%s/%s'
            self.appendFeed('My Uploads', userfeeds_uri % (self.login,'uploads'), rootItem)
            self.appendFeed('My Favorites', userfeeds_uri % (self.login,'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()
Пример #2
0
    def __init__(self, server, **kwargs):
        AbstractBackendStore.__init__(self, server, **kwargs)

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

        self.language = kwargs.get('language','English')

        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:
            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)

        categoriesItem = Container(rootItem, "All by Categories")
        rootItem.add_child(categoriesItem)
        languagesItem = Container(rootItem, "All by Languages")
        rootItem.add_child(languagesItem)

        self.appendLanguage("Recent Videos", self.language, rootItem, sort='-age', count=15)
        self.appendLanguage("Top Rated", self.language, rootItem, sort='rating', count=15)
        self.appendLanguage("Most Popular", self.language, rootItem, sort='-popular', count=15)


        def gotError(error):
            print "ERROR: %s" % error

        def gotCategories(result):
            if result is None:
                print "Unable to retrieve list of categories"
                return
            data,header = result
            categories = eval(data) # FIXME add some checks to avoid code injection
            for category in categories:
                name = category['name'].encode('ascii', 'strict')
                category_url = category['url'].encode('ascii', 'strict')
                self.appendCategory(name, name, categoriesItem)

        categories_url = "https://www.miroguide.com/api/list_categories"
        d1 = utils.getPage(categories_url)
        d1.addCallbacks(gotCategories, gotError)

        def gotLanguages(result):
            if result is None:
                print "Unable to retrieve list of languages"
                return
            data,header = result
            languages = eval(data) # FIXME add some checks to avoid code injection
            for language in languages:
                name = language['name'].encode('ascii', 'strict')
                language_url = language['url'].encode('ascii', 'strict')
                self.appendLanguage(name, name, languagesItem)

        languages_url = "https://www.miroguide.com/api/list_languages"
        d2 = utils.getPage(languages_url)
        d2.addCallbacks(gotLanguages, gotError)

        self.init_completed()
Пример #3
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()