mirror of
https://github.com/daniel-j/fimfic2epub.git
synced 2024-05-18 19:33:38 +12:00
Add Fimfiction category/subject. Add version number to EPUB metadata.
This commit is contained in:
parent
e32517e9dc
commit
8801ee398a
|
@ -49,6 +49,9 @@ webpackConfig.forEach((c) => {
|
|||
}))
|
||||
}
|
||||
}
|
||||
c.plugins.push(new webpack.DefinePlugin({
|
||||
FIMFIC2EPUB_VERSION: JSON.stringify(require('./package.json').version)
|
||||
}))
|
||||
})
|
||||
|
||||
const wpCompiler = webpack(webpackConfig)
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
"standard": {
|
||||
"env": {
|
||||
"browser": true
|
||||
}
|
||||
},
|
||||
"globals": ["FIMFIC2EPUB_VERSION"]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,14 +36,14 @@ module.exports = class FimFic2Epub {
|
|||
return sanitize(storyInfo.title + ' by ' + storyInfo.author.name + '.epub')
|
||||
}
|
||||
|
||||
static fetchStoryInfo (storyId) {
|
||||
static fetchStoryInfo (storyId, raw = false) {
|
||||
return new Promise((resolve, reject) => {
|
||||
storyId = FimFic2Epub.getStoryId(storyId)
|
||||
let url = 'https://www.fimfiction.net/api/story.php?story=' + storyId
|
||||
fetchRemote(url, (raw, type) => {
|
||||
fetchRemote(url, (content, type) => {
|
||||
let data
|
||||
try {
|
||||
data = JSON.parse(raw)
|
||||
data = JSON.parse(content)
|
||||
} catch (e) {}
|
||||
if (!data) {
|
||||
reject('Unable to fetch story info')
|
||||
|
@ -54,6 +54,10 @@ module.exports = class FimFic2Epub {
|
|||
return
|
||||
}
|
||||
let story = data.story
|
||||
if (raw) {
|
||||
resolve(story)
|
||||
return
|
||||
}
|
||||
// this is so the metadata can be cached.
|
||||
if (!story.chapters) story.chapters = []
|
||||
delete story.likes
|
||||
|
@ -64,7 +68,9 @@ module.exports = class FimFic2Epub {
|
|||
story.chapters.forEach((ch) => {
|
||||
delete ch.views
|
||||
})
|
||||
resolve(data.story)
|
||||
// Add version number
|
||||
story.FIMFIC2EPUB_VERSION = FIMFIC2EPUB_VERSION
|
||||
resolve(story)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
@ -116,10 +116,11 @@ export function createOpf (ffc) {
|
|||
m('dc:source', ffc.storyInfo.url),
|
||||
m('dc:language', 'en'),
|
||||
m('meta', {name: 'cover', content: 'cover'}),
|
||||
m('meta', {property: 'dcterms:modified'}, new Date(ffc.storyInfo.date_modified * 1000).toISOString().replace('.000', ''))
|
||||
m('meta', {property: 'dcterms:modified'}, new Date(ffc.storyInfo.date_modified * 1000).toISOString().replace('.000', '')),
|
||||
m('dc:subject', 'Fimfiction')
|
||||
].concat(ffc.categories.map((tag) =>
|
||||
m('dc:subject', tag.name)
|
||||
))),
|
||||
), m('meta', {name: 'fimfic2epub version', content: FIMFIC2EPUB_VERSION}))),
|
||||
|
||||
m('manifest', [
|
||||
m('item', {id: 'ncx', href: 'toc.ncx', 'media-type': 'application/x-dtbncx+xml'}),
|
||||
|
|
Loading…
Reference in a new issue