1
0
Fork 0
SpotifyLinuxOpen/sllo/Classes.py

39 lines
869 B
Python
Raw Normal View History

2024-03-21 03:52:36 +00:00
from enum import Enum
class SpotifyLink:
class SMTH(Enum):
CTYPE = 0
CID = 1
def __init__(self, link: str) -> None:
"""
:rtype: None
"""
if not ("open.spotify.com" in link):
raise ValueError("This is not a SpotifyOpen link")
self.__link = link
def __getsmth(self, item: SMTH) -> str:
"""
:type item: SMTH
:rtype: str
"""
split = self.__link[8:].split("/")[1:]
return split[item.value]
def __gettype(self) -> str:
"""
:return: Content type
:rtype: str
"""
return self.__getsmth(self.SMTH.CTYPE)
def __getid(self) -> str:
return self.__getsmth(self.SMTH.CID)
def uri(self):
ctype = self.__gettype()
cid = self.__getid()
return f"spotify:{ctype}:{cid}"