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


Python Library.get_watched方法代码示例

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


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

示例1: __init__

# 需要导入模块: import Library [as 别名]
# 或者: from Library import get_watched [as 别名]

#.........这里部分代码省略.........
                playlist = Playlist(filer, self)
                self.playlists.append(playlist)


    def add_account(self, j_item):
        src_type = j_item["type"]
        username = j_item["user"]
        password = j_item["pass"]

        src = Source(self.library, "@NA")
        if src_type is SourceType.GOOGLE:
            src = GoogleMusic(self.library, username, password)
        elif src_type is SourceType.SOUNDCLOUD:
            return #>*
            extras = j_item["extras"]
            client_id = extras["client_id"]
            secret_id = extras["secret_id"]
            print "sc client", client_id
            print "sc secret", secret_id
            src = Soundcloud(self.library, username, password, client_id, secret_id)
        elif src is SourceType.SPOTIFY:
            src = Spotify(self.library, username, password)
        else:
            raise ValueError("Unrecognized src_type value")

        self.library.add_source(src)

    def load(self):
        # f = open('user.tmp', 'r')
        # username = f.readline()[:-1]
        # self.G_username = f.readline().rstrip('\n')
        # self.G_password = f.readline().rstrip('\n')
        # self.S_username = f.readline().rstrip('\n')
        # self.S_password = f.readline().rstrip('\n')
        # self.SOUNDCLOUD_CLIENT_ID = f.readline().rstrip('\n')
        # self.SOUNDCLOUD_CLIENT_SECRET_ID = f.readline().rstrip('\n')
        # f.close()

        j_account_list = self.load_credentials()
        for acct in j_account_list:
            self.add_account(acct)

    def load_credentials(self):
        print "Loading credentials..."
        filer = open(Settings.pathman["profile"], 'r')
        try:
            enc_cred = pickle.load(filer)
        except EOFError:
            return []
        filer.close()

        j = json.loads(Settings.decode(self.enc_key, enc_cred))
        print j
        return j

    def add_credentials(self, j_item):
        j_cred = self.load_credentials()
        src_type = j_item["type"]
        print "adding source type:", src_type

        for item in j_cred:
            if item["type"] is src_type:
                print "credentials already stored"
                return

        j_cred.append(j_item)

        filer = open(Settings.pathman["profile"], 'w')
        enc_cred = Settings.encode(self.enc_key, json.dumps(j_cred))
        pickle.dump(enc_cred, filer)
        filer.close()

    def library_get(self, distinct, get_others, where_like, ordered_return, USI, single=False, db='tracks'):
        return self.library.get(distinct, get_others, where_like, ordered_return, USI, single, db)

    def sync(self):
        self.library.sync()

    def sync_stream(self):
        self.library.sync_stream()

    def get_stream_URL(self, location, song_id):
        return self.library.get_stream_URL(location, song_id)

    def create_playlist(self, playlist_name):
        title = 'playlist_' + playlist_name
        playlist = Playlist(title, self)
        self.playlists.append(playlist)

    def get_watched(self):
        return self.library.get_watched()

    def add_watched(self, directory):
        return self.library.add_watched(directory)

    def remove_watched(self, directory):
        self.library.remove_watched(directory)

    def quit(self):
        self.library.close()
开发者ID:hspitzle,项目名称:project-hermes,代码行数:104,代码来源:User.py


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