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(),
section: 'backendServer'
})
app.quit();
app.quit()
return
}
console.log(`Server is listening on ${address}`)
@ -100,7 +100,7 @@ async function startDB() {
timestamp: new Date().toISOString(),
section: 'databaseConnection'
})
app.quit();
app.quit()
}
try {
@ -122,7 +122,7 @@ async function startDB() {
timestamp: new Date().toISOString(),
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) {
headers = {
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'
}
@ -119,15 +119,17 @@ async function crunchyLoginFetchProxy(user: string, passw: string, geo: string)
grant_type: 'password',
scope: 'offline_access',
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) {
headers = {
Authorization: 'Basic dC1rZGdwMmg4YzNqdWI4Zm4wZnE6eWZMRGZNZnJZdktYaDRKWFMxTEVJMmNDcXUxdjVXYW4=',
'Content-Type': 'application/x-www-form-urlencoded',
'User-Agent': 'Crunchyroll/3.46.2 Android/13 okhttp/4.12.0'
'Content-Type': 'application/json',
'User-Agent': 'Crunchyroll/1.8.0 Nintendo Switch/12.3.12.0 UE4/4.27'
}
body = {
@ -136,7 +138,9 @@ async function crunchyLoginFetchProxy(user: string, passw: string, geo: string)
grant_type: 'password',
scope: 'offline_access',
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
} else {
console.log(response)
throw new Error(JSON.stringify(response))
}
} catch (e) {
@ -192,10 +197,28 @@ async function crunchyLoginFetch(user: string, passw: string) {
endpoint = 1
}
if (endpoint !== 1 && drmL3blob && drmL3key) {
headers = {
Authorization: 'Basic dm52cHJyN21ubW1la2Uyd2xwNTM6V19IdWlNekxUS1JqSnlKZTBHRlFYZXFoTldDREdUM2M=',
'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'
}
}
if (endpoint === 1) {
headers = {
Authorization: 'Basic dC1rZGdwMmg4YzNqdWI4Zm4wZnE6eWZMRGZNZnJZdktYaDRKWFMxTEVJMmNDcXUxdjVXYW4=',
'Content-Type': 'application/x-www-form-urlencoded',
'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 = {
@ -206,6 +229,7 @@ async function crunchyLoginFetch(user: string, passw: string) {
device_name: 'RMX2170',
device_type: 'realme RMX2170'
}
}
if (!headers || !body) return
@ -384,17 +408,17 @@ export async function crunchyGetPlaylist(q: string, geo: string | undefined) {
const error = await response.text()
const errorJSON: {
activeStreams: {
accountId: string,
active: boolean,
assetId: string,
clientId: string,
contentId: string,
country: string,
createdTimestamp: string,
deviceSubtype: string,
deviceType: string,
episodeIdentity: string,
id: string,
accountId: string
active: boolean
assetId: string
clientId: string
contentId: string
country: string
createdTimestamp: string
deviceSubtype: string
deviceType: string
episodeIdentity: string
id: string
token: string
}[]
} = await JSON.parse(error)

View File

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

View File

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