示例#1
0
    def login(self, email="", password=""):
        if path.isfile('/config/scripts/login'):
            with open("/config/scripts/login", 'r') as f:
                email = f.readline()
                password = f.readline()
        else:
            while email == "" and password == "":
                email = input("email: ")
                password = getpass("password: "******"login", 'w') as f:
                f.write(email + "\n" + password)
        while True:
            msg, check = self.api.login(email, password, self.token1)
            if check == False:
                print(msg)
                email = ""
                password = ""
                continue
            self.api2 = TidalAPI()
            msg, check = self.api2.login(email, password, self.token2)
            break

        self.user.username = email
        self.user.password = password
        self.user.userid = self.api.key.userId
        self.user.countryCode = self.api.key.countryCode
        self.user.sessionid1 = self.api.key.sessionId
        self.user.sessionid2 = self.api2.key.sessionId
def login(username="", password=""):
    while True:
        if isNull(username) or isNull(password):
            print("---------------" + LANG.CHOICE_LOGIN + "-----------------")
            username = Printf.enter(LANG.PRINT_USERNAME)
            password = Printf.enter(LANG.PRINT_PASSWORD)
        msg, check = API.login(username, password, TOKEN1)
        if check == False:
            Printf.err(msg)
            username = ""
            password = ""
            continue
        api2 = TidalAPI()
        msg, check = api2.login(username, password, TOKEN2)
        break

    USER.username = username
    USER.password = password
    USER.userid = API.key.userId
    USER.countryCode = API.key.countryCode
    USER.sessionid1 = API.key.sessionId
    USER.sessionid2 = api2.key.sessionId
    UserSettings.save(USER)
from aigpy.stringHelper import isNull
from aigpy.pathHelper import mkdirs
from aigpy.pipHelper import getLastVersion
from aigpy.versionHelper import cmpVersion

from tidal_dl.tidal import TidalAPI
from tidal_dl.settings import Settings, UserSettings
from tidal_dl.printf import Printf, VERSION
from tidal_dl.download import start
from tidal_dl.enum import AudioQuality, VideoQuality
from tidal_dl.lang.language import getLang, setLang, initLang

ssl._create_default_https_context = ssl._create_unverified_context

API = TidalAPI()
USER = UserSettings.read()
CONF = Settings.read()
LANG = initLang(CONF.language)


def displayTime(seconds, granularity=2):
    result = []
    intervals = (
        ('weeks', 604800),
        ('days', 86400),
        ('hours', 3600),
        ('minutes', 60),
        ('seconds', 1),
    )
示例#4
0
 def __init__(self):
     self.api = TidalAPI()
     self.api2 = None
     self.user = UserSettings.read()
     self.token1, self.token2 = self.api.getToken()
     self.checkLogin()