query cleanup DRY

This commit is contained in:
ThaUnknown 2020-11-18 00:51:07 +01:00
parent 72ef490088
commit 6397430397
2 changed files with 46 additions and 187 deletions

View file

@ -26,7 +26,46 @@ async function alRequest(searchName, method) {
query: query,
variables: variables
})
},
queryObjects = `
id
title {
romaji
english
native
userPreferred
}
description(
asHtml: true
)
season
seasonYear
format
status
episodes
duration
averageScore
genres
coverImage {
extraLarge
medium
color
}
bannerImage
synonyms
nextAiringEpisode {
timeUntilAiring
episode
}
trailer {
id
site
}
streamingEpisodes {
title
thumbnail
}
`
if (localStorage.getItem("ALtoken")) {
options.headers['Authorization'] = localStorage.getItem("ALtoken")
}
@ -36,43 +75,7 @@ async function alRequest(searchName, method) {
query ($page: Int, $perPage: Int, $sort: [MediaSort], $type: MediaType) {
Page (page: $page, perPage: $perPage) {
media(type: $type, sort: $sort) {
id
title {
romaji
english
native
userPreferred
}
description(
asHtml: true
)
season
seasonYear
format
status
episodes
duration
averageScore
genres
coverImage {
extraLarge
medium
color
}
bannerImage
synonyms
nextAiringEpisode {
timeUntilAiring
episode
}
trailer {
id
site
}
streamingEpisodes {
title
thumbnail
}
${queryObjects}
}
}
}`
@ -84,43 +87,7 @@ async function alRequest(searchName, method) {
query ($page: Int, $sort: [MediaSort], $search: String, $type: MediaType, $status: MediaStatus) {
Page (page: $page) {
media (type: $type, search: $search, sort: $sort, status: $status) {
id
title {
romaji
english
native
userPreferred
}
description(
asHtml: true
)
season
seasonYear
format
status
episodes
duration
averageScore
genres
coverImage {
extraLarge
medium
color
}
bannerImage
synonyms
nextAiringEpisode {
timeUntilAiring
episode
}
trailer {
id
site
}
streamingEpisodes {
title
thumbnail
}
${queryObjects}
}
}
}`
@ -131,43 +98,7 @@ async function alRequest(searchName, method) {
query ($page: Int, $perPage: Int, $sort: [MediaSort], $type: MediaType, $search: String) {
Page (page: $page, perPage: $perPage) {
media(type: $type, search: $search, sort: $sort) {
id
title {
romaji
english
native
userPreferred
}
description(
asHtml: true
)
season
seasonYear
format
status
episodes
duration
averageScore
genres
coverImage {
extraLarge
medium
color
}
bannerImage
synonyms
nextAiringEpisode {
timeUntilAiring
episode
}
trailer {
id
site
}
streamingEpisodes {
title
thumbnail
}
${queryObjects}
}
}
}`
@ -179,43 +110,7 @@ async function alRequest(searchName, method) {
query ($page: Int, $sort: [MediaSort], $search: String, $type: MediaType) {
Page (page: $page) {
media (type: $type, search: $search, sort: $sort) {
id
title {
romaji
english
native
userPreferred
}
description(
asHtml: true
)
season
seasonYear
format
status
episodes
duration
averageScore
genres
coverImage {
extraLarge
medium
color
}
bannerImage
synonyms
nextAiringEpisode {
timeUntilAiring
episode
}
trailer {
id
site
}
streamingEpisodes {
title
thumbnail
}
${queryObjects}
}
}
}`
@ -224,43 +119,7 @@ async function alRequest(searchName, method) {
query = `
query ($id: Int, $type: MediaType) {
Media (id: $id, type: $type){
id
title {
romaji
english
native
userPreferred
}
description(
asHtml: true
)
season
seasonYear
format
status
episodes
duration
averageScore
genres
coverImage {
extraLarge
medium
color
}
bannerImage
synonyms
nextAiringEpisode {
timeUntilAiring
episode
}
trailer {
id
site
}
streamingEpisodes {
title
thumbnail
}
${queryObjects}
}
}`
}

View file

@ -22,8 +22,8 @@ window.onbeforeunload = () => {
}
const announceList = [
['wss://tracker.openwebtorrent.com'],
['wss://tracker.btorrent.xyz']
['wss://tracker.openwebtorrent.com']
// ['wss://tracker.btorrent.xyz'] // for now disabled cuz broken
// ['wss://tracker.webtorrent.io'],
// ['wss://tracker.fastcast.nz'],
// ['wss://video.blender.org:443/tracker/socket'],