Skip to content

Instantly share code, notes, and snippets.

@mrhalix
Last active September 25, 2019 16:44
Show Gist options
  • Save mrhalix/10bb1e8d80cd9f11ca0e0693f10cae4d to your computer and use it in GitHub Desktop.
Save mrhalix/10bb1e8d80cd9f11ca0e0693f10cae4d to your computer and use it in GitHub Desktop.
RadioJavan basic command line client
import requests, json
query = input("Enter song name: ")
print("[*]Searching for " + query + "...")
# make a request to rj API to search the query
jssearch = requests.get("https://app1.rjapp.cc/api2/search?query=" + query)
jdatsearch = json.loads(jssearch.text)
# add song IDs to a list(songsIDs) and print the results
songIDs = []
countIDs = 1
for songs in jdatsearch['mp3s']:
songIDs.append(songs['id'])
print("[" + str(countIDs) + "]" + " " + songs['title'])
countIDs += 1
# get more details for the choosen song and put it into jdatlocate
choosenSongID = int(input("Enter the number: ")) - 1
if choosenSongID > len(songIDs):
print("out of items")
quit()
jslocate = requests.get("https://app1.rjapp.cc/api2/mp3?url=mp3&id=" + str(songIDs[int(choosenSongID)]))
jdatlocate = json.loads(jslocate.text)
# print available operations and ask for input
print("""[1] Get lyrics
[2] Get download link
[3] Get cover link
[4] Get share link""")
operation = int(input("What u wanna do? ")) - 1
# do the operations
if operation == 0:
if jdatlocate['lyric']:
filename = input("Enter filename to save lyrics in: [lyric-" + jdatlocate['title'].replace("\"", "") + ".txt] ")
if filename == "":
filename = "lyric-" + jdatlocate['title'].replace("\"", "") + ".txt"
file = open(filename, "w")
file.write(jdatlocate['lyric'].replace("\n", "\r\n"))
file.close()
print("Saved!")
else:
print("No lyrics assigned for this song :(")
if operation == 1:
print(jdatlocate['link'])
if operation == 2:
print(jdatlocate['photo'])
if operation == 3:
print(jdatlocate['share_link'])
if operation > 3:
print("Out of list")
quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment