Compare commits

..

No commits in common. "master" and "v0.2.0" have entirely different histories.

3 changed files with 8 additions and 42 deletions

1
.gitignore vendored
View file

@ -1 +0,0 @@
__pycache__

View file

@ -2,7 +2,6 @@
# encoding: utf-8
from dataclasses import dataclass
import json
import os
import over
import re
@ -46,19 +45,6 @@ def detect_silence(path, min_length_s=2, level_dB=-32):
return starts
def get_duration(path):
"""
Returns the duration of the media file pointed to by path.
"""
cmd = over.cmd.Command("ffprobe", "-v", "quiet", "-print_format", "json", "-show_format", "INFILE")
cmd.INFILE = "file:" + path
cmd.run()
raw = cmd.get_all_output().decode("utf-8")
dic = json.loads(raw)
return float(dic["format"]["duration"])
def floats(*args):
for arg in args:
yield float(arg)
@ -146,7 +132,7 @@ if __name__ == "__main__":
main.add_option("track-name", "Track name format.", str, ["%n %a - %t.opus"], abbr="t")
main.add_option("verbose", "Print playlist lines as they are being parsed to stderr.", bool, [False], abbr="v")
main.add_doc("Description", ["Takes a playlist and turns it into a shell script that splits a large mix into individual audio files."])
main.add_doc("Playlist", ["Empty lines and those starting with # are ignored. Each line represents a track. The format is: START [DURATION] ARTIST TITLE. Fields are tab-separated."])
main.add_doc("Playlist", ["Empty lines and those starting with # are ignored. Each line represents a track. The format is: START DURATION ARTIST TITLE. Fields are tab-separated."])
main.setup()
## Sanity checks
@ -180,8 +166,6 @@ if __name__ == "__main__":
n += 1
elif main.cfg.playlist:
previous_track = None
with open(main.cfg.playlist) as f:
n = 1
@ -191,36 +175,19 @@ if __name__ == "__main__":
if not line or line[0] == "#":
continue
cols = line.split("\t")
if len(cols) == 3:
start_s, artist, title = cols
duration = None
else:
start_s, duration_s, artist, title = cols
duration = sanitize_timestamp(duration_s)
start_s, duration_s, artist, title = line.split("\t")
start = sanitize_timestamp(start_s)
duration = sanitize_timestamp(duration_s)
track = Track(
tracks.append(Track(
start = start,
duration = duration,
number = n,
artist = artist.strip(),
title = title.strip()
)
))
tracks.append(track)
if previous_track and previous_track.duration is None:
previous_track.duration = track.start - previous_track.start
previous_track = track
n += 1
# if unset, set the last track's duration to the end of file
if tracks[-1].duration is None:
tracks[-1].duration = get_duration(main.cfg.path) - tracks[-1].start
## apply global overrides
##

View file

@ -2,7 +2,7 @@
# encoding: utf-8
major = 0 # VERSION_MAJOR_IDENTIFIER
minor = 3 # VERSION_MINOR_IDENTIFIER
# VERSION_LAST_MM 0.3
minor = 2 # VERSION_MINOR_IDENTIFIER
# VERSION_LAST_MM 0.2
patch = 0 # VERSION_PATCH_IDENTIFIER
str = "0.3.0" # VERSION_STRING_IDENTIFIER
str = "0.2.0" # VERSION_STRING_IDENTIFIER