first commit
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
const fs = require('fs');
|
||||
|
||||
function convert( filename, pages ){
|
||||
console.log(pages)
|
||||
if (filename.endsWith('.pdf')) {
|
||||
let data = pages.map( p => "<img src='/"+filename+'-'+p+".jpg'/>").join('<br>')
|
||||
// could have a richer datastructure with e.g. p.number for the page number and p.x and p.y for CSS absolute positioning
|
||||
// probably need to apk add zip then zip the result
|
||||
const outputFile = './public/saved/epub/'+filename+'.epub'
|
||||
fs.writeFileSync(outputFile, data);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.convert = convert
|
||||
@@ -0,0 +1,13 @@
|
||||
const fs = require('fs');
|
||||
|
||||
function convert( filename, pages ){
|
||||
console.log(pages)
|
||||
if (filename.endsWith('.pdf')) {
|
||||
let data = pages.map( p => "<img src='/"+filename+'-'+p+".jpg'/>").join('<br>')
|
||||
// could have a richer datastructure with e.g. p.number for the page number and p.x and p.y for CSS absolute positioning
|
||||
const outputFile = './public/saved/html/'+filename+'.html'
|
||||
fs.writeFileSync(outputFile, data);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.convert = convert
|
||||
@@ -0,0 +1,10 @@
|
||||
const {execSync} = require('child_process')
|
||||
|
||||
function convert( filename, pages ){
|
||||
console.log(pages)
|
||||
if (filename.endsWith('.pdf')) {
|
||||
execSync( 'montage -font /usr/share/fonts/noto/NotoSansSymbols-Regular.ttf -geometry +0+0 -tile 5x '+pages.map( p => filename+'-'+p+'.jpg').join(' ')+' ./saved/montages/'+filename+'montage.jpg', {cwd:'public'})
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.convert = convert
|
||||
@@ -0,0 +1,12 @@
|
||||
const {execSync} = require('child_process')
|
||||
|
||||
function convert( filename ){
|
||||
if (filename.endsWith('.ogg')) {
|
||||
//execSync( 'convert '+filename+' '+filename+'.jpg', {cwd:'public'})
|
||||
execSync( 'ffmpeg -i '+filename+' -ar 16000 -y /tmp/audio_for_tts.wav; LD_LIBRARY_PATH=/usr/app/stt/whisper.cpp/build/bin/ /usr/app/stt/whisper.cpp/build/bin/whisper-cli -f /tmp/audio_for_tts.wav -osrt -m /usr/app/stt/whisper.cpp/models/ggml-base.en.bin; mv /tmp/audio_for_tts.wav.srt '+filename+'.srt', {cwd:'public'})
|
||||
fetch('https://ntfy.benetou.fr/convertedwebdav', { method: 'POST', body: JSON.stringify({source: filename, extension: '.srt' }) })
|
||||
// could also update a file of conversions to keep track of provenance
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.convert = convert
|
||||
@@ -0,0 +1,11 @@
|
||||
const {execSync} = require('child_process')
|
||||
|
||||
function convert( filename ){
|
||||
if (filename.endsWith('.pdf')) {
|
||||
execSync( 'convert '+filename+' '+filename+'.jpg', {cwd:'public'})
|
||||
fetch('https://ntfy.benetou.fr/convertedwebdav', { method: 'POST', body: JSON.stringify({source: filename, extension: '.jpg' }) })
|
||||
// could also update a file of conversions to keep track of provenance
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.convert = convert
|
||||
@@ -0,0 +1,11 @@
|
||||
const {execSync} = require('child_process')
|
||||
|
||||
function convert( filename ){
|
||||
if (filename.endsWith('.pdf')) {
|
||||
execSync( 'node ../extract_as_json.js public/'+filename,{cwd:'public'})
|
||||
fetch('https://ntfy.benetou.fr/convertedwebdav', { method: 'POST', body: JSON.stringify({source: filename, extension: '.json' }) })
|
||||
// could also update a file of conversions to keep track of provenance
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.convert = convert
|
||||
@@ -0,0 +1,11 @@
|
||||
const {execSync} = require('child_process')
|
||||
|
||||
function convert( filename ){
|
||||
if (filename.endsWith('.pdf')) {
|
||||
execSync( 'cp ../../'+filename+' . && pdftohtml -xml '+filename,{cwd:'public/saved/pdfxml'})
|
||||
fetch('https://ntfy.benetou.fr/convertedwebdav', { method: 'POST', body: JSON.stringify({source: filename, extension: '.xml' }) })
|
||||
// could also update a file of conversions to keep track of provenance
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.convert = convert
|
||||
@@ -0,0 +1,11 @@
|
||||
const {execSync} = require('child_process')
|
||||
|
||||
function convert( filename ){
|
||||
if (filename.endsWith('.ppt')) {
|
||||
execSync( 'soffice '+filename+' '+filename+'.jpg', {cwd:'public'})
|
||||
fetch('https://ntfy.benetou.fr/convertedwebdav', { method: 'POST', body: JSON.stringify({source: filename, extension: '.jpg' }) })
|
||||
// could also update a file of conversions to keep track of provenance
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.convert = convert
|
||||
@@ -0,0 +1,10 @@
|
||||
const {execSync} = require('child_process')
|
||||
|
||||
function convert( filename, pages ){
|
||||
console.log(pages)
|
||||
if (filename.endsWith('.pdf')) {
|
||||
execSync( 'qpdf '+filename+' --pages '+filename+' '+pages.join(',')+' -- ./saved/pdf/'+filename, {cwd:'public'})
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.convert = convert
|
||||
Reference in New Issue
Block a user