mirror of
https://github.com/daniel-j/fimfic2epub.git
synced 2025-04-27 07:07:20 +12:00
restore fetchRemote to fix CORS errors, use Author - Title as default filename
This commit is contained in:
parent
ecf6e43cfd
commit
fa1ba7ac67
4 changed files with 10 additions and 6 deletions
|
@ -44,7 +44,7 @@ You can then run the tool it like this:
|
|||
|
||||
`$ fimfic2epub <story id/url> [<optional filename>]`
|
||||
|
||||
By default the EPUB will be saved in the current working directory with the filename `Title by Author.epub`. Run `fimfic2epub -h` to see a list of all flags.
|
||||
By default the EPUB will be saved in the current working directory with the filename `Author - Title.epub`. Run `fimfic2epub -h` to see a list of all flags.
|
||||
|
||||
```
|
||||
Usage: fimfic2epub [options] <story> [filename]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "fimfic2epub",
|
||||
"version": "1.7.48",
|
||||
"version": "1.7.49",
|
||||
"description": "Tool to generate improved EPUB ebooks from Fimfiction stories",
|
||||
"author": "djazz",
|
||||
"license": "MIT",
|
||||
|
|
|
@ -14,6 +14,7 @@ import { buf as crc32 } from 'crc-32'
|
|||
|
||||
import { cleanMarkup } from './cleanMarkup'
|
||||
import fetch from './fetch'
|
||||
import fetchRemote from './fetchRemote'
|
||||
import * as template from './templates'
|
||||
import { styleCss, coverstyleCss, titlestyleCss, iconsCss, navstyleCss, paragraphsCss } from './styles'
|
||||
import * as utils from './utils'
|
||||
|
@ -42,7 +43,7 @@ class FimFic2Epub extends EventEmitter {
|
|||
}
|
||||
|
||||
static getFilename (storyInfo) {
|
||||
return sanitize(storyInfo.title + ' by ' + storyInfo.author.name + '.epub')
|
||||
return sanitize(storyInfo.author.name + ' - ' + storyInfo.title + '.epub')
|
||||
}
|
||||
|
||||
static fetchStoryInfo (storyId, raw = false) {
|
||||
|
@ -325,7 +326,7 @@ class FimFic2Epub extends EventEmitter {
|
|||
|
||||
console.log('Remote file URL: ' + url)
|
||||
|
||||
fetch(url, 'arraybuffer').then(async (data) => {
|
||||
fetchRemote(url, 'arraybuffer').then(async (data) => {
|
||||
r.dest = null
|
||||
let info = await FileType.fromBuffer(isNode ? data : new Uint8Array(data))
|
||||
if (!info || info.mime === 'application/xml') {
|
||||
|
@ -746,7 +747,7 @@ class FimFic2Epub extends EventEmitter {
|
|||
|
||||
this.progress(0, 0, 'Fetching cover image...')
|
||||
|
||||
this.pcache.coverImage = fetch(url, 'arraybuffer').then(async (data) => {
|
||||
this.pcache.coverImage = fetchRemote(url, 'arraybuffer').then(async (data) => {
|
||||
data = isNode ? data : new Uint8Array(data)
|
||||
const info = await FileType.fromBuffer(data)
|
||||
if (info) {
|
||||
|
|
|
@ -61,7 +61,10 @@ export default function fetchRemote (url, responseType) {
|
|||
if (url.startsWith('//')) {
|
||||
url = 'https:' + url
|
||||
}
|
||||
if (!isNode && document.location.protocol === 'https:' && url.startsWith('http:')) {
|
||||
if (!isNode && document.location.protocol === 'https:') {
|
||||
if (url.startsWith('/')) {
|
||||
url = window.location.origin + url
|
||||
}
|
||||
return fetchBackground(url, responseType)
|
||||
}
|
||||
return fetch(url, responseType).then((data) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue