lets-read project

This commit is contained in:
2022-06-25 17:18:19 +00:00
parent 736a1982b4
commit 138897008e
6 changed files with 88 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
-lib kiss
-cp src
--main lets_read.Main
--interp

View File

@@ -0,0 +1,17 @@
{
"main": "lets_read.Main",
"name": "lets-read",
"description": "make pdfs for skimming let's play videos",
"classPath": "src/",
"dependencies": {
"kiss": ""
},
"url": "https://github.com/NQNStudios/kisslang",
"contributors": [
"NQNStudios"
],
"version": "0.0.0",
"releasenote": "",
"tags": [],
"license": "LGPL"
}

View File

@@ -0,0 +1,28 @@
#! /bin/bash
# Usage: lets-read.sh <youtube url> <output file without extension> <optional scene change threshold>
if [ ! -e ${2}.mp4 ]; then
youtube-dl $1 -o $2
if [ -e "${2}.mkv" ]; then
ffmpeg -i ${2}.mkv -codec copy ${2}.mp4
rm "${2}.mkv"
elif [ -e "${2}.webm" ]; then
ffmpeg -i ${2}.webm ${2}.mp4
rm "${2}.webm"
fi
fi
threshold=${3:-1} # default 1 fps
if [ ! -d ${2} ]; then
mkdir ${2}
fi
ffmpeg -i ${2}.mp4 -vf "fps=${threshold}" -vsync vfr ${2}/frame-%6d.jpg
rm ${2}/*.txt
haxelib run lets-read ${2}
convert ${2}/frame-*.jpg ${2}.pdf
# rm ${2}/frame-*.jpg

View File

@@ -0,0 +1,11 @@
package lets_read;
import kiss.Kiss;
import kiss.Prelude;
import sys.FileSystem;
import sys.io.File;
using hx.strings.Strings;
using haxe.io.Path;
@:build(kiss.Kiss.build())
class Main {}

View File

@@ -0,0 +1,25 @@
(var THRESHOLD 0.4)
```
echo "\$(pwd)" > g.txt
echo "$(Sys.getCwd)" > g.txt
```
(assertLet [[folder realCwd] (Sys.args)
folder (joinPath realCwd folder)
files (reverse (FileSystem.readDirectory folder))
lastFrame (first files)]
```
cd $folder && tesseract $lastFrame $(lastFrame.withoutExtension)
```
(doFor [after before] (pairs files)
```
cd $folder && tesseract $before $(Path.withoutExtension before)
```
(let [afterText (File.getContent "${folder}/$(Path.withoutExtension after).txt")
beforeText (File.getContent "${folder}/$(Path.withoutExtension before).txt")]
(when (or !beforeText
(< THRESHOLD (kiss.FuzzyMap.fuzzyMatchScore afterText beforeText)))
```
cd $folder && rm $before
```))))

View File

@@ -0,0 +1,3 @@
#! /bin/bash
haxe build.hxml