def run(self): with open(self._html_file_path, 'rb') as fid: html_text = fid.read() tables = pd.read_html(html_text) playlist_table = tables[0] playlist_table = playlist_table.rename(columns=playlist_table.iloc[0]) playlist_table = playlist_table.drop(playlist_table.index[0]) tracks = [] for index, row in playlist_table.iterrows(): song_uri_thinger = utils.get_song(self._sp, name=row['Title'], artist=row['Artist'], album=row['Release']) if song_uri_thinger is None: print(f"Skipping [{row['Artist']} - {row['Title']}]") continue tracks.append(song_uri_thinger) track_infos_no_dup = utils.remove_duplicates_keep_order(tracks) track_ids = utils.track_ids_from_infos(track_infos_no_dup) playlist_url = utils.create_playlist_from_track_ids( self._sp, self._user_id, self._playlist_name, self._playlist_description, IS_PUBLIC_PLAYLIST, track_ids) print(f"Success: Playlist URL at {playlist_url}")
def djpandora_status(request): """ Calls the Pandora service, forms a JSON object and returns it. This function should only be called via AJAX calls. """ song_result = utils.get_song(request.user) vote_result = utils.song_voting(request.user, song_result['song']) poll_results = utils.station_election(request.user) json_data = { 'title': song_result['song_info']['title'], 'station': song_result['station_name'], 'station_status': song_result['status'], 'artist': song_result['song_info']['artist'], 'album_art': song_result['song_info']['album_art'], 'time': song_result['song_info']['time'], 'album': song_result['song_info']['album'], 'progress': song_result['song_info']['progress'], 'length': song_result['song_info']['length'], 'volume': song_result['volume'], 'upcoming': song_result['playlist'], 'recents': song_result['recents'], 'purchase_itunes': song_result['song_info']['purchase_itunes'], 'purchase_amazon': song_result['song_info']['purchase_amazon'], 'voting': vote_result, 'station_voting': poll_results, 'status': 'success', } return HttpResponse(json.dumps(json_data), mimetype='application/json')
def doc_handler(msg): chat_id = msg.chat.id if msg.caption == "/get_song": doc = msg.document filename = doc.file_name file_id = doc.file_id real_filename = utils.generate_filename() if filename.split('.')[-1] != 'osz': bot.send_message(chat_id, "Wrong file extension") return if doc.file_size > 10485760: bot.send_message(chat_id, "File size is too large") return utils.get_file(file_id, f"temp/{real_filename}.zip") check = utils.get_song(real_filename) if check != "ok": bot.send_message(chat_id, "That's more than one song, idk which one you want...") utils.delete_temp_files(zip_filename=f"temp/{real_filename}.zip") return bot.send_document(chat_id, open(f"temp/{real_filename}.mp3", 'rb'), timeout=40) utils.delete_temp_files(zip_filename=f"temp/{real_filename}.zip", mp3_filename=f"temp/{real_filename}.mp3") return
def run(self): streamings = self._get_streamings() print(f'Recovered {len(streamings)} streamings from history') streamings = self._filter_streamings_by_time_range(streamings) print(f"Number of tracks in history range: {len(streamings)}") print(f"Getting tracks info from Spotify") track_infos = [] unknown_tracks_num = 0 for streaming in tqdm(streamings): track_name = streaming['trackName'] artist_name = streaming['artistName'] if track_name == "Unknown Track" or artist_name == "Unknown Artist": unknown_tracks_num += 1 continue track_info = utils.get_song(self._sp, track_name, artist_name, "") if track_info is not None: track_infos.append(track_info) print(f"Skipped {unknown_tracks_num} unknown tracks or artists in history range") print(f"Removing duplicate tracks") track_infos_no_dup = utils.remove_duplicates_keep_order(track_infos) track_ids = utils.track_ids_from_infos(track_infos_no_dup) print(f"Final tracks number: {len(track_ids)}") playlist_url = utils.create_playlist_from_track_ids(self._sp, self._user_id, self._playlist_name, self._playlist_description, self.IS_PUBLIC_PLAYLIST, track_ids) print(f"Done. Playlist created at URL: {playlist_url}")
try: p = utils.get_playlist(url) print "* trovato: \"%s\"" % (p['title']) except: sys.exit("* l'URL non e' valido, oppure il sito e' down.") print "* creo la cartella %s..." % (p['title']) try: os.makedirs(p['title']) print "* ok." except OSError: print "* esiste gia'. continuo..." print p['ids'] cycle = 0 for id in p['ids']: cycle += 1 print "* scarico %s di %s..." % (cycle, len(p['ids'])) try: utils.get_song(id, p['title'], cycle) print "* ok." except: sys.exit("* qualcosa e' andato storto. segnala questo errore su https://github.com/mexicat/rockit-d/issues") print "* tutto fatto! i file sono nella cartella %s." % (p['title']) print "* spero che tu non abbia usato questo script per scaricare vascobrondi."