sya

split youtube audio tracks, with an optional pyqt gui
git clone git://src.gearsix.net/sya
Log | Files | Refs | Atom | README

commit 12f1027241fbba1d483e225a754fd82186f0c877
parent 98d72a422b22a24194b144c23afee741800e72d8
Author: gearsix <gearsix@tuta.io>
Date:   Fri,  7 May 2021 17:22:58 +0100

minor amendment in README, improved regex for catching timestamps

Diffstat:
MREADME.txt | 5++++-
Msya.py | 10++++++----
2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/README.txt b/README.txt @@ -26,6 +26,10 @@ TRACKLIST TRACKLIST files should be text file that has the URL/v=code of the youtube video to download on the first line and the starting timestamp of each section to split, followed by the title of that section section. + + Of course, you don't have to put the timestamp first. sya will try and accomocodate + whatever syntax is used, just beware that this might cause problems. + Here is an example: https://www.youtube.com/watch?v=ors0wpcVDcc @@ -46,7 +50,6 @@ TRACKLIST 35007 - 22 25 & 61 74 [1:31:07] Stoned Cobra - Black Spiral Dancer [1:39:39] U.S. Christmas - Suzerain [1:48:09] - (I fucked up, the picture didn't make it. Comacozer - BinBeal [1:56:53] Kungens Män- Bortkopplad från tiden [2:14:52] The Kings of Frog Island - Laid [2:35:03] diff --git a/sya.py b/sya.py @@ -5,7 +5,7 @@ import subprocess import re import os -Timestamp = re.compile('(:?\d{1,2}){3}') +Timestamp = re.compile('[\[,\(]?(:?\d{1,2}){3}[\],\)]?') class TracklistItem: def __init__(self, timestamp, title): @@ -66,7 +66,9 @@ def load_tracklist(path): tracklist = [] tracklist_file = open(path, mode = 'r') for t in tracklist_file.readlines(): - tracklist.append(t.strip('\n')) + t = t.strip('\n\t ') + if len(t) > 0: + tracklist.append(t) tracklist_file.close() return tracklist @@ -77,9 +79,9 @@ def parse_tracks(tracklist): timestamp = sline[0] for l in sline: # check line in case timestamp is in another element if Timestamp.match(l): - timestamp = l + timestamp = l.strip('[()]') sline.remove(l) - title = ' '.join(sline).strip() + title = ' '.join(sline).strip(' ') if Timestamp.match(timestamp) == None: log('line {}, missing timestamp: "{}"'.format(lcount, line)) timestamp = None