コード例 #1
0
ファイル: play_rp.py プロジェクト: doctorfree/RoonCommandLine
    "publisher": "gregd",
    "email": "*****@*****.**",
}

# Can be None if you don't yet have a token
if path.exists(tokenfile):
    token = open(tokenfile).read()
else:
    token = "None"

roonapi = RoonApi(appinfo, token, server)

# get target zone output_id
outputs = roonapi.outputs

output_id = None
for (k, v) in outputs.items():
    if target_zone in v["display_name"]:
        output_id = k

if output_id is None:
    print("No zone found matching", target_zone)
    exit()

# Play Radio Paradise Main
roonapi.play_media(output_id, ["My Live Radio", "Radio Paradise: Main mix"])

# save the token for next time
with open(tokenfile, "w") as f:
    f.write(roonapi.token)
コード例 #2
0
roonapi = RoonApi(appinfo, token, server)

# get target zone output_id
outputs = roonapi.outputs

output_id = None
for (k, v) in outputs.items():
    if target_zone in v["display_name"]:
        output_id = k

if output_id is None:
    print("No zone found matching", target_zone)
    exit()

# Play artist from Library
found = roonapi.play_media(output_id, ["Library", "Artists", artist])

if found:
    print("Found media for artist search term:", artist)
else:
    artists = roonapi.list_media(output_id, ["Library", "Artists", artist])
    if len(artists) == 0:
        print("\nNo artist name partially matching", artist, "\n")
    else:
        print("\nArtist names partially matching", artist, ":\n")
        print(*artists, sep="\n")
        if len(artists) == 1:
            artist = artists[0]
            roonapi.play_media(output_id, ["Library", "Artists", artist])
        else:
            print("\nTo play an artist by name either specify the full name")
コード例 #3
0
roonapi = RoonApi(appinfo, token, server)

# get target zone output_id
outputs = roonapi.outputs

output_id = None
for (k, v) in outputs.items():
    if target_zone in v["display_name"]:
        output_id = k

if output_id is None:
    print("No zone found matching", target_zone)
    exit()

# Play playlist
found = roonapi.play_media(output_id, ["Playlists", playlist])

if found:
    print("Found media for playlist search term:", playlist)
else:
    playlists = roonapi.list_media(output_id, ["Playlists", playlist])
    if len(playlists) == 0:
        print("\nNo playlist name partially matching", playlist, "\n")
    else:
        print("\nPlaylist titles partially matching", playlist, ":\n")
        print(*playlists, sep="\n")
        if len(playlists) == 1:
            playlist = playlists[0]
            roonapi.play_media(output_id, ["Playlists", playlist])
        else:
            print("\nTo play a playlist by name either specify the full name")
コード例 #4
0
output_id = None
for (k, v) in outputs.items():
    if target_zone in v["display_name"]:
        output_id = k

if output_id is None:
    print("No zone found matching", target_zone)
    exit()

# Play tag (not yet working)
tags = roonapi.list_media(output_id, ["Library", "Tags", tag])
if len(tags) == 0:
    print("\nNo tags matching", tag, "\n")
else:
    print("\nTags matching", tag, ":\n")
    print(*tags, sep="\n")
    if len(tags) == 1:
        tag = tags[0]
        print("\nPlaying media by tag is not yet working. Found tag for", tag,
              "\n")
        # Need to identify the media here, somehow use tag to search for media. How?
        roonapi.play_media(output_id, ["Library", "Tags", tag])
    else:
        print("\nTo play a tag by name either specify the full name")
        print("or enough of a substring to provide a single match")

# save the token for next time
with open(tokenfile, "w") as f:
    f.write(roonapi.token)
コード例 #5
0
roonapi = RoonApi(appinfo, token, server)

# get target zone output_id
outputs = roonapi.outputs

output_id = None
for (k, v) in outputs.items():
    if target_zone in v["display_name"]:
        output_id = k

if output_id is None:
    print("No zone found matching", target_zone)
    exit()

# Play genre
found = roonapi.play_media(output_id, ["Genres", genre])

if found:
    print("Found media for genre search term:", genre)
else:
    genres = roonapi.list_media(output_id, ["Genres", genre])
    if len(genres) == 0:
        print("\nNo genre name partially matching", genre, "\n")
    else:
        print("\nGenres partially matching", genre, ":\n")
        print(*genres, sep="\n")
        if len(genres) == 1:
            genre = genres[0]
            roonapi.play_media(output_id, ["Genres", genre])
        else:
            print("\nTo play a genre by name either specify the full name")
コード例 #6
0
# Can be None if you don't yet have a token
token = open("mytokenfile").read()

roonapi = RoonApi(appinfo, token, server)

# get target zone output_id
zones = roonapi.zones
output_id = [
    output["zone_id"] for output in zones.values()
    if output["display_name"] == target_zone
][0]
print("OUTPUT ID", output_id)

# Examples of using play_media
print("RADIO")
items = roonapi.play_media(output_id, ["My Live Radio", "BBC Radio 4"])

print("SINGLE ARTIST")
items = roonapi.play_media(output_id, ["Library", "Artists", "Neil Young"])

print("SINGLE ARTIST ALBUM")
items = roonapi.play_media(
    output_id, ["Library", "Artists", "Neil Young", "After The Goldrush"])

print("PLAY SINGLE ARTIST ALBUM - use Queue")
items = roonapi.play_media(output_id,
                           ["Library", "Artists", "Neil Young", "Harvest"],
                           "Queue")

print("PLAY SUB GENRE")
items = roonapi.play_media(output_id, ["Genres", "Jazz", "Cool"])
コード例 #7
0
roonapi = RoonApi(appinfo, token, server)

# get target zone output_id
outputs = roonapi.outputs

output_id = None
for (k, v) in outputs.items():
    if target_zone in v["display_name"]:
        output_id = k

if output_id is None:
    print("No zone found matching", target_zone)
    exit()

# Play album from Library
found = roonapi.play_media(output_id, ["Library", "Albums", album])

if found:
    print("Found media for album search term:", album)
else:
    albums = roonapi.list_media(output_id, ["Library", "Albums", album])
    if len(albums) == 0:
        print("\nNo album titles partially matching", album, "\n")
    else:
        print("\nAlbum titles partially matching", album, ":\n")
        print(*albums, sep="\n")
        if len(albums) == 1:
            album = albums[0]
            roonapi.play_media(output_id, ["Library", "Albums", album])
        else:
            print("\nTo play an album by name either specify the full name")
コード例 #8
0
try:
    core_id = open("my_core_id_file").read()
    token = open("my_token_file").read()
except OSError:
    print("Please authorise first using discovery.py")
    exit()

discover = RoonDiscovery(core_id)
server = discover.first()
discover.stop()

roonapi = RoonApi(appinfo, token, server[0], server[1], True)

# get target zone output_id
zones = roonapi.zones
output_id = [
    output["zone_id"] for output in zones.values()
    if output["display_name"] == target_zone
][0]
print("OUTPUT ID", output_id)

# Examples of using play_media

print("PLAY Something unplayable - should give error")
items = roonapi.play_media(output_id, ["Qobuz", "My Qobuz", "Favorite Albums"])

print("PLAY Something playable - this should work")
items = roonapi.play_media(
    output_id, ["Qobuz", "My Qobuz", "Favorite Albums", "Grover Live"])