當前位置: 首頁>>代碼示例>>Python>>正文


Python Radios.get_url方法代碼示例

本文整理匯總了Python中lollypop.radios.Radios.get_url方法的典型用法代碼示例。如果您正苦於以下問題:Python Radios.get_url方法的具體用法?Python Radios.get_url怎麽用?Python Radios.get_url使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在lollypop.radios.Radios的用法示例。


在下文中一共展示了Radios.get_url方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: restore_state

# 需要導入模塊: from lollypop.radios import Radios [as 別名]
# 或者: from lollypop.radios.Radios import get_url [as 別名]
 def restore_state(self):
     """
         Restore player state
     """
     if Lp().settings.get_value('save-state'):
         track_id = Lp().settings.get_value('track-id').get_int32()
         playlist_ids = Lp().settings.get_value('playlist-ids')
         if playlist_ids and playlist_ids[0] == Type.RADIOS:
             radios = Radios()
             track = Track()
             name = radios.get_name(track_id)
             url = radios.get_url(name)
             track.set_radio(name, url)
             self.load(track)
         elif Lp().tracks.get_path(track_id) != "":
             track = Track(track_id)
             self._load_track(track)
             if playlist_ids:
                 try:
                     pids = []
                     for playlist_id in playlist_ids:
                         pids.append(int(playlist_id))
                     track_ids = []
                     for playlist_id in playlist_ids:
                         if playlist_id == Type.POPULARS:
                             tracks = Lp().tracks.get_populars()
                         elif playlist_id == Type.RECENTS:
                             tracks = Lp().tracks.get_recently_listened_to()
                         elif playlist_id == Type.NEVER:
                             tracks = Lp().tracks.get_never_listened_to()
                         elif playlist_id == Type.RANDOMS:
                             tracks = Lp().tracks.get_randoms()
                         else:
                             tracks = Lp().playlists.get_tracks_ids(
                                                                playlist_id)
                         for track_id in tracks:
                             if track_id not in track_ids:
                                 track_ids.append(track_id)
                         self.populate_user_playlist_by_tracks(track_ids,
                                                               pids)
                 except:
                     pass  # User set non int in gsettings
             else:
                 self._albums = Lp().artists.get_albums(
                                                     track.album_artist_ids)
                 for album_id in self._albums:
                     self.context.genre_ids[album_id] = []
                     self.context.artist_ids[album_id] = []
             self.set_next()
             self.set_prev()
             if Lp().settings.get_value('repeat'):
                 self.context.next = NextContext.NONE
             else:
                 self.context.next = NextContext.STOP_ALL
             self.emit('current-changed')
         else:
             print("Player::restore_state(): track missing")
開發者ID:thinkking,項目名稱:lollypop,代碼行數:59,代碼來源:player.py

示例2: RadiosView

# 需要導入模塊: from lollypop.radios import Radios [as 別名]
# 或者: from lollypop.radios.Radios import get_url [as 別名]

#.........這裏部分代碼省略.........
        for (name, url) in manager.get():
            radios_name.append(name)

        # Get currents widget less removed
        for child in self._radiobox.get_children():
            widget = child.get_child()
            if widget.get_name() not in radios_name:
                old_widget = widget
                old_child = child
            else:
                currents.append(widget.get_name())

        # Add the new radio
        for name in radios_name:
            if name not in currents:
                new_name = name
                break

        # Rename widget
        if new_name is not None:
            if old_widget is not None:
                old_widget.set_name(new_name)
            else:
                radios = [new_name]
                self._show_stack(radios)
        # Delete widget
        elif old_widget is not None:
            self._radiobox.remove(old_child)
            old_widget.destroy()
            if not self._radiobox.get_children():
                self._show_stack([])

        # Update player state based on current view
        radios = []
        for child in self._radiobox.get_children():
            widget = child.get_child()
            name = widget.get_name()
            url = manager.get_url(name)
            radios.append((name, url))
        Lp().player.set_radios(radios)
        if Lp().player.current_track.id == Type.RADIOS:
            Lp().player.set_next()  # We force next update
            Lp().player.set_prev()  # We force prev update

    def _on_logo_changed(self, player, name):
        """
            Update radio logo
            @param player as Plyaer
            @param name as string
        """
        for child in self._radiobox.get_children():
            widget = child.get_child()
            if widget.get_name() == name:
                widget.update_cover()

    def _show_stack(self, radios):
        """
            Switch empty/radios view based on radios
            @param [radio names as string]
        """
        if radios:
            self._stack.set_visible_child(self._scrolled)
            self._add_radios(radios, True)
        else:
            self._stack.set_visible_child(self._empty)

    def _add_radios(self, radios, first=False):
        """
            Pop a radio and add it to the view,
            repeat operation until radio list is empty
            @param [radio names as string]
            @param first as bool
        """
        if radios and not self._stop:
            radio = radios.pop(0)
            widget = RadioWidget(radio,
                                 self._radios_manager)
            widget.show()
            self._sizegroup.add_widget(widget)
            if first:
                self._radiobox.insert(widget, 0)
            else:
                self._radiobox.insert(widget, -1)
            GLib.idle_add(self._add_radios, radios)
        else:
            self._stop = False
        return None

    def _on_album_activated(self, flowbox, child):
        """
            Play album
            @param flowbox as Gtk.Flowbox
            @child as Gtk.FlowboxChild
        """
        name = child.get_child().get_name()
        url = self._radios_manager.get_url(name)
        if url:
            track = Track()
            track.set_radio(name, url)
            Lp().player.load(track)
開發者ID:kmf,項目名稱:lollypop,代碼行數:104,代碼來源:view_radios.py

示例3: restore_state

# 需要導入模塊: from lollypop.radios import Radios [as 別名]
# 或者: from lollypop.radios.Radios import get_url [as 別名]
 def restore_state(self):
     """
         Restore player state
     """
     try:
         if Lp().settings.get_value('save-state'):
             track_id = load(open(DataPath + "/track_id.bin", "rb"))
             playlist_ids = load(open(DataPath + "/playlist_ids.bin",
                                 "rb"))
             if playlist_ids and playlist_ids[0] == Type.RADIOS:
                 radios = Radios()
                 track = Track()
                 name = radios.get_name(track_id)
                 url = radios.get_url(name)
                 track.set_radio(name, url)
                 self.load(track)
             elif Lp().tracks.get_path(track_id) != "":
                 track = Track(track_id)
                 if Lp().notify is not None:
                     Lp().notify.inhibit()
                 self._load_track(track)
                 # We set this initial state
                 # because seek while failed otherwise
                 self.pause()
                 if playlist_ids:
                     pids = []
                     for playlist_id in playlist_ids:
                         pids.append(int(playlist_id))
                     track_ids = []
                     for playlist_id in playlist_ids:
                         if playlist_id == Type.POPULARS:
                             tracks = Lp().tracks.get_populars()
                         elif playlist_id == Type.RECENTS:
                             tracks = Lp().tracks.get_recently_listened_to()
                         elif playlist_id == Type.NEVER:
                             tracks = Lp().tracks.get_never_listened_to()
                         elif playlist_id == Type.RANDOMS:
                             tracks = Lp().tracks.get_randoms()
                         else:
                             tracks = Lp().playlists.get_track_ids(
                                                                playlist_id)
                         for track_id in tracks:
                             if track_id not in track_ids:
                                 track_ids.append(track_id)
                         self.populate_user_playlist_by_tracks(track_ids,
                                                               pids)
                 else:
                     self._albums = load(open(
                                         DataPath + "/albums.bin",
                                         "rb"))
                     self.shuffle_albums(True)
                     self._context.genre_ids = load(open(
                                         DataPath + "/genre_ids.bin",
                                         "rb"))
                     self._context.artist_ids = load(open(
                                         DataPath + "/artist_ids.bin",
                                         "rb"))
                 self.set_next()
                 self.set_prev()
                 if Lp().settings.get_value('repeat'):
                     self._context.next = NextContext.NONE
                 else:
                     self._context.next = NextContext.STOP_ALL
             else:
                 print("Player::restore_state(): track missing")
     except Exception as e:
         print("Player::restore_state()", e)
開發者ID:ferranroig,項目名稱:lollypop,代碼行數:69,代碼來源:player.py


注:本文中的lollypop.radios.Radios.get_url方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。