Skip to content

Commit

Permalink
loadVideo do not need to be in try catch block
Browse files Browse the repository at this point in the history
  • Loading branch information
mateussouzaweb committed Jun 5, 2022
1 parent a73e73b commit e7c8fc6
Showing 1 changed file with 27 additions and 33 deletions.
60 changes: 27 additions & 33 deletions src/scripts/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,48 +99,42 @@ const loadVideo = async () => {
'media.series_name'
]

try {

const response = await Api.request('POST', '/info', {
media_id: episodeId,
fields: fields.join(',')
})

if (response.error
&& response.code == 'bad_session') {
await Api.tryLogin()
return loadVideo()
}
const response = await Api.request('POST', '/info', {
media_id: episodeId,
fields: fields.join(',')
})

if (response.error && response.message) {
throw new Error(response.message)
}
if (response.error
&& response.code == 'bad_session') {
await Api.tryLogin()
return loadVideo()
}

const serieName = response.data.series_name
const episodeName = response.data.name
if (response.error && response.message) {
throw new Error(response.message)
}

const serieId = Number(response.data.series_id)
const collectionId = Number(response.data.collection_id)
const episodeNumber = Number(response.data.episode_number)
const serieName = response.data.series_name
const episodeName = response.data.name

serie.innerHTML = serieName + ' / Episode ' + episodeNumber
title.innerHTML = episodeName
const serieId = Number(response.data.series_id)
const collectionId = Number(response.data.collection_id)
const episodeNumber = Number(response.data.episode_number)

let startTime = response.data.playhead || 0
let duration = response.data.duration || 0
serie.innerHTML = serieName + ' / Episode ' + episodeNumber
title.innerHTML = episodeName

if (startTime / duration > 0.90 || startTime < 30) {
startTime = 0
}
let startTime = response.data.playhead || 0
let duration = response.data.duration || 0

streams = response.data.stream_data.streams
video.currentTime = startTime
if (startTime / duration > 0.90 || startTime < 30) {
startTime = 0
}

loadClosestEpisodes(serieId, collectionId, episodeNumber)
streams = response.data.stream_data.streams
video.currentTime = startTime

} catch (error) {
showError(error.message)
}
loadClosestEpisodes(serieId, collectionId, episodeNumber)

}

Expand Down

0 comments on commit e7c8fc6

Please sign in to comment.