Skip to content

Commit

Permalink
Fix formatting. Removed redundant method
Browse files Browse the repository at this point in the history
  • Loading branch information
tehkillerbee committed Oct 10, 2024
1 parent 523dec1 commit 952abc4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 29 deletions.
1 change: 1 addition & 0 deletions tests/test_playlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import tidalapi
from tidalapi.exceptions import ObjectNotFound

from .cover import verify_image_cover, verify_image_resolution


Expand Down
27 changes: 11 additions & 16 deletions tidalapi/playlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,7 @@ def parse(self, json_obj: JsonObj) -> "Folder":
return copy.copy(self)

def rename(self, name: str) -> bool:
"""
Rename the selected folder
"""Rename the selected folder.
:param name: The name to be used for the folder
:return: True, if operation was successful.
Expand All @@ -356,8 +355,7 @@ def rename(self, name: str) -> bool:
return res.ok

def remove(self) -> bool:
"""
Remove the selected folder
"""Remove the selected folder.
:return: True, if operation was successful.
"""
Expand All @@ -373,8 +371,7 @@ def remove(self) -> bool:
def items(
self, offset: int = 0, limit: int = 50
) -> List[Union["Playlist", "UserPlaylist"]]:
"""
Return the items in the folder
"""Return the items in the folder.
:param offset: Optional; The index of the first item to be returned. Default: 0
:param limit: Optional; The amount of items you want returned. Default: 50
Expand Down Expand Up @@ -405,26 +402,23 @@ def items(
return []

def add_items(self, trns: [str]):
"""
Convenience method to add items to the current folder
"""Convenience method to add items to the current folder.
:param trns: List of playlist trns to be added to the current folder
:return: True, if operation was successful.
"""
self.move_items_to_folder(trns, self.id)

def move_items_to_root(self, trns: [str]):
"""
Convenience method to move items from the current folder to the root folder
"""Convenience method to move items from the current folder to the root folder.
:param trns: List of playlist trns to be moved from the current folder
:return: True, if operation was successful.
"""
self.move_items_to_folder(trns, folder="root")

def move_items_to_folder(self, trns: [str], folder: str = None):
"""
Move item(s) in one folder to another folder.
"""Move item(s) in one folder to another folder.
:param trns: List of playlist trns to be moved.
:param folder: Destination folder. Default: Use the current folder
Expand Down Expand Up @@ -534,12 +528,13 @@ def add(
def merge(
self, playlist: str, allow_duplicates: bool = False, allow_missing: bool = True
) -> List[int]:
"""
Add (merge) items from a playlist with the current playlist
"""Add (merge) items from a playlist with the current playlist.
:param playlist: Playlist UUID to be merged in the current playlist
:param allow_duplicates: If true, duplicate tracks are allowed. Otherwise, tracks will be skipped.
:param allow_missing: If true, missing tracks are allowed. Otherwise, exception will be thrown
:param allow_duplicates: If true, duplicate tracks are allowed. Otherwise,
tracks will be skipped.
:param allow_missing: If true, missing tracks are allowed. Otherwise, exception
will be thrown
:return:
"""
data = {
Expand Down
4 changes: 2 additions & 2 deletions tidalapi/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@

from tidalapi.exceptions import *
from tidalapi.types import JsonObj

from . import album, artist, genre, media, mix, page, playlist, request, user

if TYPE_CHECKING:
Expand Down Expand Up @@ -848,8 +849,7 @@ def playlist(
raise

def folder(self, folder_id: Optional[str] = None) -> playlist.Folder:
"""
Function to create a Folder object with access to the session instance in a
"""Function to create a Folder object with access to the session instance in a
smoother way. Calls :class:`tidalapi.Folder(session=session, folder_id=track_id)
<.Folder>` internally.
Expand Down
14 changes: 3 additions & 11 deletions tidalapi/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from tidalapi.artist import Artist
from tidalapi.media import Track, Video
from tidalapi.mix import MixV2
from tidalapi.playlist import Playlist, UserPlaylist, Folder
from tidalapi.playlist import Folder, Playlist, UserPlaylist
from tidalapi.session import Session


Expand Down Expand Up @@ -406,7 +406,8 @@ def remove_video(self, video_id: str) -> bool:
return self.requests.request("DELETE", f"{self.base_url}/videos/{video_id}").ok

def remove_folders_playlists(self, trns: [str], type: str = "folder") -> bool:
"""Removes one or more folders or playlists from the users favourites, using the v2 endpoint
"""Removes one or more folders or playlists from the users favourites, using the
v2 endpoint.
:param trns: List of folder (or playlist) trns to be deleted
:param type: Type of trn: as string, either `folder` or `playlist`. Default `folder`
Expand All @@ -431,15 +432,6 @@ def remove_folders_playlists(self, trns: [str], type: str = "folder") -> bool:
params=params,
).ok

def remove_folder_playlist(self, trn: str, type: str = "folder") -> bool:
"""Removes a folder (or playlist) from the users favourites, using the v2 endpoint
:param trn: Folder or playlist id (trn) of the item to be deleted
:param type: Type of trn: as string, either `folder` or `playlist`
:return: A boolean indicating whether the request was successful or not.
"""
return self.remove_folders_playlists([trn], type)

def artists(self, limit: Optional[int] = None, offset: int = 0) -> List["Artist"]:
"""Get the users favorite artists.
Expand Down

0 comments on commit 952abc4

Please sign in to comment.