Last active
April 3, 2019 19:26
-
-
Save zaneneuschuler/10335420d1bdd222576d5e09cce45f68 to your computer and use it in GitHub Desktop.
Randomly select an album from your library to play in MusicBee.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import random | |
import subprocess | |
def get_immediate_subdirectories(a_dir): | |
return [name for name in os.listdir(a_dir) | |
if os.path.isdir(os.path.join(a_dir, name))] | |
played = open('musicpaths.txt', "r+") | |
BASE_PATH = '[YOUR MUSIC PATH HERE]' | |
def get_lowest_subdir(MUSIC_PATH): | |
subDirs = get_immediate_subdirectories(MUSIC_PATH) | |
while len(subDirs) != 0: | |
randFolder = subDirs[random.randint(0, len(subDirs)-1)] | |
MUSIC_PATH += '\\'+randFolder | |
subDirs = get_immediate_subdirectories(MUSIC_PATH) | |
return MUSIC_PATH | |
music = get_lowest_subdir(BASE_PATH) | |
while music in played.readlines(): | |
print("Duplicate album, rolling again...") | |
music = get_lowest_subdir(BASE_PATH) | |
print("FINAL PATH: " + music) | |
subprocess.call('C:\\Program Files (x86)\\MusicBee\\MusicBee.exe /Play "'+music+'"') | |
save_check = input("Do you want to save this as listened? Y/N") | |
while save_check != "Y" and save_check != "N" and save_check != "y" and save_check != "n" : | |
save_check = input("Please try again. Enter either a lower or uppercase y or n.") | |
if save_check == "Y" or save_check == "y": | |
played.write(music+"\n") | |
played.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment