added switch endpoint fix
This commit is contained in:
parent
a22f70a017
commit
b749f22ae9
@ -16,6 +16,17 @@ const crErrors = [
|
|||||||
|
|
||||||
// Crunchyroll Login Handler
|
// Crunchyroll Login Handler
|
||||||
export async function crunchyLogin(user: string, passw: string, geo: string) {
|
export async function crunchyLogin(user: string, passw: string, geo: string) {
|
||||||
|
|
||||||
|
var endpoint = await settings.get('CREndpoint')
|
||||||
|
const drmL3blob = await settings.get('l3blob')
|
||||||
|
const drmL3key = await settings.get('l3key')
|
||||||
|
|
||||||
|
if (!drmL3blob || !drmL3key) {
|
||||||
|
await settings.set('CREndpoint', 1)
|
||||||
|
endpoint = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const cachedData:
|
const cachedData:
|
||||||
| {
|
| {
|
||||||
access_token: string
|
access_token: string
|
||||||
@ -27,7 +38,7 @@ export async function crunchyLogin(user: string, passw: string, geo: string) {
|
|||||||
account_id: string
|
account_id: string
|
||||||
profile_id: string
|
profile_id: string
|
||||||
}
|
}
|
||||||
| undefined = server.CacheController.get(`crtoken-${geo}`)
|
| undefined = server.CacheController.get(`crtoken-${geo}-${endpoint}`)
|
||||||
|
|
||||||
if (!cachedData) {
|
if (!cachedData) {
|
||||||
if (geo === 'LOCAL') {
|
if (geo === 'LOCAL') {
|
||||||
@ -35,7 +46,7 @@ export async function crunchyLogin(user: string, passw: string, geo: string) {
|
|||||||
|
|
||||||
if (!data) return
|
if (!data) return
|
||||||
|
|
||||||
server.CacheController.set(`crtoken-${geo}`, data, data.expires_in - 30)
|
server.CacheController.set(`crtoken-${geo}-${endpoint}`, data, data.expires_in - 30)
|
||||||
|
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
@ -45,7 +56,7 @@ export async function crunchyLogin(user: string, passw: string, geo: string) {
|
|||||||
|
|
||||||
if (!data) return
|
if (!data) return
|
||||||
|
|
||||||
server.CacheController.set(`crtoken-${geo}`, data, data.expires_in - 30)
|
server.CacheController.set(`crtoken-${geo}-${endpoint}`, data, data.expires_in - 30)
|
||||||
|
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
@ -114,6 +125,23 @@ async function crunchyLoginFetchProxy(user: string, passw: string, geo: string)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (endpoint === 1) {
|
||||||
|
headers = {
|
||||||
|
Authorization: 'Basic dC1rZGdwMmg4YzNqdWI4Zm4wZnE6eWZMRGZNZnJZdktYaDRKWFMxTEVJMmNDcXUxdjVXYW4=',
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
|
'User-Agent': 'Crunchyroll/1.8.0 Nintendo Switch/12.3.12.0 UE4/4.27'
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -183,6 +211,23 @@ async function crunchyLoginFetch(user: string, passw: string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (endpoint === 1) {
|
||||||
|
headers = {
|
||||||
|
Authorization: 'Basic dC1rZGdwMmg4YzNqdWI4Zm4wZnE6eWZMRGZNZnJZdktYaDRKWFMxTEVJMmNDcXUxdjVXYW4=',
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
|
'User-Agent': 'Crunchyroll/1.8.0 Nintendo Switch/12.3.12.0 UE4/4.27'
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -328,7 +373,8 @@ export async function crunchyGetPlaylist(q: string, geo: string | undefined) {
|
|||||||
|
|
||||||
const headersLoc = {
|
const headersLoc = {
|
||||||
Authorization: `Bearer ${login.access_token}`,
|
Authorization: `Bearer ${login.access_token}`,
|
||||||
'X-Cr-Disable-Drm': 'true'
|
'X-Cr-Disable-Drm': 'true',
|
||||||
|
'User-Agent': 'Crunchyroll/1.8.0 Nintendo Switch/12.3.12.0 UE4/4.27',
|
||||||
}
|
}
|
||||||
|
|
||||||
var playlist: VideoPlaylist
|
var playlist: VideoPlaylist
|
||||||
@ -379,7 +425,8 @@ export async function crunchyGetPlaylist(q: string, geo: string | undefined) {
|
|||||||
|
|
||||||
const headers = {
|
const headers = {
|
||||||
Authorization: `Bearer ${logindata.access_token}`,
|
Authorization: `Bearer ${logindata.access_token}`,
|
||||||
'X-Cr-Disable-Drm': 'true'
|
'X-Cr-Disable-Drm': 'true',
|
||||||
|
'User-Agent': 'Crunchyroll/1.8.0 Nintendo Switch/12.3.12.0 UE4/4.27',
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
@ -434,7 +481,8 @@ export async function deleteVideoToken(content: string, token: string) {
|
|||||||
if (!login) return
|
if (!login) return
|
||||||
|
|
||||||
const headers = {
|
const headers = {
|
||||||
Authorization: `Bearer ${login.access_token}`
|
Authorization: `Bearer ${login.access_token}`,
|
||||||
|
'User-Agent': 'Crunchyroll/1.8.0 Nintendo Switch/12.3.12.0 UE4/4.27',
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -473,7 +521,8 @@ export async function crunchyGetPlaylistMPD(q: string, geo: string | undefined)
|
|||||||
if (!login) return
|
if (!login) return
|
||||||
|
|
||||||
const headers = {
|
const headers = {
|
||||||
Authorization: `Bearer ${login.access_token}`
|
Authorization: `Bearer ${login.access_token}`,
|
||||||
|
'User-Agent': 'Crunchyroll/1.8.0 Nintendo Switch/12.3.12.0 UE4/4.27',
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Reference in New Issue
Block a user