Ejemplo n.º 1
0
def result():
    lyrics = False
    query = request.args.get('query')
    lyrics_ = request.args.get('lyrics')
    if lyrics_ and lyrics_.lower() != 'false':
        lyrics = True

    if 'saavn' not in query:
        return jsonify(jiosaavn.search_for_song(query, lyrics))
    try:
        if '/song/' in query:
            print("Song")
            song_id = jiosaavn.get_song_id(query)
            song = jiosaavn.get_song(song_id, lyrics)
            return jsonify(song)

        elif '/album/' in query:
            print("Album")
            id = jiosaavn.get_album_id(query)
            songs = jiosaavn.get_album(id, lyrics)
            return jsonify(songs)

        elif '/playlist/' or '/featured/' in query:
            print("Playlist")
            id = jiosaavn.get_playlist_id(query)
            songs = jiosaavn.get_playlist(id, lyrics)
            return jsonify(songs)

    except Exception as e:
        print_exc()
        error = {"status": True, "error": str(e)}
        return jsonify(error)
    return None
Ejemplo n.º 2
0
def search():
    lyrics = False
    query = request.args.get('query')
    lyrics_ = request.args.get('lyrics')
    if lyrics_ and lyrics_.lower() != 'false':
        lyrics = True
    if query:
        return jsonify(jiosaavn.search_for_song(query, lyrics))
    else:
        error = {
            "status": False,
            "error": 'Query is required to search songs!'
        }
        return jsonify(error)
Ejemplo n.º 3
0
def seekmove(data):
    jsdir = jiosaavn.search_for_song(data['query'], False)
    js = []
    for t in jsdir:
        tmp = {
            'name': t['song'],
            'album': t['album'],
            'year': t['year'],
            'artist': t['primary_artists'],
            'image': t['image'],
            'url': t['media_url']
        }
        js.append(tmp)

    socketio.emit('songsearchresults', js)
Ejemplo n.º 4
0
import jiosaavn
js = jiosaavn.search_for_song('scared to be lonely', False)
for t in js:
    print('Song Name - ', t['song'])
    print('Album Name - ', t['album'])
    print('Year - ', t['year'])
    print('Artists - ', t['primary_artists'])
    print('Song Link - ', t['media_url'])
    print('__________________________________________________')
Ejemplo n.º 5
0
def main():
    isdir = os.path.isdir(download_path)
    if not isdir:
        os.mkdir(download_path)
    while True:
        song_name = input("Enter Song Name: ")
        if song_name == "":
            continue
        else:
            try:
                song_data = jiosaavn.search_for_song(
                    song_name.replace('with lyrics', '').strip())
                print("Which one of these you want?")
                for i in range(len(song_data)):
                    song_name = song_data[i]['title']
                    subtitle = song_data[i]['description']
                    pre = "{}. ".format(i + 1)
                    print("{}{}\n{}{}".format(pre, song_name, ' ' * len(pre),
                                              subtitle))

                pref = input("Enter song number(Hit Enter for Default i,e 1): "
                             ).replace(".", '')
                if pref == '':
                    pref = 1
                elif pref.isnumeric and int(pref) <= len(song_data):
                    pref = int(pref)
                else:
                    print("Invalid Value Entered")
                    continue

                song_id = song_data[pref - 1]['id']
                song_data = jiosaavn.get_song(str(song_id))
                song_name = song_data['song'].replace('?',
                                                      '').replace(':',
                                                                  '').strip()
                artist_name = song_data['primary_artists']
                featured_artist = song_data['featured_artists']
                song_title = "{} - {}".format(song_name, artist_name)
                audio_path = "{}/{}.m4a".format(download_path, song_title)
                img_path = "{}/{}.jpg".format(download_path, song_title)

                album = song_data['album']
                year = song_data['year']
                lang = (song_data['language'])
                lang = lang[0].upper() + lang[1:]
                image_url = song_data['image']

                print("Selected {} by {}".format(song_name, artist_name))

                t1 = threading.Thread(target=dwnld_img,
                                      args=(image_url, img_path))
                t1.start()
                dwnld_sng(song_dwn_url=song_data['media_url'],
                          song_title=song_title)
                fname = "{}/{} - {}.m4a".format(download_path, artist_name,
                                                song_name)
                t1.join()
                #print("Saving matadata")
                save_metadata(audio_path=audio_path,
                              song_name=song_name,
                              artist_name=artist_name,
                              featured_artist=featured_artist,
                              img_path=img_path,
                              album=album,
                              year=year,
                              genre=lang)
                os.remove(img_path)
            except Exception as e:
                print("Failed to Download Song")
                print("ERROR: {}".format(e))