fixed proxy login

This commit is contained in:
stratuma 2024-05-22 14:19:58 +02:00
parent c010bbc826
commit cecdd683c5
4 changed files with 55 additions and 34 deletions

View File

@ -67,7 +67,7 @@ async function startAPI() {
timestamp: new Date().toISOString(), timestamp: new Date().toISOString(),
section: 'backendServer' section: 'backendServer'
}) })
app.quit(); app.quit()
return return
} }
console.log(`Server is listening on ${address}`) console.log(`Server is listening on ${address}`)
@ -100,7 +100,7 @@ async function startDB() {
timestamp: new Date().toISOString(), timestamp: new Date().toISOString(),
section: 'databaseConnection' section: 'databaseConnection'
}) })
app.quit(); app.quit()
} }
try { try {
@ -122,7 +122,7 @@ async function startDB() {
timestamp: new Date().toISOString(), timestamp: new Date().toISOString(),
section: 'databaseSync' section: 'databaseSync'
}) })
app.quit(); app.quit()
} }
} }

View File

@ -109,7 +109,7 @@ async function crunchyLoginFetchProxy(user: string, passw: string, geo: string)
if (endpoint !== 1 && drmL3blob && drmL3key) { if (endpoint !== 1 && drmL3blob && drmL3key) {
headers = { headers = {
Authorization: 'Basic dm52cHJyN21ubW1la2Uyd2xwNTM6V19IdWlNekxUS1JqSnlKZTBHRlFYZXFoTldDREdUM2M=', Authorization: 'Basic dm52cHJyN21ubW1la2Uyd2xwNTM6V19IdWlNekxUS1JqSnlKZTBHRlFYZXFoTldDREdUM2M=',
'Content-Type': 'application/x-www-form-urlencoded', 'Content-Type': 'application/json',
'User-Agent': 'Crunchyroll/4.51.0 (bundle_identifier:com.crunchyroll.iphone; build_number:3634220.454824296) iOS/17.4.1 Gravity/4.51.0' 'User-Agent': 'Crunchyroll/4.51.0 (bundle_identifier:com.crunchyroll.iphone; build_number:3634220.454824296) iOS/17.4.1 Gravity/4.51.0'
} }
@ -119,15 +119,17 @@ async function crunchyLoginFetchProxy(user: string, passw: string, geo: string)
grant_type: 'password', grant_type: 'password',
scope: 'offline_access', scope: 'offline_access',
device_name: 'iPhone', device_name: 'iPhone',
device_type: 'iPhone 13' device_type: 'iPhone 13',
ursa: 'Crunchyroll/4.51.0 (bundle_identifier:com.crunchyroll.iphone; build_number:3634220.454824296) iOS/17.4.1 Gravity/4.51.0',
token: 'Basic dm52cHJyN21ubW1la2Uyd2xwNTM6V19IdWlNekxUS1JqSnlKZTBHRlFYZXFoTldDREdUM2M='
} }
} }
if (endpoint === 1) { if (endpoint === 1) {
headers = { headers = {
Authorization: 'Basic dC1rZGdwMmg4YzNqdWI4Zm4wZnE6eWZMRGZNZnJZdktYaDRKWFMxTEVJMmNDcXUxdjVXYW4=', Authorization: 'Basic dC1rZGdwMmg4YzNqdWI4Zm4wZnE6eWZMRGZNZnJZdktYaDRKWFMxTEVJMmNDcXUxdjVXYW4=',
'Content-Type': 'application/x-www-form-urlencoded', 'Content-Type': 'application/json',
'User-Agent': 'Crunchyroll/3.46.2 Android/13 okhttp/4.12.0' 'User-Agent': 'Crunchyroll/1.8.0 Nintendo Switch/12.3.12.0 UE4/4.27'
} }
body = { body = {
@ -136,7 +138,9 @@ async function crunchyLoginFetchProxy(user: string, passw: string, geo: string)
grant_type: 'password', grant_type: 'password',
scope: 'offline_access', scope: 'offline_access',
device_name: 'RMX2170', device_name: 'RMX2170',
device_type: 'realme RMX2170' device_type: 'realme RMX2170',
ursa: 'Crunchyroll/1.8.0 Nintendo Switch/12.3.12.0 UE4/4.27',
token: 'Basic dC1rZGdwMmg4YzNqdWI4Zm4wZnE6eWZMRGZNZnJZdktYaDRKWFMxTEVJMmNDcXUxdjVXYW4='
} }
} }
@ -164,6 +168,7 @@ async function crunchyLoginFetchProxy(user: string, passw: string, geo: string)
return data return data
} else { } else {
console.log(response)
throw new Error(JSON.stringify(response)) throw new Error(JSON.stringify(response))
} }
} catch (e) { } catch (e) {
@ -192,19 +197,38 @@ async function crunchyLoginFetch(user: string, passw: string) {
endpoint = 1 endpoint = 1
} }
headers = { if (endpoint !== 1 && drmL3blob && drmL3key) {
Authorization: 'Basic dC1rZGdwMmg4YzNqdWI4Zm4wZnE6eWZMRGZNZnJZdktYaDRKWFMxTEVJMmNDcXUxdjVXYW4=', headers = {
'Content-Type': 'application/x-www-form-urlencoded', Authorization: 'Basic dm52cHJyN21ubW1la2Uyd2xwNTM6V19IdWlNekxUS1JqSnlKZTBHRlFYZXFoTldDREdUM2M=',
'User-Agent': 'Crunchyroll/3.46.2 Android/13 okhttp/4.12.0' 'Content-Type': 'application/x-www-form-urlencoded',
'User-Agent': 'Crunchyroll/4.51.0 (bundle_identifier:com.crunchyroll.iphone; build_number:3634220.454824296) iOS/17.4.1 Gravity/4.51.0'
}
body = {
username: user,
password: passw,
grant_type: 'password',
scope: 'offline_access',
device_name: 'iPhone',
device_type: 'iPhone 13'
}
} }
body = { if (endpoint === 1) {
username: user, headers = {
password: passw, Authorization: 'Basic dC1rZGdwMmg4YzNqdWI4Zm4wZnE6eWZMRGZNZnJZdktYaDRKWFMxTEVJMmNDcXUxdjVXYW4=',
grant_type: 'password', 'Content-Type': 'application/x-www-form-urlencoded',
scope: 'offline_access', 'User-Agent': 'Crunchyroll/1.8.0 Nintendo Switch/12.3.12.0 UE4/4.27'
device_name: 'RMX2170', }
device_type: 'realme RMX2170'
body = {
username: user,
password: passw,
grant_type: 'password',
scope: 'offline_access',
device_name: 'RMX2170',
device_type: 'realme RMX2170'
}
} }
if (!headers || !body) return if (!headers || !body) return
@ -384,17 +408,17 @@ export async function crunchyGetPlaylist(q: string, geo: string | undefined) {
const error = await response.text() const error = await response.text()
const errorJSON: { const errorJSON: {
activeStreams: { activeStreams: {
accountId: string, accountId: string
active: boolean, active: boolean
assetId: string, assetId: string
clientId: string, clientId: string
contentId: string, contentId: string
country: string, country: string
createdTimestamp: string, createdTimestamp: string
deviceSubtype: string, deviceSubtype: string
deviceType: string, deviceType: string
episodeIdentity: string, episodeIdentity: string
id: string, id: string
token: string token: string
}[] }[]
} = await JSON.parse(error) } = await JSON.parse(error)

View File

@ -48,7 +48,7 @@ export async function loginController(
var responseData var responseData
if (params.id === 'CR') { if (params.id === 'CR') {
const login = await crunchyLogin(body.user, body.password, 'LOCAL'); const login = await crunchyLogin(body.user, body.password, 'LOCAL')
response = login response = login
} }

View File

@ -116,7 +116,6 @@ export async function getPlaylist() {
return episodes return episodes
} catch (e) { } catch (e) {
messageBox('error', ['Cancel'], 2, 'Database Error', 'Failed to get Playlist', JSON.stringify(e))
server.logger.log({ server.logger.log({
level: 'error', level: 'error',
message: 'Failed to get Playlist', message: 'Failed to get Playlist',
@ -150,7 +149,6 @@ async function deletePlaylistandTMP() {
section: 'playlistClearDatabase' section: 'playlistClearDatabase'
}) })
} catch (e) { } catch (e) {
messageBox('error', ['Cancel'], 2, 'Database Error', 'Failed to delete Playlist and tmp folders', JSON.stringify(e))
server.logger.log({ server.logger.log({
level: 'error', level: 'error',
message: 'Failed to delete Playlist and tmp folders', message: 'Failed to delete Playlist and tmp folders',
@ -291,7 +289,6 @@ async function checkPlaylists() {
} }
} }
} catch (e) { } catch (e) {
messageBox('error', ['Cancel'], 2, 'Database Error', 'Failed check Playlist', JSON.stringify(e))
server.logger.log({ server.logger.log({
level: 'error', level: 'error',
message: 'Failed check Playlist', message: 'Failed check Playlist',