Handle removed youtube videos. Fixes #14

This commit is contained in:
daniel-j 2016-09-08 20:58:32 +02:00
parent e1d6647411
commit b2b6cb010d
2 changed files with 6 additions and 6 deletions

View file

@ -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 {

View file

@ -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},