Sorrow446 / SberZvuk-Downloader

Zvuk (Звук) downloader written in Go.
22 stars 7 forks source link

Feature request: add auth by token (bypass login with emai|pass) #7

Closed tst32 closed 2 years ago

tst32 commented 2 years ago

if we have an of auth token (provided for a non anonymous user 33 chars from https://zvuk.com/api/v2/tiny/profile). it would be useful not to login but proceed directly to all other operations

expected ./main --token <33 secret chars> URLS

it could be done with config.json as well

{
    "email": "",
    "password": "",
    "format": 3,
    "outPath": "Zvuk downloads",
    "albumTemplate": "{{.albumArtist}} - {{.album}}",
    "trackTemplate": "{{.trackPad}}. {{.title}}",
    "maxCover": true,
    "lyrics": true,
    "speedLimit": -1,
    "keepCover": true
    "token": 6SJPyDCub8EJtXQuRPyu5q2meJKW8yleb
}

example token from /dev/urandom

Sorrow446 commented 2 years ago

I don't see the point in this. Could you explain the benefit of using a token over credentials?

tst32 commented 2 years ago

In my case I have a token and email, in my profile, but no password. This is because of the way I authorize in openplay - I authorize through a third-party service. accordingly, I can't specify a password. The way I looked at it - in the process the password is only used together with the email to get the token. I'm sorry if I missed something, as I just quickly looked through the code. cheers!

Sorrow446 commented 2 years ago

That makes perfect sense, thanks. This token should be identical to the one the auth function returns, I'll need to check that.

Sorrow446 commented 2 years ago

Implemented. https://github.com/Sorrow446/SberZvuk-Downloader/commit/de1d87d2dcb50ff736bc4200e4cdaca6b3f77657 It'll use the token if it's not empty, otherwise it'll use credentials. My tokens seem to always be 32 chars long, let me know if yours aren't. Let me know if you need binaries.

tst32 commented 2 years ago

Yes, mine is also 32 length! it works, as follow

./main  https://zvuk.com/track/57571043

 _____         _      ____                _           _         
|__   |_ _ _ _| |_   |    \ ___ _ _ _ ___| |___ ___ _| |___ ___ 
|   __| | | | | '_|  |  |  | . | | | |   | | . | .'| . | -_|  _|
|_____|\_/|___|_,_|  |____/|___|_____|_|_|_|___|__,|___|___|_|

Signed in successfully - <skipped>.3months

Album 1 of 1:
Invalid URL: https://zvuk.com/track/57571043

so i'm happy token auth works, but something is wrong with request

Sorrow446 commented 2 years ago

Album links only, sorry.

tst32 commented 2 years ago

Oh, nice! thanks you so much! 🛩️ all works now! 👍🏻