from secrets import spotify_user_id
from datetime import datetime
import sys, os, time

## Logger = ON
class Logger(object):
    def __init__(self):
        self.terminal = sys.stdout
        self.log = open('bot-radio.log', 'w')
    def write(self, message):
        self.terminal.write(message)
        self.log.write(message)  
    def flush(self):
        pass    
sys.stdout = Logger()

os.system('cls')
now = datetime.now()
date_time = now.strftime('%d-%m-%Y at %H:%M')

print('ALL NEW RADIO BOT v22-FEB-2022.')
print('An Auto-DJ bot for Spotify playlists.')
print('Maintains up to 60 tracks in a RADIO / MIXTAPE.')
print('(c) Viking Design Studios (User: ' + spotify_user_id + ').')
## Design team: Ollie Beak and Freddy Barker.
## Technical adviser and concept: Euan Morgan.
print('')
print('Report for ' + datetime.today().strftime('%A') + ' ' + date_time) 

## MODULE RUNNING ORDER INDEX ##
## NOTE: See the 'About' folder for info, options and preferences.
import module01  # Remove REJECT tracks from selected playlists.
import module02  # Show pos #1 track and info in FEED playlist.
import module03  # Remove Spotify's Recently Played from RADIO (and SUN LOUNGE playlists).
import module04  # Re-scan RADIO (deficit) track total [mid checks].
import module05  # Move tracks out of FEED to MIXER.
import module06  # Shuffle MIXER tracks.
import module07  # Return MIXER tracks to end pos #nn of FEED.
## import module08  # Add a 'recommender' track to MIXER. (as mostly CRAP).
import module09  # Copy tracks from MIXER to RADIO.
import module10  # Final check for Recently Played tracks in RADIO.
import module11  # Re-scan RADIO, FEED and BACK playlists track totals [tot sync check].


print('All Done.')
print('Cmd window will close in 15 seconds, (unless run from Scheduler).')
time.sleep(15)
print('')

## Logger = OFF
sys.stdout = sys.stdout

## Copy 'radio-bot.log' to 'C:\Users\Documents'.
## import xcopy_log
