mirror of
https://github.com/afkcodes/zspotify.git
synced 2024-09-27 19:51:52 +02:00
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
from enum import Enum
|
|
from tqdm import tqdm
|
|
|
|
from config import *
|
|
from zspotify import ZSpotify
|
|
|
|
|
|
class PrintChannel(Enum):
|
|
SPLASH = PRINT_SPLASH
|
|
SKIPS = PRINT_SKIPS
|
|
DOWNLOAD_PROGRESS = PRINT_DOWNLOAD_PROGRESS
|
|
ERRORS = PRINT_ERRORS
|
|
WARNINGS = PRINT_WARNINGS
|
|
DOWNLOADS = PRINT_DOWNLOADS
|
|
API_ERRORS = PRINT_API_ERRORS
|
|
PROGRESS_INFO = PRINT_PROGRESS_INFO
|
|
|
|
|
|
class Printer:
|
|
@staticmethod
|
|
def print(channel: PrintChannel, msg: str) -> None:
|
|
if ZSpotify.CONFIG.get(channel.value):
|
|
print(msg)
|
|
|
|
@staticmethod
|
|
def print_loader(channel: PrintChannel, msg: str) -> None:
|
|
if ZSpotify.CONFIG.get(channel.value):
|
|
print(msg, flush=True, end="")
|
|
|
|
@staticmethod
|
|
def progress(iterable=None, desc=None, total=None, unit='it', disable=False, unit_scale=False, unit_divisor=1000):
|
|
if not ZSpotify.CONFIG.get(PrintChannel.DOWNLOAD_PROGRESS.value):
|
|
disable = True
|
|
return tqdm(iterable=iterable, desc=desc, total=total, disable=disable, unit=unit, unit_scale=unit_scale, unit_divisor=unit_divisor)
|