lets-read project
This commit is contained in:
4
projects/lets-read/build.hxml
Normal file
4
projects/lets-read/build.hxml
Normal file
@@ -0,0 +1,4 @@
|
||||
-lib kiss
|
||||
-cp src
|
||||
--main lets_read.Main
|
||||
--interp
|
17
projects/lets-read/haxelib.json
Normal file
17
projects/lets-read/haxelib.json
Normal 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"
|
||||
}
|
28
projects/lets-read/lets-read.sh
Normal file
28
projects/lets-read/lets-read.sh
Normal 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
|
11
projects/lets-read/src/lets_read/Main.hx
Normal file
11
projects/lets-read/src/lets_read/Main.hx
Normal 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 {}
|
25
projects/lets-read/src/lets_read/Main.kiss
Normal file
25
projects/lets-read/src/lets_read/Main.kiss
Normal 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
|
||||
```))))
|
3
projects/lets-read/test.sh
Normal file
3
projects/lets-read/test.sh
Normal file
@@ -0,0 +1,3 @@
|
||||
#! /bin/bash
|
||||
|
||||
haxe build.hxml
|
Reference in New Issue
Block a user