Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kaimi-io/yandex-music-download.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaimi <kaimi-@users.noreply.github.com>2018-09-30 10:35:42 +0300
committerGitHub <noreply@github.com>2018-09-30 10:35:42 +0300
commit0d7e0562c46b59e289a8023694660f4e06c1ccfa (patch)
tree6b01f06ef762c87e4094baef6c0224802b0d7604
parentd0122d7b09aece1149c49d832fb2466d7853b0a1 (diff)
Append OAuth prefix if not present
-rwxr-xr-xsrc/ya.pl15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/ya.pl b/src/ya.pl
index 225952b..bde01ec 100755
--- a/src/ya.pl
+++ b/src/ya.pl
@@ -37,7 +37,8 @@ use constant
URL_PLAYLIST_REGEX => qr{music\.yandex\.\w+/users/(.+?)/playlists/(\d+)}is,
RESPONSE_LOG_PREFIX => 'log_',
TEST_URL => 'https://api.music.yandex.net/users/ya.playlist/playlists/1',
- RENAME_ERRORS_MAX => 5
+ RENAME_ERRORS_MAX => 5,
+ AUTH_TOKEN_PREFIX => 'OAuth ',
};
use constant
{
@@ -500,6 +501,16 @@ sub get_track_url
my $storage_dir = shift;
my $track_id = (split(/\./, $storage_dir))[-1];
+ my $auth_token = '';
+ if($opt{mobile} && $opt{auth})
+ {
+ if($opt{auth} !~ /${\(AUTH_TOKEN_PREFIX)}/i)
+ {
+ $auth_token = AUTH_TOKEN_PREFIX;
+ }
+ $auth_token .= $opt{auth};
+ }
+
my $request = $ua->get
(
$opt{mobile} ?
@@ -507,7 +518,7 @@ sub get_track_url
:
YANDEX_BASE.sprintf(DOWNLOAD_INFO_MASK, time, $storage_dir)
,
- Authorization => ($opt{mobile} && $opt{auth}) ? $opt{auth} : ''
+ Authorization => $auth_token
);
if(!$request->is_success)
{