mirror of
https://github.com/daniel-j/fimfic2epub.git
synced 2024-05-05 21:12:45 +12:00
restore fetchRemote to fix CORS errors, use Author - Title as default filename
This commit is contained in:
parent
ecf6e43cfd
commit
fa1ba7ac67
|
@ -44,7 +44,7 @@ You can then run the tool it like this:
|
||||||
|
|
||||||
`$ fimfic2epub <story id/url> [<optional filename>]`
|
`$ 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]
|
Usage: fimfic2epub [options] <story> [filename]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "fimfic2epub",
|
"name": "fimfic2epub",
|
||||||
"version": "1.7.48",
|
"version": "1.7.49",
|
||||||
"description": "Tool to generate improved EPUB ebooks from Fimfiction stories",
|
"description": "Tool to generate improved EPUB ebooks from Fimfiction stories",
|
||||||
"author": "djazz",
|
"author": "djazz",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|
|
@ -14,6 +14,7 @@ import { buf as crc32 } from 'crc-32'
|
||||||
|
|
||||||
import { cleanMarkup } from './cleanMarkup'
|
import { cleanMarkup } from './cleanMarkup'
|
||||||
import fetch from './fetch'
|
import fetch from './fetch'
|
||||||
|
import fetchRemote from './fetchRemote'
|
||||||
import * as template from './templates'
|
import * as template from './templates'
|
||||||
import { styleCss, coverstyleCss, titlestyleCss, iconsCss, navstyleCss, paragraphsCss } from './styles'
|
import { styleCss, coverstyleCss, titlestyleCss, iconsCss, navstyleCss, paragraphsCss } from './styles'
|
||||||
import * as utils from './utils'
|
import * as utils from './utils'
|
||||||
|
@ -42,7 +43,7 @@ class FimFic2Epub extends EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
static getFilename (storyInfo) {
|
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) {
|
static fetchStoryInfo (storyId, raw = false) {
|
||||||
|
@ -325,7 +326,7 @@ class FimFic2Epub extends EventEmitter {
|
||||||
|
|
||||||
console.log('Remote file URL: ' + url)
|
console.log('Remote file URL: ' + url)
|
||||||
|
|
||||||
fetch(url, 'arraybuffer').then(async (data) => {
|
fetchRemote(url, 'arraybuffer').then(async (data) => {
|
||||||
r.dest = null
|
r.dest = null
|
||||||
let info = await FileType.fromBuffer(isNode ? data : new Uint8Array(data))
|
let info = await FileType.fromBuffer(isNode ? data : new Uint8Array(data))
|
||||||
if (!info || info.mime === 'application/xml') {
|
if (!info || info.mime === 'application/xml') {
|
||||||
|
@ -746,7 +747,7 @@ class FimFic2Epub extends EventEmitter {
|
||||||
|
|
||||||
this.progress(0, 0, 'Fetching cover image...')
|
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)
|
data = isNode ? data : new Uint8Array(data)
|
||||||
const info = await FileType.fromBuffer(data)
|
const info = await FileType.fromBuffer(data)
|
||||||
if (info) {
|
if (info) {
|
||||||
|
|
|
@ -61,7 +61,10 @@ export default function fetchRemote (url, responseType) {
|
||||||
if (url.startsWith('//')) {
|
if (url.startsWith('//')) {
|
||||||
url = 'https:' + url
|
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 fetchBackground(url, responseType)
|
||||||
}
|
}
|
||||||
return fetch(url, responseType).then((data) => {
|
return fetch(url, responseType).then((data) => {
|
||||||
|
|
Loading…
Reference in a new issue