Пример #1
0
    def on_first_run(self):
        logging.info("Spawning Miro Guide...")
        guide_url = unicode(app.config.get(prefs.CHANNEL_GUIDE_URL))
        if guide.get_guide_by_url(guide_url) is None:
            allowed_urls = app.config.get(prefs.CHANNEL_GUIDE_ALLOWED_URLS)
            guide.ChannelGuide(guide_url, unicode(allowed_urls).split())

        if self.theme is not None:
            # we have a theme
            new_guides = unicode(
                app.config.get(prefs.ADDITIONAL_CHANNEL_GUIDES)).split()
            for temp_guide in new_guides:
                if guide.get_guide_by_url(temp_guide) is None:
                    guide.ChannelGuide(temp_guide)
            if (((app.config.get(prefs.DEFAULT_CHANNELS_FILE) is not None)
                 and (app.config.get(prefs.THEME_NAME) is not None))):
                importer = opml.Importer()
                filepath = resources.theme_path(
                    app.config.get(prefs.THEME_NAME),
                    app.config.get(prefs.DEFAULT_CHANNELS_FILE))
                if os.path.exists(filepath):
                    importer.import_subscriptions(filepath, show_summary=False)
                else:
                    logging.warn("Theme subscription file doesn't exist: %s",
                                 filepath)
            elif None not in self.pastThemes:
                # We pretend to have run the default theme, and then
                # install the default channels.  XXX: If Miro Guide isn't
                # installed by the theme and it doesn't provide a default
                # set of channels, we'll never install the Miro Guide.

                # This code would install the Miro Guide if it isn't
                # already installed
                # if guide.get_guide_by_url(prefs.CHANNEL_GUIDE_URL.default) is None:
                #     guide.ChannelGuide(prefs.CHANNEL_GUIDE_URL.default)
                self.pastThemes.append(None)
                self._install_default_feeds()
        else:
            # no theme
            self._install_default_feeds()
        signals.system.theme_first_run(self.theme)
Пример #2
0
 def setUp(self):
     StoreDatabaseTest.setUp(self)
     self.feed = feed.Feed(u"dtv:savedsearch/all?q=dogs")
     self.item = item.Item(item.FeedParserValues({'title': u'item1'}),
                           feed_id=self.feed.id)
     self.downloader = downloader.RemoteDownloader(
         u'http://example.com/1/item1/movie.mpeg', self.item)
     self.item.set_downloader(self.downloader)
     self.tab_order = tabs.TabOrder(u'channel')
     self.guide = guide.ChannelGuide(u'http://example.com/')
     self.theme_hist = theme.ThemeHistory()
     self.view_state = widgetstate.ViewState((u'testtype', u'testid', 0))
Пример #3
0
 def on_theme_change(self):
     if self.theme is None: # vanilla Miro
         guide_url = app.config.get(prefs.CHANNEL_GUIDE_URL)
         if guide.get_guide_by_url(guide_url) is None:
             # This happens when the DB is initialized with a theme that
             # doesn't have it's own set of default channels; None is
             # artificially added to the pastThemes lists to prevent the
             # default channels from being added again.  However, it means
             # that we need to add the Miro Guide to the DB ourselves.
             logging.warn('Installing default guide after switch to vanilla Miro')
             guide.ChannelGuide(guide_url,
                                unicode(app.config.get(
                         prefs.CHANNEL_GUIDE_ALLOWED_URLS)).split())
     self.signal_change()
Пример #4
0
    def handle_site(self, site_dict, parent_folder):
        """
        Site subscriptions look like::

            {
            'type': 'site',
            'url': URL of the site
            'title': name of the site (optional),
            }
        """
        assert parent_folder is None, "no folders in site section"
        url = site_dict['url']
        if guide.get_guide_by_url(url) is None:
            new_guide = guide.ChannelGuide(url, [u'*'])
            title = site_dict.get('title')
            if title is not None and title != url:
                new_guide.set_title(title)
            return True
        else:
            return False
Пример #5
0
    def _install_default_feeds(self):
        logging.info("Adding default feeds")
        default_feeds = [
            (u"http://feeds.feedburner.com/tedtalks_video", False),
            (u"http://revision3.com/lifehacker/feed/MP4-hd30", False),
            (u"http://feeds.thisamericanlife.org/talpodcast", False),
            (u"http://feeds.themoth.org/themothpodcast", False),
        ]

        for default in default_feeds:
            self._add_default(default)

        # create example playlist
        default_playlists = [u"Example Playlist"]
        for default in default_playlists:
            try:
                playlist.SavedPlaylist.get_by_title(default)
            except ObjectNotFoundError:
                playlist.SavedPlaylist(_("Example Playlist"))

        default_guides = [
            (u"http://www.youtube.com", u"YouTube", False),
            (u"http://www.archive.org", u"Internet Archive", False),
            (u"http://www.hulu.com/", u"Hulu", False),
            (u"http://video.pbs.org/", u"PBS", False),
            (u"http://www.clearbits.net/", u"ClearBits", False),
            (u"http://www.amara.org/", u"Amara", False),
            (u'http://www.amazon.com/b?_encoding=UTF8&site-redirect=&'
             'node=163856011&tag=pcultureorg-20&linkCode=ur2&camp=1789&'
             'creative=9325', u"Amazon MP3 Store", True),
            (u"http://www.amazon.com/gp/redirect.html?ie=UTF8&location="
             u"http%3A%2F%2Fwww.amazon.com%2Fmobile-apps%2Fb%3Fie%3DUTF8"
             u"%26node%3D2350149011&tag=pcultureorg-20&linkCode=ur2&camp="
             u"1789&creative=9325", u"Amazon Android Store", True),
            (u"http://market.android.com/", u"Google Android Store", True),
            (u"http://www.kqzyfj.com/click-5294129-10364534", u"eMusic", True)
        ]

        if app.debugmode:
            default_guides.append(
                (u"http://bugzilla.pculture.org/enter_bug.cgi?product=Miro",
                 u"Report a Miro Bug", False))
            default_guides.append((
                u"http://develop.participatoryculture.org/index.php/Miro-Current-Release-Testing",
                u"Miro Testing", False))
            default_guides.append((
                u"http://develop.participatoryculture.org/index.php/DeviceSupport/AddingSupport",
                u"Adding a Device", False))

        for default in default_guides:
            try:
                cg = guide.ChannelGuide.get_by_url(default[0])
            except ObjectNotFoundError:
                cg = guide.ChannelGuide(default[0])
                cg.store = default[2]  # before title because title saves the
                # object
                cg.set_title(default[1])

        other_stores = ((
            u'http://www.amazon.fr/gp/redirect.html?ie=UTF8&location=http%3A%2F%2Fwww.amazon.fr%2FT%25C3%25A9l%25C3%25A9charger-Musique-mp3%2Fb%3Fie%3DUTF8%26node%3D77196031&tag=miro0e-21&linkCode=ur2&camp=1642&creative=6746',
            u'Amazon Téléchargements MP3 (FR)'
        ), (
            u'http://www.amazon.de/gp/redirect.html?ie=UTF8&location=http%3A%2F%2Fwww.amazon.de%2FMP3-Musik-Downloads%2Fb%3F_encoding%3DUTF8%26node%3D77195031&site-redirect=de&tag=miro09-21&linkCode=ur2&camp=1638&creative=6742',
            u'Amazon MP3-Downloads (DE/AT/CH)'
        ), (
            u'http://www.amazon.co.jp/MP3-%E3%83%80%E3%82%A6%E3%83%B3%E3%83%AD%E3%83%BC%E3%83%89-%E9%9F%B3%E6%A5%BD%E9%85%8D%E4%BF%A1-DRM%E3%83%95%E3%83%AA%E3%83%BC/b/ref=sa_menu_dmusic1?ie=UTF8&node=2128134051',
            u'Amazon MP3ダウンロード (JP)'
        ), (u'http://www.amazon.co.uk/gp/redirect.html?ie=UTF8&location=http%3A%2F%2Fwww.amazon.co.uk%2FMP3-Music-Download%2Fb%3Fie%3DUTF8%26node%3D77197031&tag=miro00-21&linkCode=ur2&camp=1634&creative=6738',
            u'Amazon MP3 Downloads (UK)'))

        for store_url, name in other_stores:
            try:
                cg = guide.ChannelGuide.get_by_url(store_url)
            except ObjectNotFoundError:
                cg = guide.ChannelGuide(store_url)
                cg.store = cg.STORE_INVISIBLE
                cg.set_title(name)
Пример #6
0
 def setUp(self):
     EventLoopTest.setUp(self)
     self.feed = feed.Feed(u'http://example.com/')
     self.item = item.Item(item.FeedParserValues({}), feed_id=self.feed.id)
     self.guide = guide.ChannelGuide(u'http://example.com/guide/')