diff --git a/websitemodule.py b/websitemodule.py index 09ce70d..a4bdc4a 100644 --- a/websitemodule.py +++ b/websitemodule.py @@ -11,7 +11,7 @@ def read_music_database(): conn.close() return music_list -def read_count_database(year: int = datetime.datetime.now().year): +def read_count_database(year: int): if year == datetime.datetime.now().year: conn = sqlite3.connect(f'assets/localwrapped/count.db') c = conn.cursor() @@ -29,13 +29,13 @@ def read_count_database(year: int = datetime.datetime.now().year): def total_play_time(year: int): total_time = 0 - for countvar in read_count_database(): - for musicvar in read_music_database(year): + for countvar in read_count_database(year): + for musicvar in read_music_database(): if countvar[0] == musicvar[0]: total_time += float(musicvar[-1]) * countvar[1] return total_time -def generatehtmlcode(year: int): +def generatehtmlcode(year: int = datetime.datetime.now().year): html = '\n\n' html += '\n\n\n\n' html += '\n\n' @@ -48,7 +48,7 @@ def generatehtmlcode(year: int): html += '

Hi guys. I am too lazy to add links to song names. To find which song is it, check this link.

\n' html += '

' + str(year) + '

\n' html += '
\n\n
\n' - html += '

Total Play Time: ' + str(int(total_play_time(url)/60)) + ' minutes

\n' + html += '

Total Play Time: ' + str(int(total_play_time(datetime.datetime.now().year)/60)) + ' minutes

\n' if year == datetime.datetime.now().year: html += '

Last Updated: ' + datetime.datetime.utcfromtimestamp(os.path.getmtime('assets/localwrapped/count.db')).strftime('%Y-%m-%d %H:%M:%S') + ' (UTC +0, I hope.)

\n'; else: @@ -56,7 +56,7 @@ def generatehtmlcode(year: int): html += '

Most Played Musics

\n' html += '
    \n' count_list_formatted = [] - for music in read_count_database(): + for music in read_count_database(year): music_name = music[0] count = music[1] count_list_formatted.append([music_name, count])