66 lines
1.3 KiB
Python
66 lines
1.3 KiB
Python
import qrcode
|
|
from enum import Enum, StrEnum
|
|
from abc import abstractmethod, ABC
|
|
|
|
class SongStatus(Enum):
|
|
SONG_EXIST = 1
|
|
SONG_NOTEXIST = 0
|
|
SONG_NOTAVAIL = 2
|
|
SONG_ISVIP = 3
|
|
|
|
class AccountType(StrEnum):
|
|
ACCOUNT_NOLOGIN = "未登录"
|
|
ACCOUNT_ANONYMOUS = "匿名用户"
|
|
ACCOUNT_USER = "普通用户"
|
|
ACCOUNT_VIP = "VIP用户"
|
|
ACCOUNT_COOKIE = "Cookie登录"
|
|
def __json__(self):
|
|
return self.value
|
|
|
|
class SessionProvider():
|
|
tempPath = None
|
|
session = None
|
|
|
|
@abstractmethod
|
|
def login(self):
|
|
pass
|
|
|
|
@abstractmethod
|
|
def logout(self):
|
|
pass
|
|
|
|
@abstractmethod
|
|
def qrcode(self):
|
|
pass
|
|
|
|
def _qrcode(self, content):
|
|
raise DeprecationWarning("Please use string instead.")
|
|
if type(content)!=type("string"):
|
|
raise ValueError("QRCode content should be string")
|
|
img = qrcode.make(content)
|
|
return img
|
|
|
|
@abstractmethod
|
|
def status(self):
|
|
pass
|
|
|
|
@abstractmethod
|
|
def loginAnonymous(self):
|
|
pass
|
|
|
|
@abstractmethod
|
|
def checkSong(self, content: int):
|
|
pass
|
|
|
|
@abstractmethod
|
|
def parseURL(self, content: str):
|
|
pass
|
|
|
|
@abstractmethod
|
|
def dumpSession(self):
|
|
pass
|
|
|
|
@abstractmethod
|
|
def restoreSession(self, session: str):
|
|
pass
|