finally spotify working

pull/1/head
Yash Agarwal 2017-06-16 18:44:41 +05:30
parent 5c8ca5b10e
commit 87c01cf7d7
2 changed files with 31 additions and 5 deletions

8
README.md 100644
View File

@ -0,0 +1,8 @@
# TODO LIST
Basic useful feature list:
* implement song metadata fetch from musicbrainz/spotify/discogs/wikipedia/acoustid
* use mutagen instead of eyed3
* implement lyrics fetcher from genius/metrolyrics
* add download functionality from youtube

View File

@ -3,12 +3,14 @@ import os
from os.path import basename from os.path import basename
import acoustid import acoustid
import discogs_client as discogs import discogs_client as discogs
from string import digits
import musicbrainzngs as m import musicbrainzngs as m
import eyed3 import eyed3
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
import requests import requests
import json import json
import spotipy
import spotipy.oauth2 as oauth2
import re
def improve_song_names(songs): def improve_song_names(songs):
@ -16,11 +18,13 @@ def improve_song_names(songs):
blacklistWords = text_file.read().splitlines() blacklistWords = text_file.read().splitlines()
blacklistWords = [word.lower() for word in blacklistWords] blacklistWords = [word.lower() for word in blacklistWords]
reg_exp = 's/^\d\d //'
improved_names = [] improved_names = []
for song in songs: for song in songs:
song = song.strip()
song = song.lstrip("0123456789.- ")
# re.sub(reg_exp, '', song)
searchText = song[0:-4] searchText = song[0:-4]
# remove_digits = searchText.maketrans('', '', digits)
# searchText = searchText.translate(remove_digits)
for word in song[0:-4].split(' '): for word in song[0:-4].split(' '):
if word.lower() in blacklistWords: if word.lower() in blacklistWords:
searchText = searchText.replace(word, '') searchText = searchText.replace(word, '')
@ -150,15 +154,29 @@ def add_metadata(file_name, album_art):
audiofile.tag.save() audiofile.tag.save()
# def get_metadata_spotify(song):
# spotify.search(song, limit=1)['tracks']['items'][0]
# return
def main(): def main():
auth = oauth2.SpotifyClientCredentials(
client_id='622a0e16a4914e3eadc2a37b4a134f1e',
client_secret='6fe008a8b7754954a58a9849fa3172df')
token = auth.get_access_token()
spotify = spotipy.Spotify(auth=token)
files = list_files() files = list_files()
improved_name = improve_song_names(files)
# get_metadata_spotify(files[1])
# valid, score, rid, title, artist, albumart = get_metadata_acoustid( # valid, score, rid, title, artist, albumart = get_metadata_acoustid(
# "35. Mike Posner - I Took a Pill in Ibiza (SeeB Remix).mp3") # "35. Mike Posner - I Took a Pill in Ibiza (SeeB Remix).mp3")
# print(valid, score, rid, title, artist, albumart) # print(valid, score, rid, title, artist, albumart)
add_album_art( # add_album_art(
"Badi.mp3", "") # "Badi.mp3", "")
# for file_name in files: # for file_name in files:
# print("-------------" + file_name + "------------------") # print("-------------" + file_name + "------------------")
# print() # print()