Ejemplo n.º 1
0
def play(key):
    plist = connect.get("/playlists/" + key + "/items")
    print("Playing Playlist \"" + plist.attrib["title"] + "\"")
    shuffle = input("Shuffle? Y/n: ")
    if shuffle != "n":
        random.shuffle(plist)
    for child in plist:
        play_song.play(child.attrib["ratingKey"])
Ejemplo n.º 2
0
def play(key):
    album = connect.get("/library/metadata/" + key + "/children")
    print("Playing Album " + ident(key))
    shuffle = input("Shuffle? Y/n: ")
    if shuffle != "n":
        random.shuffle(album)
    for track in album:
        play_song.play(track.attrib["ratingKey"])
Ejemplo n.º 3
0
def play(key):
    item = connect.get("/library/metadata/" + key + "/children")
    print("Playing Artist \"" + item.attrib["parentTitle"] + "\"")
    shuffle = input("Shuffle? Y/n: ")
    if shuffle != "n":
        random.shuffle(item)
    for child in item:
        play_album.play(child.attrib["ratingKey"])
Ejemplo n.º 4
0
def play(key):
    track = connect.get("/library/metadata/" + key)
    ply.play(track[0][0][0].attrib["key"])
    dur = int(track[0][0][0].attrib["duration"])
    print("Playing: " + ident(key))
    seconds = (dur // 1000) % 60
    minutes = (dur // 60000) % 60
    elapsed = 0
    while "ffplay" in os.popen("ps aux").read():
        time.sleep(3)
    print()
Ejemplo n.º 5
0
def search():
    search = urllib.parse.quote_plus(input("Search Term: "))

    results = connect.get("/hubs/search", {"query" : search})

    results = [ r for r in results if int(r.attrib["size"]) > 0]
    # only can play tracks, artists, or albums
    results = [ r for r in results if r.attrib["type"] in ["track", "album", "artist", "playlist"]]

    i = 0
    flat_results = []
    for result in results:
        print("----" + result.attrib["title"] + "----")
        for item in result:
            flat_results.append(item)
            print(str(i) + ") " + ident.ident(item.attrib["ratingKey"], item.attrib["type"]))
            i = i + 1

    print("--------")
    print(str(i) + ") Search Again")
    i += 1
    print(str(i) + ") Quit")

    selection = int(input("Choice: "))
    if selection == i - 1:
        return
    if selection >= i:
        quit()

    chosen = flat_results[selection]
    play_chosen(chosen)

    print(  "--------\n" + \
            "0) Play Again\n" + \
            "1) Search Again\n" + \
            "2) Quit" )
    choice = int(input("Choice: "))
    if choice == 0:
        play_chosen(chosen)
    elif choice == 1:
        return
    else:
        quit()
Ejemplo n.º 6
0
def process_gdtv(cid, date, retry=3):
    url = 'http://epg.gdtv.cn/f/%s/%s.xml' % (cid, date)
    data = None
    while retry > 0:
        data = get(url, ctype='xml')
        if not data:
            LOG.error('[%s]No data, try again.' % cid)
            retry -= 1
        else:
            break
    if not data:
        return None
    root = ET.fromstring(data.encode('utf8'))
    datas = list()
    for obj in root[1].findall('content'):
        datas.append({
            'time': timestamp_to_time(obj.attrib['time1']),
            'program_name': obj.text
        })
    return datas
Ejemplo n.º 7
0
def ident(key):
    track = connect.get("/library/metadata/" + key)
    return "\"" + track[0].attrib["title"] + "\" from \"" + track[0].attrib[
        "parentTitle"] + "\" by \"" + track[0].attrib["grandparentTitle"] + "\""
Ejemplo n.º 8
0
def ident(key):
    album = connect.get("/library/metadata/" + key + "/children")
    return "\"" + album[0].attrib["parentTitle"] + "\" by \"" + album[
        0].attrib["grandparentTitle"] + "\""
Ejemplo n.º 9
0
def ident(key):
    item = connect.get("/library/metadata/" + key + "/children")
    return item.attrib["parentTitle"]