From 272c699606912a3066f0de440d2925bb320de7df Mon Sep 17 00:00:00 2001 From: Hemant KArya <65885023+HemantKArya@users.noreply.github.com> Date: Fri, 11 Oct 2024 13:51:42 +0530 Subject: [PATCH] saavn api bug fix --- lib/repository/Saavn/saavn_api.dart | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/repository/Saavn/saavn_api.dart b/lib/repository/Saavn/saavn_api.dart index a244768..b07612d 100644 --- a/lib/repository/Saavn/saavn_api.dart +++ b/lib/repository/Saavn/saavn_api.dart @@ -29,20 +29,17 @@ class SaavnAPI { Future getResponse(String params, {bool usev4 = false}) async { Uri url; + String param = params; if (!usev4) { - url = Uri.https( - baseUrl, - '$apiStr&$params'.replaceAll('&api_version=4', ''), - ); - } else { - url = Uri.https(baseUrl, '$apiStr&$params'); + param.replaceAll('&api_version=4', ''); } + url = Uri.parse('https://$baseUrl$apiStr&$param'); final String languageHeader = 'L=Hindi'; headers = { 'cookie': languageHeader, - 'Accept': '*/*', + 'Accept': 'application/json, text/plain, */*', 'User-Agent': - 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36', + 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36', }; return get(url, headers: headers).onError((error, stackTrace) { return Response( @@ -275,7 +272,7 @@ class SaavnAPI { "p=$page&q=$searchQuery&n=$count&${endpoints['getResults']}"; try { - final res = await getResponse(params); + final res = await getResponse(params, usev4: true); if (res.statusCode == 200) { final Map getMain = json.decode(res.body) as Map; final List responseList = getMain['results'] as List;