fixes
This commit is contained in:
parent
5f4bbbaa59
commit
20c7b28ed6
7 changed files with 91 additions and 276 deletions
36
old/env
36
old/env
|
|
@ -1,36 +0,0 @@
|
|||
|
||||
PS1=" > "
|
||||
|
||||
#export PATH="/usr/local/bin/:$PATH"
|
||||
export PATH="$HOME/bin/scripts:$HOME/bin/:$PATH"
|
||||
#export PATH="$HOME/home/auser/.local/bin:$PATH"
|
||||
|
||||
export SIP="185.238.170.251"
|
||||
|
||||
alias v=nvim
|
||||
alias ll="ls -l -a"
|
||||
alias gl="git log --oneline"
|
||||
alias ssh_server="ssh auser@185.238.170.251"
|
||||
|
||||
#eval "$(zoxide init bash --cmd zd)"
|
||||
|
||||
#source $PMAIN/.scripts/bashmarks.sh
|
||||
|
||||
fe() {
|
||||
local result=$(command tere "$@")
|
||||
[ -n "$result" ] && cd -- "$result"
|
||||
}
|
||||
|
||||
vim_configure() {
|
||||
pwd=$(pwd)
|
||||
cd ~/.config/nvim/
|
||||
nvim
|
||||
cd $pwd
|
||||
}
|
||||
|
||||
pyenv() {
|
||||
source ~/bin/python/env311/bin/activate
|
||||
}
|
||||
|
||||
source ~/src/scripts/remotes.sh
|
||||
source /usr/share/fzf/key-bindings.bash
|
||||
195
old/main.py
195
old/main.py
|
|
@ -1,79 +1,3 @@
|
|||
from DataBase import *
|
||||
from LocalLibraryIndexer import update_local_library
|
||||
from LinkerPatternGenerator import run_pattern_generators
|
||||
from LocalPLaylistGenerator import generate_playlists
|
||||
|
||||
from SpotifyWebAPI import fetch_data, update_access_token
|
||||
import cmd
|
||||
|
||||
local_library_path = "/home/auser/Music/"
|
||||
rel_autogen_dir = "0autogen"
|
||||
|
||||
playlists = get_data('playlistTracks')
|
||||
top_artists = get_data('top_artists')
|
||||
top_tracks = get_data('top_tracks')
|
||||
user_tracks = get_data('tracks')
|
||||
link_pattern = get_data('link_pattern_spotify')
|
||||
local_library = get_data("local_library")
|
||||
user_tracks_by_id = {track['track']['id']: track['track'] for track in user_tracks}
|
||||
|
||||
|
||||
def get_playlist_names(pl):
|
||||
return [name for name, items in pl.items()]
|
||||
|
||||
|
||||
def print_playlist_tracks(pl_id: int):
|
||||
pls = list(playlists)
|
||||
name = pls[pl_id]
|
||||
pl = playlists[name]
|
||||
print(name)
|
||||
for track in pl:
|
||||
track_data = track['track']
|
||||
track_name = track_data['name']
|
||||
artists = get_artists_str(track_data['artists'])
|
||||
print(f" '{track_name}' - '{artists}' ")
|
||||
|
||||
|
||||
def print_top_artists():
|
||||
for artist in top_artists:
|
||||
name = artist['name']
|
||||
print(f" '{name}'")
|
||||
|
||||
|
||||
def print_top_tracks():
|
||||
for track in top_tracks:
|
||||
track_name = track['name']
|
||||
artists = get_artists_str(track['artists'])
|
||||
print(f" '{track_name}' - '{artists}' ")
|
||||
|
||||
|
||||
def print_stats():
|
||||
print(f" tracks - {len(user_tracks)}")
|
||||
print(f" playlists - {len(playlists)}")
|
||||
|
||||
for name, tracks in playlists.items():
|
||||
print(f" '{name}' - {len(tracks)}")
|
||||
|
||||
print(f" top tracks - {len(top_tracks)}")
|
||||
print(f" top artists - {len(top_artists)}")
|
||||
|
||||
|
||||
def print_tracks():
|
||||
track_idx = 0
|
||||
for trackItem in user_tracks:
|
||||
track = trackItem['track']
|
||||
print(f" {track_idx}: '{track['name']}' by '{get_artists_str(track['artists'])}'")
|
||||
track_idx += 1
|
||||
|
||||
|
||||
def sort_remote_tracks_by_popularity(track_ids):
|
||||
out = []
|
||||
for top_track in top_tracks:
|
||||
if top_track['id'] in track_ids:
|
||||
out.append(top_track['id'])
|
||||
return out
|
||||
|
||||
|
||||
def print_link_stats(link_pattern):
|
||||
resolved_reversed = {}
|
||||
resolved = []
|
||||
|
|
@ -114,121 +38,4 @@ def print_link_stats(link_pattern):
|
|||
|
||||
print(f" {index}: '{local_track['name']}' by '{local_track['artist']}'", end=' ----> ')
|
||||
print(f"'{remote_track['name']}' by '{get_artists_str(remote_track['artists'])}'")
|
||||
index += 1
|
||||
|
||||
|
||||
class Interpreter(cmd.Cmd):
|
||||
intro = "Welcome to the interactive command loop. Type help or ? to list commands.\n"
|
||||
prompt = "(spotify) "
|
||||
|
||||
def do_list_stat_vs_types(self, arg):
|
||||
"""prints available linking patterns"""
|
||||
print(f"0 - fuzzy tags")
|
||||
print(f"1 - spotify")
|
||||
print(f"2 - fuzzy")
|
||||
|
||||
def do_stat_local_library_vs_spotify(self, arg):
|
||||
"""compares local library and remote with the link pattern generated by the generate_pattern_command"""
|
||||
print_link_stats(link_pattern)
|
||||
|
||||
def do_playlists(self, arg):
|
||||
"""prints user playlists"""
|
||||
pl_id = 0
|
||||
for pl in get_playlist_names(playlists):
|
||||
print(f"{pl_id} - {pl}")
|
||||
pl_id += 1
|
||||
|
||||
def do_playlist_tracks(self, arg):
|
||||
"""prints playlist [name]"""
|
||||
try:
|
||||
pl_id = int(arg.split()[0])
|
||||
print_playlist_tracks(pl_id)
|
||||
except IndexError:
|
||||
print("Invalid input")
|
||||
|
||||
def do_top_artists(self, arg):
|
||||
"""Top artists"""
|
||||
print_top_artists()
|
||||
|
||||
def do_top_tracks(self, arg):
|
||||
"""Top tracks"""
|
||||
print_top_tracks()
|
||||
|
||||
def do_stat(self, arg):
|
||||
"""Print stats"""
|
||||
print_stats()
|
||||
|
||||
def do_tracks(self, arg):
|
||||
"""Print tracks"""
|
||||
print_tracks()
|
||||
|
||||
def do_generate_local_playlists(self, arg):
|
||||
"""generates local playlists based on the vs comparison type"""
|
||||
generate_playlists(local_library, local_library_path, playlists, link_pattern, local_library_path + rel_autogen_dir)
|
||||
|
||||
|
||||
def do_index_local_library(self, arg):
|
||||
"""find local tracks and fetches the data from them for further analysis"""
|
||||
global local_library
|
||||
update_local_library(local_library_path)
|
||||
local_library = get_data("local_library")
|
||||
|
||||
def do_generate_vs_stat(self, arg):
|
||||
"""compares local and remote library and generates the vs stats"""
|
||||
|
||||
global link_pattern
|
||||
run_pattern_generators()
|
||||
link_pattern = get_data('link_pattern_spotify')
|
||||
|
||||
def do_fetch(self, arg):
|
||||
"""Fetch all spotify data"""
|
||||
try:
|
||||
update_access_token()
|
||||
fetch_data()
|
||||
|
||||
global playlists, top_artists, top_tracks, user_tracks
|
||||
|
||||
playlists = get_data('playlistTracks')
|
||||
top_artists = get_data('top_artists')
|
||||
top_tracks = get_data('top_tracks')
|
||||
user_tracks = get_data('tracks')
|
||||
|
||||
except ValueError:
|
||||
print("Can not fetch the data.")
|
||||
|
||||
def do_generate_todo(self, arg):
|
||||
"""generates todos for the pirates"""
|
||||
print("sorry not implemented yet.")
|
||||
|
||||
def do_run_all_default(self, arg):
|
||||
"""runs general flow"""
|
||||
|
||||
local_lib_path = "/home/auser/Music/"
|
||||
print("Fetching spotify data...")
|
||||
self.do_fetch([])
|
||||
|
||||
print("Fetching local data...")
|
||||
self.do_index_local_library(f"{local_lib_path}/organized")
|
||||
|
||||
print("Generating vs patterns...")
|
||||
self.do_generate_vs_stat("0")
|
||||
|
||||
print("Generating todos...")
|
||||
self.do_generate_todo(f"{local_lib_path}")
|
||||
|
||||
print("Generating local playlists...")
|
||||
self.do_generate_local_playlists(f"{local_lib_path}")
|
||||
|
||||
return True
|
||||
|
||||
def do_exit(self, arg):
|
||||
"""Exit the command loop: exit"""
|
||||
print("Goodbye!")
|
||||
return True
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
Interpreter().cmdloop()
|
||||
except KeyboardInterrupt as kb:
|
||||
print("process terminated")
|
||||
index += 1
|
||||
Loading…
Add table
Add a link
Reference in a new issue