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


Python User.library_get方法代码示例

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


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

示例1: __init__

# 需要导入模块: import User [as 别名]
# 或者: from User import library_get [as 别名]
class Hermes:
    def __init__(self, username):
        self.setup_paths(username)
        self.user = User(self, username)
        self.player = Player()

    # def __del__(self):
    #     print "**Hermes dtor"

    def setup_paths(self, username):
        Settings.add_path_dir("data", "hermes-userdata")
        Settings.add_path_dir("user", username, "data")

        Settings.add_path_file("profile", username, "user")
        Settings.add_path_file("library", username+"_db", "user")

    def add_account(self, j_item):
        self.user.add_account(j_item)
        self.user.add_credentials(j_item)


    def search(self, tail):
        return self.user.library.search(tail)

    def search_album(self, album):
        return self.user.library.search_album(album)

    def search_artist(self, artist):
        return self.user.library.search_artist(artist)


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

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

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

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

    def sync(self):
        print "Syncing"
        self.user.sync()
        print "Done"

    def syncStream(self):
        self.user.sync_stream()
        all_rows = self.user.library_get('streamid', ['artist', 'album', 'title', 'tracknum', 'art', 'location'], 'location', ['artist', 'album', 'tracknum'], 'S', False, 'stream')
        return all_rows

    def create_playlist(self, playlist_name):
        self.user.create_playlist(playlist_name)

    def quit(self):
        self.user.quit()
开发者ID:hspitzle,项目名称:project-hermes,代码行数:60,代码来源:Hermes.py

示例2: __init__

# 需要导入模块: import User [as 别名]
# 或者: from User import library_get [as 别名]
class Hermes:
    def __init__(self, username):
        self.user = User(username)
        self.client = ClientHandler(self.user)
        self.player = Player()

    def intersect(self, res, inp):
        if len(res) == 0:
            for row in inp:
                res.add(row)
        else:
            temp = set()
            for row in inp:
                temp.add(row)
            res = res.intersection(temp)
        return res

    def search(self, tail):
        Art_res = set()
        Alb_res = set()
        Tra_res = set()
        tail = str(tail)
        for word in tail.split():
            all_rows = self.user.library_get('artist', [], 'artist', ['artist'], word)
            Art_res = self.intersect(Art_res, all_rows)

            all_rows = self.user.library_get('album', ['artist'], 'album', ['album'], word)
            Alb_res = self.intersect(Alb_res, all_rows)

            all_rows = self.user.library_get('streamid', ['artist', 'album', 'title', 'tracknum', 'art', 'location'],
                                             'title',
                                             ['artist', 'album', 'tracknum'], word)
            Tra_res = self.intersect(Tra_res, all_rows)

        # recent_Art, recent_Alb, recent_Tra = Print_Results(Art_res, Alb_res, Tra_res)

        Alb_res2 = set()

        for album in Alb_res:
            albuma = self.user.library_get('album', ['artist', 'art'], 'album', [], album[0], True)
            Alb_res2.add(albuma)

        return [Art_res, Alb_res2, Tra_res]

    def search_album(self, album):
        Art_res = set()
        Alb_res = set()
        Tra_res = set()
        tail = str(album)
        for word in tail.split():
            all_rows = self.user.library_get('artist', [], 'album', ['artist'], word)
            Art_res = self.intersect(Art_res, all_rows)

            all_rows = self.user.library_get('album', ['artist'], 'album', ['album'], word)
            Alb_res = self.intersect(Alb_res, all_rows)

            all_rows = self.user.library_get('streamid', ['artist', 'album', 'title', 'tracknum', 'art', 'location'],
                                             'album',
                                             ['artist', 'album', 'tracknum'], word)
            Tra_res = self.intersect(Tra_res, all_rows)

        # recent_Art, recent_Alb, recent_Tra = Print_Results(Art_res, Alb_res, Tra_res)

        Alb_res2 = set()

        for album in Alb_res:
            albuma = self.user.library_get('album', ['artist', 'art'], 'album', [], album[0], True)
            Alb_res2.add(albuma)

        return [Art_res, Alb_res2, Tra_res]

    def search_artist(self, album):
        Art_res = set()
        Alb_res = set()
        Tra_res = set()
        tail = str(album)
        for word in tail.split():
            all_rows = self.user.library_get('artist', [], 'artist', ['artist'], word)
            Art_res = self.intersect(Art_res, all_rows)

            all_rows = self.user.library_get('album', ['artist'], 'artist', ['album'], word)
            Alb_res = self.intersect(Alb_res, all_rows)

            all_rows = self.user.library_get('streamid', ['artist', 'album', 'title', 'tracknum', 'art', 'location'],
                                             'artist',
                                             ['artist', 'album', 'tracknum'], word)
            Tra_res = self.intersect(Tra_res, all_rows)

        Alb_res2 = set()

        for album in Alb_res:
            albuma = self.user.library_get('album', ['artist', 'art'], 'album', [], album[0], True)
            Alb_res2.add(albuma)

        # recent_Art, recent_Alb, recent_Tra = Print_Results(Art_res, Alb_res, Tra_res)

        return [Art_res, Alb_res2, Tra_res]

    def playlist_add(self, title, track):
        for playlist in self.user.playlists:
#.........这里部分代码省略.........
开发者ID:nightfire8199,项目名称:project-hermes,代码行数:103,代码来源:Hermes.py


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