mirror of
https://github.com/oskvr37/tiddl.git
synced 2026-06-13 04:05:08 +03:00
🎨 get rid of relative imports
This commit is contained in:
+2
-2
@@ -2,8 +2,8 @@ import logging
|
||||
|
||||
from requests import request
|
||||
|
||||
from .exceptions import AuthError
|
||||
from .models import auth
|
||||
from tiddl.exceptions import AuthError
|
||||
from tiddl.models import auth
|
||||
|
||||
AUTH_URL = "https://auth.tidal.com/v1/oauth2"
|
||||
CLIENT_ID = "zU4XHVVkc2tDPo4t"
|
||||
|
||||
@@ -3,14 +3,12 @@ import logging
|
||||
|
||||
from rich.logging import RichHandler
|
||||
|
||||
from .ctx import ContextObj, passContext, Context
|
||||
from .auth import AuthGroup
|
||||
from .download import UrlGroup, FavGroup, SearchGroup, FileGroup
|
||||
from .config import ConfigCommand
|
||||
|
||||
from tiddl.config import HOME_PATH
|
||||
|
||||
from .auth import refresh
|
||||
from tiddl.cli.ctx import ContextObj, passContext, Context
|
||||
from tiddl.cli.auth import AuthGroup
|
||||
from tiddl.cli.download import UrlGroup, FavGroup, SearchGroup, FileGroup
|
||||
from tiddl.cli.config import ConfigCommand
|
||||
from tiddl.cli.auth import refresh
|
||||
|
||||
|
||||
@click.group()
|
||||
|
||||
+2
-5
@@ -11,8 +11,7 @@ from tiddl.auth import (
|
||||
removeToken,
|
||||
AuthError,
|
||||
)
|
||||
|
||||
from .ctx import passContext, Context
|
||||
from tiddl.cli.ctx import passContext, Context
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -74,9 +73,7 @@ def login(ctx: Context):
|
||||
time_left = auth_end_at - time()
|
||||
minutes, seconds = time_left // 60, int(time_left % 60)
|
||||
|
||||
click.echo(
|
||||
f"\rTime left: {minutes:.0f}:{seconds:02d}", nl=False
|
||||
)
|
||||
click.echo(f"\rTime left: {minutes:.0f}:{seconds:02d}", nl=False)
|
||||
continue
|
||||
|
||||
if e.error == "expired_token":
|
||||
|
||||
+1
-2
@@ -1,8 +1,7 @@
|
||||
import click
|
||||
|
||||
from tiddl.config import CONFIG_PATH
|
||||
|
||||
from .ctx import Context, passContext
|
||||
from tiddl.cli.ctx import Context, passContext
|
||||
|
||||
|
||||
@click.command("config")
|
||||
|
||||
@@ -26,15 +26,14 @@ from tiddl.utils import (
|
||||
trackExists,
|
||||
)
|
||||
|
||||
from tiddl.cli.ctx import Context, passContext
|
||||
from tiddl.cli.download.fav import FavGroup
|
||||
from tiddl.cli.download.file import FileGroup
|
||||
from tiddl.cli.download.search import SearchGroup
|
||||
from tiddl.cli.download.url import UrlGroup
|
||||
|
||||
from typing import List, Union
|
||||
|
||||
from .fav import FavGroup
|
||||
from .file import FileGroup
|
||||
from .search import SearchGroup
|
||||
from .url import UrlGroup
|
||||
|
||||
from ..ctx import Context, passContext
|
||||
|
||||
|
||||
@click.command("download")
|
||||
@click.option(
|
||||
@@ -96,13 +95,9 @@ def DownloadCommand(
|
||||
SINGLES_FILTER = SINGLES_FILTER or ctx.obj.config.download.singles_filter
|
||||
|
||||
# TODO: pretty print
|
||||
logging.debug(
|
||||
(QUALITY, TEMPLATE, PATH, THREADS_COUNT, DO_NOT_SKIP, SINGLES_FILTER)
|
||||
)
|
||||
logging.debug((QUALITY, TEMPLATE, PATH, THREADS_COUNT, DO_NOT_SKIP, SINGLES_FILTER))
|
||||
|
||||
DOWNLOAD_QUALITY = ARG_TO_QUALITY[
|
||||
QUALITY or ctx.obj.config.download.quality
|
||||
]
|
||||
DOWNLOAD_QUALITY = ARG_TO_QUALITY[QUALITY or ctx.obj.config.download.quality]
|
||||
|
||||
api = ctx.obj.getApi()
|
||||
|
||||
@@ -136,9 +131,7 @@ def DownloadCommand(
|
||||
urls, extension = parseTrackStream(track_stream)
|
||||
elif isinstance(item, Video):
|
||||
video_stream = api.getVideoStream(item.id)
|
||||
description = (
|
||||
f"Video '{item.title}' {video_stream.videoQuality} quality"
|
||||
)
|
||||
description = f"Video '{item.title}' {video_stream.videoQuality} quality"
|
||||
|
||||
urls = parseVideoStream(video_stream)
|
||||
extension = ".ts"
|
||||
@@ -172,11 +165,7 @@ def DownloadCommand(
|
||||
)
|
||||
|
||||
stream_data += req.content
|
||||
speed = (
|
||||
len(stream_data)
|
||||
/ (perf_counter() - time_start)
|
||||
/ (1024 * 128)
|
||||
)
|
||||
speed = len(stream_data) / (perf_counter() - time_start) / (1024 * 128)
|
||||
size = len(stream_data) / 1024**2
|
||||
progress.update(
|
||||
task_id,
|
||||
@@ -205,9 +194,7 @@ def DownloadCommand(
|
||||
cover_data = Cover(item.album.cover).content
|
||||
|
||||
try:
|
||||
addMetadata(
|
||||
path, item, cover_data, credits, album_artist=album_artist
|
||||
)
|
||||
addMetadata(path, item, cover_data, credits, album_artist=album_artist)
|
||||
except Exception as e:
|
||||
logging.error(f"Can not add metadata to: {path}, {e}")
|
||||
|
||||
@@ -292,10 +279,7 @@ def DownloadCommand(
|
||||
album.artist.name,
|
||||
)
|
||||
|
||||
if (
|
||||
album_items.limit + album_items.offset
|
||||
> album_items.totalNumberOfItems
|
||||
):
|
||||
if album_items.limit + album_items.offset > album_items.totalNumberOfItems:
|
||||
break
|
||||
|
||||
offset += album_items.limit
|
||||
@@ -362,14 +346,11 @@ def DownloadCommand(
|
||||
offset = 0
|
||||
|
||||
while True:
|
||||
playlist_items = api.getPlaylistItems(
|
||||
playlist.uuid, offset=offset
|
||||
)
|
||||
playlist_items = api.getPlaylistItems(playlist.uuid, offset=offset)
|
||||
|
||||
for item in playlist_items.items:
|
||||
filename = formatResource(
|
||||
template=TEMPLATE
|
||||
or ctx.obj.config.template.playlist,
|
||||
template=TEMPLATE or ctx.obj.config.template.playlist,
|
||||
resource=item.item,
|
||||
playlist_title=playlist.title,
|
||||
playlist_index=item.item.index // 100000,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import click
|
||||
|
||||
from tiddl.utils import TidalResource, ResourceTypeLiteral
|
||||
from ..ctx import Context, passContext
|
||||
from tiddl.cli.ctx import Context, passContext
|
||||
|
||||
ResourceTypeList: list[ResourceTypeLiteral] = ["track", "video", "album", "artist", "playlist"]
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ import json
|
||||
from io import TextIOWrapper
|
||||
from os.path import splitext
|
||||
|
||||
from ..ctx import Context, passContext
|
||||
from tiddl.utils import TidalResource
|
||||
from tiddl.cli.ctx import Context, passContext
|
||||
|
||||
|
||||
@click.group("file")
|
||||
|
||||
@@ -2,8 +2,7 @@ import click
|
||||
|
||||
from tiddl.utils import TidalResource
|
||||
from tiddl.models.resource import Artist, Album, Playlist, Track, Video
|
||||
|
||||
from ..ctx import Context, passContext
|
||||
from tiddl.cli.ctx import Context, passContext
|
||||
|
||||
|
||||
@click.group("search")
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import click
|
||||
|
||||
from ..ctx import Context, passContext
|
||||
|
||||
from tiddl.utils import TidalResource
|
||||
from tiddl.cli.ctx import Context, passContext
|
||||
|
||||
|
||||
class TidalURL(click.ParamType):
|
||||
|
||||
+2
-4
@@ -1,7 +1,7 @@
|
||||
from pydantic import BaseModel
|
||||
from typing import Optional, List, Literal, Union
|
||||
|
||||
from .resource import Album, Artist, Playlist, Track, TrackQuality, Video
|
||||
from tiddl.models.resource import Album, Artist, Playlist, Track, TrackQuality, Video
|
||||
|
||||
__all__ = [
|
||||
"SessionResponse",
|
||||
@@ -114,9 +114,7 @@ class TrackStream(BaseModel):
|
||||
assetPresentation: Literal["FULL"]
|
||||
audioMode: Literal["STEREO"]
|
||||
audioQuality: TrackQuality
|
||||
manifestMimeType: Literal[
|
||||
"application/dash+xml", "application/vnd.tidal.bts"
|
||||
]
|
||||
manifestMimeType: Literal["application/dash+xml", "application/vnd.tidal.bts"]
|
||||
manifestHash: str
|
||||
manifest: str
|
||||
albumReplayGain: float
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
from pydantic import BaseModel
|
||||
from datetime import datetime
|
||||
from typing import Optional, List, Literal, Dict
|
||||
from .constants import TrackQuality
|
||||
|
||||
from tiddl.models.constants import TrackQuality
|
||||
|
||||
|
||||
__all__ = ["Track", "Video", "Album", "Playlist", "Artist"]
|
||||
|
||||
Reference in New Issue
Block a user