Skip to content

Commit

Permalink
added global variables file
Browse files Browse the repository at this point in the history
  • Loading branch information
Nokse22 committed Apr 13, 2024
1 parent c45cbbd commit f54f51d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import requests
from pathlib import Path
from . import variables

def pretty_duration(secs):
if not secs:
Expand All @@ -54,7 +55,7 @@ def add_image(image_widget, item):

"""Retrieves and adds an image"""

file_path = Path(f"tmp_img/{item.id}.jpg")
file_path = Path(f"{variables.IMG_DIR}/{item.id}.jpg")

if file_path.is_file():
GLib.idle_add(_add_image, image_widget, str(file_path))
Expand Down
13 changes: 13 additions & 0 deletions src/lib/variables.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import os

def init():
global DATA_DIR
DATA_DIR = os.environ.get('XDG_DATA_HOME')
global IMG_DIR
IMG_DIR = f"{DATA_DIR}/images"

if not os.path.exists(IMG_DIR):
# shutil.rmtree(IMG_DIR)
os.makedirs(IMG_DIR)

print(DATA_DIR)
8 changes: 2 additions & 6 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from .window import HighTideWindow

from tidalapi.media import Quality
from .lib import variables

import threading
import os
Expand Down Expand Up @@ -133,12 +134,7 @@ def __init__(self):
css_provider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)

folder_path = "tmp_img"

if os.path.exists(folder_path):
shutil.rmtree(folder_path)

os.makedirs(folder_path)
variables.init()

def on_download(self, *args):
th = threading.Thread(target=self.win.download_song)
Expand Down

0 comments on commit f54f51d

Please sign in to comment.