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


Python Song.uid方法代码示例

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


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

示例1: get_songs

# 需要导入模块: from song import Song [as 别名]
# 或者: from song.Song import uid [as 别名]
    def get_songs(self):
        cursor = self.db.cursor()
        sql = '''\
select id, uid, title, artist, url, img_url, played_count, created_at, description, duration FROM SONGS
'''
        cursor.execute(sql)
        ret = []

        while True:
            data = cursor.fetchone()
            if data:
                song = Song()

                song.dbid = data[0]
                song.uid = data[1]
                song.title = data[2]
                song.artist = data[3]
                song.url = data[4]
                song.img_url = data[5]
                song.played_count = data[6]
                song.created_at = data[7]
                song.description = data[8]
                song.duration = data[9]
                
                yield song
            else:
                break
开发者ID:mycat83,项目名称:book_python_example,代码行数:29,代码来源:store.py

示例2: find_songs_by_title

# 需要导入模块: from song import Song [as 别名]
# 或者: from song.Song import uid [as 别名]
    def find_songs_by_title(self, title):
        "노래 제목으로 곡을 찾는다."

        cursor = self.db.cursor()
        sql = '''\
select id, uid, title, artist, url, img_url, played_count, created_at, description, duration FROM SONGS where title like ?
'''
        cursor.execute(sql, (title, ))
        ret = []

        for data in cursor.fetchmany(5):
            if data:
                song = Song()

                song.dbid = data[0]
                song.uid = data[1]
                song.title = data[2]
                song.artist = data[3]
                song.url = data[4]
                song.img_url = data[5]
                song.played_count = data[6]
                song.created_at = data[7]
                song.description = data[8]
                song.duration = data[9]

                ret.append(song)
        
        return ret
开发者ID:mycat83,项目名称:book_python_example,代码行数:30,代码来源:store.py

示例3: add_song

# 需要导入模块: from song import Song [as 别名]
# 或者: from song.Song import uid [as 别名]
def add_song():
    """노래 추가.

    youtube link를 주면 곡 정보를 DB에 추가한다.
    가능한 링크
      - youtube 노래 link
      - youtube playlist link
    """

    # web browser에서 요청한 데이터를 받는다. body 영역 데이터
    data = request.get_json(silent=True)

    # 그중에 url, list_url, add_playlist 정보를 가져온다.
    # url는 노래 link
    # list_url는 플레이 리스트 link
    # add_playlist는 현재 연주되고 있는 플레이 리스트에 바로 추가할지 결정
    url = data.get("url", None)
    list_url = data.get("list_url", None)
    add_playlist = data.get('add_playlist', False)

    # 노래 link 라면
    if url:

        # 노래 정보를 구해서
        info = youtube.get_video_info(url)
        # song 객체로 만들어
        song = Song()
        song.url = info["url"]
        song.uid = info["uid"]
        song.title = info["title"]
        song.img_url = info["image_url"]
        song.duration = info['duration']

        if song.title and song.duration:
            # 데이터가 valid 할 때만 추가
        
            # DB에 추가한다.
            jukebox.append_song_to_db(song)

            # 플레이 리스트에 추가해야 하면 그렇게 한다.
            if add_playlist:
                jukebox.append_song_playlist(song)

    elif list_url:
        # 노래 목록이면
        # 별도의 처리 쓰레드를 통해서 처리한다.
        thread = AddYoutubeListThread(jukebox, list_url, add_playlist)
        thread.start()

    # 잘 처리되었다고 반환
    ret = { 'code': 0, 'msg': 'ok' }        
    return jsonify(**ret)
开发者ID:mycat83,项目名称:book_python_example,代码行数:54,代码来源:web_jukebox.py

示例4: test

# 需要导入模块: from song import Song [as 别名]
# 或者: from song.Song import uid [as 别名]
def test():
    from  song import Song
    store = Store()

    song = Song()
    song.title = "노래 제목"
    song.uid = 'uid01'
    song.url = "http://song_url"
    song.played_count = 1
    store.save(song)

    s = store.findByUid('uid01')
    print(s)

    for s in store.findSongsByTitle('%노래%'):
        print(s)
开发者ID:mycat83,项目名称:book_python_example,代码行数:18,代码来源:store.py

示例5: run

# 需要导入模块: from song import Song [as 别名]
# 或者: from song.Song import uid [as 别名]
    def run(self):
        infos = youtube.get_video_infos_from_list(self.list_url)
        for info in infos:
            print(info)
            try:
                song = Song()
                song.url = info["url"]
                song.uid = info["uid"]
                song.title = info["title"]
                song.img_url = info["image_url"]
                song.duration = info['duration']

                if song.title and song.duration:
                    # 데이터가 valid 할 때만 추가
                    
                    self.store.update_or_new(song)

                    if self.add_playlist:
                        self.jukebox.append_song_playlist(song)
                
            except Exception as e:
                print(e)
开发者ID:mycat83,项目名称:book_python_example,代码行数:24,代码来源:jukebox.py

示例6: find_by_id

# 需要导入模块: from song import Song [as 别名]
# 或者: from song.Song import uid [as 别名]
    def find_by_id(self, dbid):
        "UID로 노래를 찾는다."
        cursor = self.db.cursor()
        sql = '''\
select id, uid, title, artist, url, img_url, played_count, created_at, description, duration FROM SONGS where id = ?
'''
        cursor.execute(sql, (dbid, ))
        data = cursor.fetchone()
        if data:
            song = Song()

            song.dbid = data[0]
            song.uid = data[1]
            song.title = data[2]
            song.artist = data[3]
            song.url = data[4]
            song.img_url = data[5]
            song.played_count = data[6]
            song.created_at = data[7]
            song.description = data[8]
            song.duration = data[9]
            
        return song
开发者ID:mycat83,项目名称:book_python_example,代码行数:25,代码来源:store.py


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