예제 #1
0
    def _parse_podcast(self, url, add_to_db=False):
        try:
            url = url.replace('itpc://', 'http://')

            self._set_status(_('Loading %s...') % url)
            d = fp.parse(url)
            entries = d['entries']

            title = d['feed']['title']

            if add_to_db:
                self._add_to_db(url, title)

            pl = playlist.Playlist(md5(url).hexdigest())

            tracks = []
            for e in entries:
                for link in e.get('enclosures', []):
                    tr = trax.Track(link.href)
                    date = e['updated_parsed']
                    tr.set_tag_raw('artist', title)
                    tr.set_tag_raw('title', '%s: %s' % (e['title'], link.href.split('/')[-1]))
                    tr.set_tag_raw('date', "%d-%02d-%02d" %
                            (date.tm_year, date.tm_mon, date.tm_mday))
                    tracks.append(tr)

            pl.extend(tracks)
            self._set_status('')

            self._open_podcast(pl, title)
            self.podcast_playlists.save_playlist(pl, overwrite=True)
        except:
            traceback.print_exc()
            self._set_status(_('Error loading podcast.'), 2)
예제 #2
0
def _create_search_playlist(name, search_string, exaile):
    '''Create a playlist based on a search string'''
    tracks = [x.track for x in search.search_tracks_from_string(exaile.collection, search_string)]

    # create the playlist
    pl = playlist.Playlist(name, tracks)
    main.get_playlist_notebook().create_tab_from_playlist(pl)
예제 #3
0
파일: queue.py 프로젝트: thiblahute/exaile
 def _saveas_playlist_cb(widget, name, page, context):
     exaile = main.exaile()
     name = dialogs.ask_for_playlist_name(exaile.playlists, "")
     if name is not None:
         pl = playlist.Playlist(name, page.playlist[:])
         exaile.playlists.save_playlist(pl)
         page.container.create_tab_from_playlist(pl)
예제 #4
0
 def on_saveas(self):
     exaile = main.exaile()
     name = dialogs.ask_for_playlist_name(
         exaile.gui.main.window, exaile.playlists)
     if name is not None:
         pl = playlist.Playlist(name, self.playlist[:])
         exaile.playlists.save_playlist(pl)
         self.plcontainer.create_tab_from_playlist(pl)
예제 #5
0
파일: radio.py 프로젝트: hayate891/exaile
    def _do_add_playlist(self, name, uri):
        from xl import playlist, trax
        if playlist.is_valid_playlist(uri):
            pl = playlist.import_playlist(uri)
            pl.name = name
        else:
            pl = playlist.Playlist(name)
            tracks = trax.get_tracks_from_uri(uri)
            pl.extend(tracks)

        self.playlist_manager.save_playlist(pl)
        self._add_to_tree(pl)
예제 #6
0
 def get_playlist(self):
     tr = trax.Track()
     tr['title'] = 'Test Track'
     pl = playlist.Playlist('Test Playlist')
     pl.add_tracks([tr])
     return pl
예제 #7
0
    def add_new_playlist(self, tracks=[], name=None):
        """
            Adds a new playlist to the list of playlists. If name is
            None or the name conflicts with an existing playlist, the
            user will be queried for a new name.

            Returns the name of the new playlist, or None if it was
            not added.
        """
        if name:
            if name in self.playlist_manager.playlists:
                name = dialogs.ask_for_playlist_name(
                    self.get_panel().get_toplevel(), self.playlist_manager,
                    name)
        else:
            if tracks:
                artists = []
                composers = []
                albums = []

                for track in tracks:
                    artist = track.get_tag_display('artist',
                                                   artist_compilations=False)

                    if artist is not None:
                        artists += [artist]

                    composer = track.get_tag_display('composer',
                                                     artist_compilations=False)

                    if composer is not None:
                        composers += composer

                    album = track.get_tag_display('album')

                    if album is not None:
                        albums += album

                artists = list(set(artists))[:3]
                composers = list(set(composers))[:3]
                albums = list(set(albums))[:3]

                if len(artists) > 0:
                    name = artists[0]

                    if len(artists) > 2:
                        # TRANSLATORS: Playlist title suggestion with more
                        # than two values
                        name = _('%(first)s, %(second)s and others') % {
                            'first': artists[0],
                            'second': artists[1],
                        }
                    elif len(artists) > 1:
                        # TRANSLATORS: Playlist title suggestion with two values
                        name = _('%(first)s and %(second)s') % {
                            'first': artists[0],
                            'second': artists[1],
                        }
                elif len(composers) > 0:
                    name = composers[0]

                    if len(composers) > 2:
                        # TRANSLATORS: Playlist title suggestion with more
                        # than two values
                        name = _('%(first)s, %(second)s and others') % {
                            'first': composers[0],
                            'second': composers[1],
                        }
                    elif len(composers) > 1:
                        # TRANSLATORS: Playlist title suggestion with two values
                        name = _('%(first)s and %(second)s') % {
                            'first': composers[0],
                            'second': composers[1],
                        }
                elif len(albums) > 0:
                    name = albums[0]

                    if len(albums) > 2:
                        # TRANSLATORS: Playlist title suggestion with more
                        # than two values
                        name = _('%(first)s, %(second)s and others') % {
                            'first': albums[0],
                            'second': albums[1],
                        }
                    elif len(albums) > 1:
                        # TRANSLATORS: Playlist title suggestion with two values
                        name = _('%(first)s and %(second)s') % {
                            'first': albums[0],
                            'second': albums[1],
                        }
                else:
                    name = ''

            name = dialogs.ask_for_playlist_name(
                self.get_panel().get_toplevel(), self.playlist_manager, name)

        if name is not None:
            # Create the playlist from all of the tracks
            new_playlist = xl_playlist.Playlist(name)
            new_playlist.extend(tracks)
            # We are adding a completely new playlist with tracks so we save it
            self.playlist_manager.save_playlist(new_playlist)

        return name
예제 #8
0
 def _open_podcast(self, pl, title):
     new_pl = playlist.Playlist(title)
     new_pl.extend(pl)
     main.get_playlist_notebook().create_tab_from_playlist(new_pl)