You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

52 lines
1.0 KiB

import json
import time
from subprocess import run
ACRONYM = "sch"
FORMATS = {
"opus": ["-b:a", "48k"],
"m4a": [
"-b:a",
"48k",
"-f",
"ipod",
"-profile:a",
"aac_he",
"-disposition:v:0",
"attached_pic",
],
"oga": ["-b:a", "64k", "-c:a", "libvorbis"],
"mp3": ["-b:a", "96k", "-map", "0:0", "-map", "1:0"],
}
def path_to_episode(name, format):
if format in ["flac", "md"]:
base = "content"
else:
base = "static/episodes"
return f"{base}/{name}.{format}"
def get_episode_info(name, format):
path = path_to_episode(name, format)
return json.loads(
run(
[
"ffprobe",
"-loglevel",
"error",
"-show_format",
"-print_format",
"json",
path,
],
capture_output=True,
).stdout
)["format"]
def sexagesimal(ts):
return time.strftime("%H:%M:%S", time.gmtime(ts)) + str(round(ts % 1, 3))[1:]