当前位置: 首页>>代码示例>>Python>>正文


Python Util.mark_as_not_available方法代码示例

本文整理汇总了Python中lib.util.Util.mark_as_not_available方法的典型用法代码示例。如果您正苦于以下问题:Python Util.mark_as_not_available方法的具体用法?Python Util.mark_as_not_available怎么用?Python Util.mark_as_not_available使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lib.util.Util的用法示例。


在下文中一共展示了Util.mark_as_not_available方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: RipperThread

# 需要导入模块: from lib.util import Util [as 别名]
# 或者: from lib.util.Util import mark_as_not_available [as 别名]

#.........这里部分代码省略.........
                itrack = iter([track])

            elif link.type() == Link.LINK_PLAYLIST \
                    or link_string == 'spotify:user:'+config_get('username')+':starred':
                print 'Loading playlist %s ...' % link_string

                playlist = link.as_playlist()

                while not playlist.is_loaded():
                    time.sleep(0.1)

                itrack = iter(playlist)

            elif link.type() == Link.LINK_ALBUM:
                print 'Processing album %s' % str(link)
                itrack = [ ]
                album = link.as_album()
                album_browser = AlbumBrowser(album)

                while not album_browser.is_loaded():
                    time.sleep(0.1)

                if self._util.is_compilation(album):
                    continue

                if album.is_available():
                    print 'Getting tracks for %s' % album.name()
                    for track in album_browser:
                        itrack.append(track)

            elif link.type() == Link.LINK_ARTIST:
                print "Processing artist %s ..." % str(link)

                artist         = link.as_artist()
                artist_browser = ArtistBrowser(artist, 'no_tracks')

                while not artist_browser.is_loaded():
                    time.sleep(0.1)

                print "Artist loaded"
                print(artist.name())

                similar_artists = artist_browser.similar_artists()

                for similar_artist in similar_artists:
                    self._queue.add_artist_link(similar_artist, 'similar')

                albums           = artist_browser.albums()
                processed_albums = [ ]
                itrack           = [ ]

                for album in albums:
                    if self._util.is_compilation(album):
                        continue

                    if album.is_available() and Link.from_album(album) \
                            not in processed_albums:
                        processed_albums.append(Link.from_album(album))
                        print 'Getting tracks for %s' % album.name()
                        album_browser = AlbumBrowser(album)

                        while not album_browser.is_loaded():
                            time.sleep(0.1)

                        for track in album_browser:
                            itrack.append(track)

            else:
                print "Unrecognised link"
                os._exit(2)
                return

            # ripping loop
            session = self._ripper.session

            for track in itrack:
                if self._util.is_known_not_available(Link.from_track(track)):
                    continue

                try:
                    self._ripper.load_track(track)

                    while not track.is_loaded():
                        time.sleep(0.1)

                    for track_artist in track.artists():
                        self._queue.add_artist_link(track_artist, 'track')

                    if self._ripper.rip_init(session, track):
                        self._ripper.play()
                        self._end_of_track.wait()
                        self._end_of_track.clear()
                        self._ripper.rip_terminate(session, track)
                        self._ripper.rip_id3(session, track)

                except TrackNotAvailableException:
                    print "Track not available (%s)" % track.name()
                    self._util.mark_as_not_available(Link.from_track(track))

        self._ripper.disconnect()
开发者ID:lovek323,项目名称:spotify-ripper,代码行数:104,代码来源:ripper_thread.py


注:本文中的lib.util.Util.mark_as_not_available方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。