Skip to content

Commit

Permalink
Merge branch 'master' into compatibility-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mateussouzaweb committed Feb 11, 2024
2 parents ac2b596 + bfed36d commit 714329e
Show file tree
Hide file tree
Showing 13 changed files with 161 additions and 109 deletions.
4 changes: 3 additions & 1 deletion src/icons/premium.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/scripts/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const request = async (method: string, endpoint: string, body: any, headers: Hea
}

const result = await fetch(url, requestOptions)

if( result.status === 204 ){
return {} as Result
}
Expand Down Expand Up @@ -323,7 +323,7 @@ const watchlist = async (accessToken: string, accountId: string, filters: Data)
* @returns
*/
const inWatchlist = async (accessToken: string, accountId: string, filters: Data) => {

const headers = {
'Authorization': 'Bearer ' + accessToken,
'Content-Type': 'application/x-www-form-urlencoded'
Expand Down
10 changes: 5 additions & 5 deletions src/scripts/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ const getTemplate = async (name: string, data: any) => {

/**
* Retrieve image information
* @param images
* @returns
* @param images
* @returns
*/
const getImage = (images: any[]) => {

const image = { source: '' }
if( images && images.length ){
image.source = images[0][0].source
}

return image
}

Expand Down Expand Up @@ -589,7 +589,7 @@ const setProgress = async (filters: Data, data: Data) => {
* @returns
*/
const serie = async (serieId: string, filters: Data) => {

await refreshSession()

const accessToken = localStorage.getItem('accessToken')
Expand Down Expand Up @@ -686,7 +686,7 @@ const episode = async (episodeId: string, filters: Data) => {
const accessToken = localStorage.getItem('accessToken')
const preferredContentAudioLanguage = localStorage.getItem('preferredContentAudioLanguage')
const preferredCommunicationLanguage = localStorage.getItem('preferredCommunicationLanguage')

filters['preferred_audio_language'] = preferredContentAudioLanguage
filters['locale'] = preferredCommunicationLanguage

Expand Down
6 changes: 3 additions & 3 deletions src/scripts/explore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ const listResults: Callback = async ({ state, render }) => {

let total = 0
let items = []

// Special listings
if ( category && special ){
const response = await App.browser({
'type': 'series',
'sort_by': sort,
'start': offset.toString(),
'start': offset.toString(),
'n': limit.toString()
})

Expand All @@ -118,7 +118,7 @@ const listResults: Callback = async ({ state, render }) => {
'type': 'series',
'categories': category,
'sort_by': sort,
'start': offset.toString(),
'start': offset.toString(),
'n': limit.toString()
})

Expand Down
17 changes: 9 additions & 8 deletions src/scripts/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,20 @@ const listHistory: Callback = async ({ state, render }) => {
const items = data.filter((item) => {
return item.panel.type === 'episode'
}).map((item) => {
const metadata = item.panel.episode_metadata
return {
id: item.panel.id,
image: App.getImage(item.panel.images.thumbnail).source,
number: item.panel.episode_metadata.episode_number,
number: metadata.episode_number || metadata.episode,
name: item.panel.title,
description: item.panel.description,
duration: item.panel.episode_metadata.duration_ms / 1000,
duration: metadata.duration_ms / 1000,
playhead: item.playhead,
premium: item.panel.episode_metadata.is_premium_only,
season_id: item.panel.episode_metadata.season_id,
season_name: item.panel.episode_metadata.season_title,
serie_id: item.panel.episode_metadata.series_id,
serie_name: item.panel.episode_metadata.series_title,
premium: metadata.is_premium_only,
season_id: metadata.season_id,
season_name: metadata.season_title,
serie_id: metadata.series_id,
serie_name: metadata.series_title,
}
})

Expand All @@ -72,7 +73,7 @@ const listHistory: Callback = async ({ state, render }) => {
})

} catch (error) {

await render({
loaded: true,
error: true,
Expand Down
30 changes: 16 additions & 14 deletions src/scripts/home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,38 +67,40 @@ const listResults: Callback = async ({ state, render }) => {
const history = historyData.filter((item) => {
return item.panel.type === 'episode'
}).map((item) => {
const metadata = item.panel.episode_metadata
return {
id: item.panel.id,
image: App.getImage(item.panel.images.thumbnail).source,
number: item.panel.episode_metadata.episode_number,
number: metadata.episode_number || metadata.episode,
name: item.panel.title,
description: item.panel.description,
duration: item.panel.episode_metadata.duration_ms / 1000,
duration: metadata.duration_ms / 1000,
playhead: item.playhead,
premium: item.panel.episode_metadata.is_premium_only,
season_id: item.panel.episode_metadata.season_id,
season_name: item.panel.episode_metadata.season_title,
serie_id: item.panel.episode_metadata.series_id,
serie_name: item.panel.episode_metadata.series_title,
premium: metadata.is_premium_only,
season_id: metadata.season_id,
season_name: metadata.season_title,
serie_id: metadata.series_id,
serie_name: metadata.series_title,
}
})

const watchlistResponse = await App.watchlist({'n': '4'})
const watchlistData = watchlistResponse.data || []
const watchlist = watchlistData.map((item) => {
const metadata = item.panel.episode_metadata
return {
id: item.panel.id,
image: App.getImage(item.panel.images.thumbnail).source,
number: item.panel.episode_metadata.episode_number,
number: metadata.episode_number || metadata.episode,
name: item.panel.title,
description: item.panel.description,
duration: item.panel.episode_metadata.duration_ms / 1000,
duration: metadata.duration_ms / 1000,
playhead: item.playhead,
premium: item.panel.episode_metadata.is_premium_only,
season_id: item.panel.episode_metadata.season_id,
season_name: item.panel.episode_metadata.season_title,
serie_id: item.panel.episode_metadata.series_id,
serie_name: item.panel.episode_metadata.series_title,
premium: metadata.is_premium_only,
season_id: metadata.season_id,
season_name: metadata.season_title,
serie_id: metadata.series_id,
serie_name: metadata.series_title,
}
})

Expand Down
4 changes: 2 additions & 2 deletions src/scripts/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ const makeLogin: Callback = async ({ element, render }) => {
await App.login(username.value, password.value)
Route.redirect('/home')
} catch (error) {
await render({
message: error.message
await render({
message: error.message
})
}

Expand Down
8 changes: 4 additions & 4 deletions src/scripts/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ const listResults: Callback = async ({ state, render }) => {
const response = await App.search({
'type': 'series',
'q': query,
'start': offset.toString(),
'start': offset.toString(),
'n': limit.toString()
})

const data = {
count: 0,
items: []
const data = {
count: 0,
items: []
}

if( response.data && response.data.length ){
Expand Down
15 changes: 10 additions & 5 deletions src/scripts/serie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,16 @@ const listSerieInfo: Callback = async ({ state }) => {
const seasons = seasonItems.map((item) => {
return {
id: item.id,
name: 'S' + item.season_number + ': ' + item.title
number: item.season_number,
name: item.title
}
})

state.seasons = seasons
state.seasons = seasons.sort((a, b) => {
if(a.number < b.number) { return -1; }
if(a.number > b.number) { return 1; }
return 0;
})

if( !state.seasonId && seasons.length ){
state.seasonId = seasons[0].id
Expand Down Expand Up @@ -171,7 +176,7 @@ const listEpisodes: Callback = async ({ state, render }) => {
return {
id: item.id,
image: App.getImage(item.images.thumbnail).source,
number: item.episode_number,
number: item.episode_number || item.episode,
name: item.title,
description: item.description,
duration: item.duration_ms / 1000,
Expand Down Expand Up @@ -202,7 +207,7 @@ const listEpisodes: Callback = async ({ state, render }) => {
})

} catch (error) {

await render({
loaded: true,
error: true,
Expand All @@ -228,7 +233,7 @@ const onMount: Callback = async (component) => {
const serieId = component.state.serieId
Route.redirect('/serie/' + serieId + '/season/' + target.value)
})

on(element, 'change', 'input#sort', (_event, target: HTMLInputElement) => {
const serieId = component.state.serieId
const seasonId = component.state.seasonId
Expand Down
25 changes: 14 additions & 11 deletions src/scripts/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,11 @@ const loadEpisode: Callback = async ({ state }) => {
const episodeId = state.episodeId
const episodeResponse = await App.episode(episodeId, {})
const episodeInfo = episodeResponse.data[0]
const episodeMetadata = episodeInfo.episode_metadata

const serieName = episodeInfo.episode_metadata.series_title
const seasonNumber = episodeInfo.episode_metadata.season_number
const episodeNumber = Number(episodeInfo.episode_metadata.episode_number)
const serieName = episodeMetadata.series_title
const seasonNumber = episodeMetadata.season_number
const episodeNumber = episodeMetadata.episode_number || episodeMetadata.episode
const episodeName = episodeInfo.title

const streamsLink = String(episodeInfo.streams_link)
Expand Down Expand Up @@ -140,11 +141,12 @@ const loadClosestEpisodes: Callback = async ({ state }) => {

if( previousResponse.data && previousResponse.data.length ){
const item = previousResponse.data[0].panel
const serieId = item.episode_metadata.series_id
const seasonId = item.episode_metadata.season_id
const metadata = item.episode_metadata
const serieId = metadata.series_id
const seasonId = metadata.season_id
const episodeId = item.id
const seasonNumber = item.episode_metadata.season_number
const episodeNumber = item.episode_metadata.episode_number
const seasonNumber = metadata.season_number
const episodeNumber = metadata.episode_number || metadata.episode
const episodeUrl = '/serie/' + serieId + '/season/' + seasonId + '/episode/' + episodeId + '/video'

previous.dataset.url = episodeUrl
Expand All @@ -157,11 +159,12 @@ const loadClosestEpisodes: Callback = async ({ state }) => {

if( nextResponse.data && nextResponse.data.length ){
const item = nextResponse.data[0].panel
const serieId = item.episode_metadata.series_id
const seasonId = item.episode_metadata.season_id
const metadata = item.episode_metadata
const serieId = metadata.series_id
const seasonId = metadata.season_id
const episodeId = item.id
const seasonNumber = item.episode_metadata.season_number
const episodeNumber = item.episode_metadata.episode_number
const seasonNumber = metadata.season_number
const episodeNumber = metadata.episode_number || metadata.episode
const episodeUrl = '/serie/' + serieId + '/season/' + seasonId + '/episode/' + episodeId + '/video'

next.dataset.url = episodeUrl
Expand Down
15 changes: 8 additions & 7 deletions src/scripts/watchlist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,20 @@ const listWatchlist: Callback = async ({ state, render }) => {

const data = response.data || []
const items = data.map((item) => {
const metadata = item.panel.episode_metadata
return {
id: item.panel.id,
image: App.getImage(item.panel.images.thumbnail).source,
number: item.panel.episode_metadata.episode_number,
number: metadata.episode_number || metadata.episode,
name: item.panel.title,
description: item.panel.description,
duration: item.panel.episode_metadata.duration_ms / 1000,
duration: metadata.duration_ms / 1000,
playhead: item.playhead,
premium: item.panel.episode_metadata.is_premium_only,
season_id: item.panel.episode_metadata.season_id,
season_name: item.panel.episode_metadata.season_title,
serie_id: item.panel.episode_metadata.series_id,
serie_name: item.panel.episode_metadata.series_title,
premium: metadata.is_premium_only,
season_id: metadata.season_id,
season_name: metadata.season_title,
serie_id: metadata.series_id,
serie_name: metadata.series_title,
}
})

Expand Down
Loading

0 comments on commit 714329e

Please sign in to comment.