mirror of
https://github.com/foo-dogsquared/dotfiles.git
synced 2025-01-30 22:57:54 +00:00
Update bangs and split-album
This commit is contained in:
parent
085c17c26d
commit
c13705fffb
@ -1,5 +1,6 @@
|
||||
{
|
||||
"alacritty": "$HOME/.config/alacritty/",
|
||||
"bangs": "$HOME/.config/bangs/",
|
||||
"bin": "$HOME/.local/bin/",
|
||||
"bspwm": "$HOME/.config/bspwm/",
|
||||
"dunst": "$HOME/.config/dunst/",
|
||||
|
12
bin/bangs
12
bin/bangs
@ -66,6 +66,9 @@ const bangs_placeholder = "${BANGS_PLACEHOLDER:-{{{s}}}}"
|
||||
const bangs_format = / %start $bangs_prefix !space+ %end /
|
||||
const valid_bangs = %()
|
||||
const search_query = %()
|
||||
|
||||
# Config file detection.
|
||||
# Otherwise, we'll just use the default config.
|
||||
if test -f $config_file {
|
||||
json read :bangs < $config_file
|
||||
} else {
|
||||
@ -75,7 +78,7 @@ if test -f $config_file {
|
||||
# Stolen from https://gist.github.com/cdown/1163649 and https://gist.github.com/cdown/1163649#gistcomment-1256298
|
||||
proc urlencode(msg) {
|
||||
for (i in 0:len(msg)) {
|
||||
var char = msg[i - 1]
|
||||
var char = msg[i]
|
||||
|
||||
case $char {
|
||||
[a-zA-Z0-9.~_-])
|
||||
@ -112,12 +115,15 @@ for i in @ARGV {
|
||||
}
|
||||
}
|
||||
|
||||
var query = $(printf "%s " @search_query)
|
||||
var query = join(search_query, " ")
|
||||
var encoded_query = $(urlencode $query)
|
||||
|
||||
warnf "Search query is '%s'" $query
|
||||
warnf "Encoded form is '%s'" $encoded_query
|
||||
|
||||
for bang in @valid_bangs {
|
||||
var metadata = bangs[bang]
|
||||
var url = $(write -- ${metadata['url']} | sed --expression "s/${bangs_placeholder}/$(urlencode $query)/")
|
||||
var url = $(write -- ${metadata['url']} | sed --expression "s/${bangs_placeholder}/${encoded_query}/")
|
||||
|
||||
handlr open $url
|
||||
}
|
||||
|
@ -5,12 +5,16 @@
|
||||
# It could also accept an OPML through stdin.
|
||||
|
||||
import itertools
|
||||
import fileinput
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
filename = sys.argv[1]
|
||||
opml = ET.parse(filename)
|
||||
if len(sys.argv) > 1:
|
||||
opml = ET.parse(sys.argv[1])
|
||||
else:
|
||||
opml = ET.fromstring(fileinput.input())
|
||||
|
||||
for outline in opml.findall("body/outline"):
|
||||
categories = [category.strip("/") for category in outline.get("category", "").split(",") if category]
|
||||
print('{xmlUrl} "~{text}" {category}'.format(xmlUrl = outline.get("xmlUrl"),
|
||||
|
@ -4,6 +4,8 @@
|
||||
shopt --set strict:all
|
||||
|
||||
const show_help = "A small script for splitting files into tracks, perfect for full album releases and audiobooks.
|
||||
Based from Luke Smith's booksplit script
|
||||
(https://raw.githubusercontent.com/LukeSmithxyz/voidrice/091d7e54c5c1ed77201ce1254aa2623a2801c9f2/.local/bin/booksplit).
|
||||
|
||||
split-album [options...] [\$ALBUM_FILE \$TIMESTAMP_FILE]
|
||||
|
||||
@ -183,6 +185,7 @@ setvar output_data['extension'] = $EXTENSION
|
||||
const timestamp_regex = / %start digit{2,} ':' digit{2} ':' digit{2} <'.' digit+>? %end /
|
||||
var has_error = false
|
||||
|
||||
# Deserialize the given input into the chapters data.
|
||||
case $(file --mime-type --brief $timestamp_file) {
|
||||
"application/json")
|
||||
json read :chapters < $timestamp_file
|
||||
@ -190,7 +193,7 @@ case $(file --mime-type --brief $timestamp_file) {
|
||||
;;
|
||||
|
||||
# Also cleans up the timestamp file with comments (i.e., lines starting with '#') and empty lines allowing for more commenting options.
|
||||
# I just want to improve the timestamp format (a little bit).
|
||||
# I just want to improve the timestamp format a little bit.
|
||||
"text/plain")
|
||||
sed --regexp-extended --expression '/^\s*$/d' --expression '/^#/d' $timestamp_file | while read --line {
|
||||
var chapter = {}
|
||||
@ -227,6 +230,7 @@ for index in @(seq $[chapter_len]) {
|
||||
var filename = $(printf "%.2d-%s.%s" $index $(kebab-case ${chapter['title']}) $EXTENSION)
|
||||
setvar output_data['chapters'][index - 1]['file'] = filename
|
||||
|
||||
# Check for incorrect timestamp order.
|
||||
if (start > end and end is not null) {
|
||||
warnf '%s (start) is ahead compared to %s (end)' $start $end
|
||||
setvar has_error = true
|
||||
|
Loading…
Reference in New Issue
Block a user