Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tackle_The_Box Done #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
.pub-cache/
.pub/
/build/

assets/venv
assets/.cache
assets/cread.py
assets/file copy.json
# Web related
lib/generated_plugin_registrant.dart

Expand Down
1 change: 1 addition & 0 deletions assets/file.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"item": [{"Artist": "Ed Sheeran", "Name": "Perfect (Acoustic)", "Like": 57, "image": "https://i.scdn.co/image/ab67616d0000b273a629dbc92d4dcb0312b45fa2", "url": "https://open.spotify.com/album/4uJ318DIOMiA4y9vg2dRwv", "Tracks": 1}, {"Artist": "Ravindra Jain", "Name": "Nadiya Ke Paar", "Like": 45, "image": "https://i.scdn.co/image/ab67616d0000b273eac0f6e72c19c4c2925f6f08", "url": "https://open.spotify.com/album/60eF9Ax87kGEvdz59jzj7F", "Tracks": 6}, {"Artist": "Jagjit Singh", "Name": "Dard-E-Jigar", "Like": 56, "image": "https://i.scdn.co/image/ab67616d0000b273b5eba194cd2f743be9a0f87b", "url": "https://open.spotify.com/album/210OGDoE9U5PLaKJfn1N4E", "Tracks": 10}, {"Artist": "Hariharan", "Name": "Shree Hanuman Chalisa (Hanuman Ashtak)", "Like": 63, "image": "https://i.scdn.co/image/ab67616d0000b2736d9a2050e82ce05424dca5aa", "url": "https://open.spotify.com/album/1JfMAw56ShwV21lxRrwGbu", "Tracks": 8}, {"Artist": "Madhur Sharma", "Name": "Kali Kali Zulfon Ke", "Like": 57, "image": "https://i.scdn.co/image/ab67616d0000b2735d3eb49f951719b18c4b657f", "url": "https://open.spotify.com/album/5sy3Yeqw1hIefmQCQs4ClP", "Tracks": 1}, {"Artist": "Alan Walker", "Name": "On My Way", "Like": 71, "image": "https://i.scdn.co/image/ab67616d0000b273d2aaf635815c265aa1ecdecc", "url": "https://open.spotify.com/album/1bcvtuHyO79DNAOOhHEkEm", "Tracks": 1}, {"Artist": "Arijit Singh", "Name": "Best Of Arijit Singh - Revisited", "Like": 63, "image": "https://i.scdn.co/image/ab67616d0000b273e0129ac6975a3a8b658f708b", "url": "https://open.spotify.com/album/5h2JZNs7g1Q7zua3ikDIKd", "Tracks": 30}, {"Artist": "Various Artists", "Name": "Old Is Gold", "Like": 40, "image": "https://i.scdn.co/image/ab67616d0000b27395b5249bed33599a4d9706c0", "url": "https://open.spotify.com/album/7mybvUeKtPQISj8UCfdgmV", "Tracks": 9}, {"Artist": "Various Artists", "Name": "Ranjha (From \"Shershaah\")", "Like": 75, "image": "https://i.scdn.co/image/ab67616d0000b27309426d9ae9d8d981735ebc5e", "url": "https://open.spotify.com/album/0Z1zYMwJRpvq0d9rdqTOYo", "Tracks": 1}]}
25 changes: 25 additions & 0 deletions assets/spotify.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import spotipy
import json
from spotipy.oauth2 import SpotifyOAuth
import cread
sp = spotipy.Spotify(auth_manager=SpotifyOAuth(client_id=cread.client_ID,
client_secret=cread.client_SECRET,
redirect_uri=cread.redirect_url,
scope="user-library-read"))
f=open("file.json","w")
results = sp.current_user_saved_tracks()

l={"item":[]}
results = sp.current_user_saved_albums()
for idx, item in enumerate(results['items']):
track = item['album']
my_dict = {}
my_dict["Artist"]=track['artists'][0]['name']
my_dict["Name"]=track['name']
my_dict["Like"]=track['popularity']
my_dict["image"]=track["images"][0]["url"]
my_dict["url"]=track['external_urls']["spotify"]
my_dict["Tracks"]=track['total_tracks']
l["item"].append(my_dict)
print(idx, track['artists'][0]['name'], " – ", track['name'], "--", track['popularity'],"--",track["images"][0]["url"], "--", track['total_tracks'])
json.dump(l,f)
Loading