mediasnacks 0.32.4 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/package.json +1 -1
- package/src/cli.js +2 -1
- package/src/dlaudio.js +4 -9
- package/src/info.js +8 -2
- package/src/seqcheck.js +1 -5
- package/src/tag.osascript +42 -0
- package/src/unemoji.js +4 -3
package/README.md
CHANGED
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -18,7 +18,8 @@ const COMMANDS = {
|
|
|
18
18
|
countframes: ['./countframes.js', 'Counts frames in a video'],
|
|
19
19
|
ssim: ['./ssim.js', 'Computes SSIM between two images'],
|
|
20
20
|
gif: ['./gif.js', 'Video to GIF'],
|
|
21
|
-
info: ['./info.js', 'Prints video stream attributes
|
|
21
|
+
info: ['./info.js', 'Prints video stream attributes'],
|
|
22
|
+
tag: ['./tag.osascript', 'Adds color tag for Finder\n'],
|
|
22
23
|
|
|
23
24
|
detectdups: ['./detectdups.js', 'Detects duplicate frames in a video'],
|
|
24
25
|
dropdups: ['./dropdups.js', 'Removes duplicate frames in a video'],
|
package/src/dlaudio.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { parseOptions } from './utils/parseOptions.js'
|
|
2
|
-
import {
|
|
3
|
-
import { unemoji } from './unemoji.js'
|
|
2
|
+
import { run } from './utils/subprocess.js'
|
|
4
3
|
|
|
5
4
|
|
|
6
5
|
const HELP = `
|
|
@@ -17,18 +16,14 @@ export default async function main() {
|
|
|
17
16
|
if (!positionals[0])
|
|
18
17
|
throw usage('Missing URL')
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
console.log(f)
|
|
19
|
+
await dlaudio(positionals[0])
|
|
22
20
|
}
|
|
23
21
|
|
|
24
22
|
export async function dlaudio(url) {
|
|
25
|
-
|
|
26
|
-
'--print', 'filename',
|
|
23
|
+
await run('yt-dlp', [
|
|
27
24
|
'--no-simulate',
|
|
28
25
|
'-o', '%(title)s.%(ext)s',
|
|
29
26
|
'-f', 'bestaudio[ext=m4a]/bestaudio',
|
|
30
27
|
url
|
|
31
|
-
])
|
|
32
|
-
|
|
33
|
-
return await unemoji(f) || f
|
|
28
|
+
])
|
|
34
29
|
}
|
package/src/info.js
CHANGED
|
@@ -26,11 +26,17 @@ EXAMPLES
|
|
|
26
26
|
DIR=\${FPS}fps
|
|
27
27
|
mkdir -p \$DIR
|
|
28
28
|
mediasnacks info *.* |
|
|
29
|
-
|
|
30
|
-
awk -F\\t '{print $NF}' |
|
|
29
|
+
awk "\\$3==\\"\${FPS}fps\\" { print \\$NF }" |
|
|
31
30
|
while read -r f; do
|
|
32
31
|
mv -- "$f" \$DIR/
|
|
33
32
|
done
|
|
33
|
+
|
|
34
|
+
Tag with "red" (in macOS Finder) 1080 videos:
|
|
35
|
+
COLOR=red
|
|
36
|
+
HEIGHT=1080
|
|
37
|
+
mediasnacks info *.mov |
|
|
38
|
+
awk "\\$2==\$HEIGHT { print \\$NF }" |
|
|
39
|
+
xargs -I{} mediasnacks tag $COLOR "{}"
|
|
34
40
|
`
|
|
35
41
|
|
|
36
42
|
export default async function main() {
|
package/src/seqcheck.js
CHANGED
|
@@ -35,7 +35,7 @@ export function seqcheck(dir, leftDelim = LEFT_DELIM, rightDelim = RIGHT_DELIM)
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
export function extractSeqNums(names, leftDelim, rightDelim) {
|
|
38
|
-
const pattern = new RegExp(
|
|
38
|
+
const pattern = new RegExp(RegExp.escape(leftDelim) + '(\\d+)' + RegExp.escape(rightDelim))
|
|
39
39
|
const seq = []
|
|
40
40
|
for (const name of names) {
|
|
41
41
|
const match = name.match(pattern)
|
|
@@ -54,7 +54,3 @@ export function findMissingNumbers(seq) {
|
|
|
54
54
|
missing.push(i)
|
|
55
55
|
return missing
|
|
56
56
|
}
|
|
57
|
-
|
|
58
|
-
function escapeRegex(str) {
|
|
59
|
-
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
60
|
-
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#!/usr/bin/osascript
|
|
2
|
+
|
|
3
|
+
property colorNames : {"none", "orange", "red", "yellow", "blue", "purple", "green", "gray"}
|
|
4
|
+
|
|
5
|
+
on usage()
|
|
6
|
+
log "USAGE: mediasnacks tag <color> <file>"
|
|
7
|
+
set AppleScript's text item delimiters to " "
|
|
8
|
+
set colorList to colorNames as text
|
|
9
|
+
set AppleScript's text item delimiters to ""
|
|
10
|
+
log "COLORS: " & colorList
|
|
11
|
+
end usage
|
|
12
|
+
|
|
13
|
+
on labelNumForColor(theItem)
|
|
14
|
+
repeat with i from 1 to count of colorNames
|
|
15
|
+
if item i of colorNames as text is theItem as text then
|
|
16
|
+
return i - 1
|
|
17
|
+
end if
|
|
18
|
+
end repeat
|
|
19
|
+
return -1
|
|
20
|
+
end labelNumForColor
|
|
21
|
+
|
|
22
|
+
on run argv
|
|
23
|
+
if (count of argv) < 2 then
|
|
24
|
+
usage()
|
|
25
|
+
return
|
|
26
|
+
end if
|
|
27
|
+
set tagColor to item 1 of argv
|
|
28
|
+
set filePath to item 2 of argv
|
|
29
|
+
|
|
30
|
+
set labelNum to labelNumForColor(tagColor)
|
|
31
|
+
if labelNum is -1 then
|
|
32
|
+
log "invalid color: " & tagColor
|
|
33
|
+
usage()
|
|
34
|
+
return
|
|
35
|
+
end if
|
|
36
|
+
|
|
37
|
+
set theFile to POSIX file filePath as alias
|
|
38
|
+
tell application "Finder"
|
|
39
|
+
set label index of theFile to labelNum
|
|
40
|
+
end tell
|
|
41
|
+
return
|
|
42
|
+
end run
|
package/src/unemoji.js
CHANGED
|
@@ -44,7 +44,7 @@ export default async function main() {
|
|
|
44
44
|
|
|
45
45
|
for (const file of files) {
|
|
46
46
|
const newpath = await unemoji(file)
|
|
47
|
-
if (newpath)
|
|
47
|
+
if (newpath !== file)
|
|
48
48
|
console.log(`Renaming: ${file} -> ${newpath}`)
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -57,10 +57,11 @@ export async function unemoji(file) {
|
|
|
57
57
|
.replace(/\s+/g, ' ')
|
|
58
58
|
.replace(/\s+\./g, '.')
|
|
59
59
|
.trim()
|
|
60
|
+
const newpath = join(dir, newbase)
|
|
61
|
+
|
|
60
62
|
if (base === newbase)
|
|
61
|
-
return
|
|
63
|
+
return newpath
|
|
62
64
|
|
|
63
|
-
const newpath = join(dir, newbase)
|
|
64
65
|
if (existsSync(newpath))
|
|
65
66
|
throw `Skipping (exists): ${file} -> ${newpath}`
|
|
66
67
|
|