mirror of
https://github.com/daniel-j/fimfic2epub.git
synced 2024-06-23 08:30:20 +12:00
Handle removed youtube videos. Fixes #14
This commit is contained in:
parent
e1d6647411
commit
b2b6cb010d
|
@ -222,7 +222,7 @@ class FimFic2Epub extends Emitter {
|
|||
this.chapters[index] = chapter
|
||||
|
||||
completeCount++
|
||||
this.progress(0, completeCount / chapterCount, 'Fetched chapter ' + (completeCount) + ' / ' + chapters.length)
|
||||
this.progress(0, completeCount / chapterCount, 'Fetched chapter ' + (completeCount) + ' / ' + chapterCount)
|
||||
if (completeCount < chapterCount) {
|
||||
recursive()
|
||||
} else {
|
||||
|
|
|
@ -67,17 +67,15 @@ export function cleanMarkup (html) {
|
|||
|
||||
function getYoutubeInfo (ids) {
|
||||
fetch('https://www.googleapis.com/youtube/v3/videos?id=' + ids + '&part=snippet&maxResults=50&key=' + youtubeKey).then((raw) => {
|
||||
let data
|
||||
let data = []
|
||||
try {
|
||||
data = JSON.parse(raw).items
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
} catch (e) { }
|
||||
data.forEach((video) => {
|
||||
cache.set(video.id, video.snippet)
|
||||
completeCount++
|
||||
})
|
||||
if (completeCount === cache.size) {
|
||||
if (completeCount === cache.size || data.length === 0) {
|
||||
html = html.replace(matchYoutube, replaceYoutube)
|
||||
continueParsing()
|
||||
}
|
||||
|
@ -96,6 +94,8 @@ export function cleanMarkup (html) {
|
|||
thumbnail = (data.thumbnails.standard || data.thumbnails.high || data.thumbnails.medium || data.thumbnails.default).url
|
||||
title = data.title
|
||||
caption = data.title + ' on YouTube'
|
||||
} else {
|
||||
return ''
|
||||
}
|
||||
return render(m('figure.youtube', [
|
||||
m('a', {href: youtubeUrl},
|
||||
|
|
Loading…
Reference in a new issue