Skip to content

Commit

Permalink
Added m4a support and fixed cue creation
Browse files Browse the repository at this point in the history
Web site change broke the addition of the short URL. Should find a more rigorous solution in the long run using regex.
  • Loading branch information
globalnomad committed Feb 20, 2019
1 parent 86766a2 commit 1d9a560
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 43 deletions.
18 changes: 9 additions & 9 deletions quickCUE.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ def __init__(self, master):

# Pack into center_text (which is in bot_text_frame)
self.appInfo = Button(self.center_text, text='About', fg='blue', bg=self.bg_light, font=('Segoe UI', 8, 'underline'), borderwidth=0, cursor='hand2', command=self.info, takefocus=0)
self.version = Label(self.center_text, text='v1.0.0', bg=self.bg_light)
self.version = Label(self.center_text, text='v1.1.0', bg=self.bg_light)
self.appHelp = Button(self.center_text, text='Help', fg='blue', bg=self.bg_light, font=('Segoe UI', 8, 'underline'), borderwidth=0, cursor='hand2', command=self.help, takefocus=0)
self.appInfo.pack(side=RIGHT, padx=1, pady=(5, 10))
self.version.pack(side=RIGHT, pady=(5, 10))
Expand All @@ -436,16 +436,16 @@ def acquireAudioFile(self):
messagebox.showwarning('Bad file', 'Please select an MP3, FLAC, M4A or WAV file.')
logging.warning(f'Failed to import file. {me}\n')
if file:
if self.filepath.get()[-4:].lower() is not '.m4a':
if self.filepath.get()[-4:].lower() != '.m4a':
self.artistvar.set(file.get('artist')[0])
self.titlevar.set(file.get('title')[0])
self.yearvar.set(file.get('date'))
self.genrevar.set(file.get('genre'))
else:
self.artistvar.set(file.get('')[0])
self.titlevar.set(file.get('')[0])
self.yearvar.set(file.get(''))
self.genrevar.set(file.get(''))
self.artistvar.set(file.get('\xa9ART')[0])
self.titlevar.set(file.get('\xa9nam')[0])
self.yearvar.set(file.get('\xa9day'))
self.genrevar.set(file.get('\xa9gen'))
filename = self.filepath.get().split("/")[-1]
if len(filename) > 70:
chars_to_remove = (len(filename) - 68) // 2
Expand Down Expand Up @@ -510,13 +510,13 @@ def save_cue(self, website=None, soup=None):
filename = self.filepath.get().split('/')[-1]
else:
filename = '[PLEASE MANUALLY INSERT FILENAME]'
filetypes = {'wav': 'WAVE', 'lac': 'WAVE', 'mp3': 'MP3', 'ME]': '[INSERT FILE TYPE]'}
filetypes = {'wav': 'WAVE', 'lac': 'WAVE', 'm4a' : 'WAVE', 'mp3': 'MP3', 'ME]': '[INSERT FILE TYPE]'}

try:
file.write(f'REM GENRE {genre}\n')
file.write(f'REM DATE {year}\n')
if website:
short_url = soup.find('td', text='short url').next_sibling.next_sibling.contents[0]['href']
short_url = 'https://' + soup.find('td', text='short link').next_sibling.next_sibling.text.strip()
file.write(f'REM WWW {short_url}\n')
file.write(f'PERFORMER "{artist}"\n')
file.write(f'TITLE "{title}"\n')
Expand All @@ -531,7 +531,7 @@ def save_cue(self, website=None, soup=None):
logging.info('CUE creation successful.')
except Exception as e:
success = False
exception = e.args[1]
exception = e.args[0]
logging.warning(f'Error during creation of CUE. {exception}')
finally:
file.close()
Expand Down
76 changes: 42 additions & 34 deletions scrap.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,42 @@
from re import MULTILINE, findall, search

# test string
teststring = "00:00 test me - testerroo [ANJUNADEEP]\n01. boerd - Fragment II [ANJUNADEEP]\n[7:18] Timecop1983 - Tonight\n[11:21] Padai - Iglu [SUDBEAT]\n[17:22] Röyksopp - Sordid Affair [DOG TRIUMPH]\n[22:25] Libranine - Orca [GHOST DIGITAL]\n[28:11] Forerunners - Just For A While [PURE PROGRESSIVE]\n[35:16] Karmon - Eleventh Hour [DIYNAMIC]\n[40:40] Acid Pauli - Nana [PAMPA]\n[46:15] ID - ID\n[51:55] Van der Trip - Lunar Trip [1.2. TRIP]\n[57:21] Paul Oakenfold ft. Carla Werner - Southern Sun (Solarstone After Hours Mix) (Robert Nickson pres. RNX Edit) [PERFECTO]\n[1:03:40] Lunar Park - Tantra [BONZAI PROG]\n[1:08:30] Boris Brejcha - Pillenkäfer [FCKNG SERIOUS]\n[1:13:06] Orkidea - Forward Forever [PURE PROGRESSIVE]\n[1:18:37] Gordey Tsukanov - Opacity (Solarstone Retouch) [PURE PROGRESSIVE]\n[1:26:14] Kate Bush - Running Up That Hill (Orkidea Pure Progressive Mix) [EMI]\n[1:30:42] Solarstone & RABBII - Untitled Love (Nude Mix) [BLACK HOLE]\n[1:38:27] Markus Schulz pres. Dakota - Future Shock [COLDHARBOUR]\n[1:43:25] Solarstone ft. Clare Stagg - Requiem [BLACK HOLE]\n[1:50:32] Salt Tank - Phoenix (Allende Remix EA3 Reconstruction) [PURE TRANCE]\n[1:58:42] Solarstone - Nothing But Chemistry Here [BLACK HOLE]\n[2:05:35] Robert Nickson pres. RNX - Atoms [PURE PROGRESSIVE]\n[2:09:46] Gabriel & Dresden ft. Sub Teal - White Walls [ANJUNABEATS]\n[2:14:37] Solarstone - Leap Of Faith [PURE TRANCE]\nw/ Snap! - Rhythm Is A Dancer (Acappella) [ARISTA]\n[2:19:54] Solarstone & John 00 Fleming - Hemispheres [PURE TRANCE]\nw/ Depeche Mode - Never Let Me Down Again (Acappella)\n[2:28:00] Nugen - Deliverance (Forerunners Remix) [TOUCHSTONE]\n[2:35:12] Solarstone & Gai Barone - Fata Morgana [PURE PROGRESSIVE]\n[2:42:28] Gai Barone - Shiny [PURE PROGRESSIVE]\nw/ Frankie Goes To Hollywood - Relax (Acappella)\n[2:49:06] Solarstone - Spectrum [SOLARIS]\n[2:54:37] Jam & Spoon - Odyssey To Anyoona (Airwave Remix) [COLDHARBOUR]\n[3:01:37] ID - ID\n[3:06:28] Solarstone & Orkidea - Slowmotion IV [BLACK HOLE]\n[3:13:55] ReOrder - Beyond Time [PURE TRANCE]\n[3:19:40] Röyksopp - I Had This Thing (Solarstone Remix) [DOG TRIUMPH]\n[3:26:24] David Broaders - Swelter [PURE TRANCE]\n[3:29:47] Neil Bamford - They Are There [PURE TRANCE]\n[3:36:23] Solarstone & Clare Stagg - The Spell (Solarstone Pure Mix) [BLACK HOLE]\n[3:42:30] Craig Connelly - New York Sunday [PURE TRANCE]\n[3:46:45] Salt Tank - Eugina (Ciaran McAuley Remix) [GROTESQUE REWORKED]\nw/ Salt Tank - Eugina (Salt Tank Reactivation Mix) [GROTESQUE REWORKED]\n[3:53:04] Allende - 10 Minutes To Infinity [PURE TRANCE]\n[3:58:43] Armin van Buuren ft. Josh Cumbee - Sunny Days (Pure NRG Remix) [ARMIND]\n[4:03:00] Solarstone - Shield (Part II) [BLACK HOLE]\n[4:12:58] Solarstone & Betsie Larkin - Breathe You In (Solarstone Pure Mix) [PREMIER]\n[4:18:49] Ferry Corsten & Paul Oakenfold - A Slice Of Heaven [FLASHOVER]\n[4:24:56] Solarstone - Seven Cities (Solarstone Pure Mix) [ARMADA CAPTIVATING]\n[4:32:21] Solarstone ft. Jonathan Mendelsohn - This Is Where It Starts [BLACK HOLE]\n[4:39:15] Ciaran McAuley - Maria [PURE TRANCE]\n[4:43:00] Bicep - Glue [NINJA]\n[4:46:44] Solarstone - Thank You [BLACK HOLE]\n[4:52:58] Craig Connelly ft. Jessica Lawrence - How Can I (John O'Callaghan Remix) [SUBCULTURE]\n[4:56:40] Pure NRG - Scarlett [BLACK HOLE]\n[5:01:17] a-ha - Take On Me (Robert Nickson Bootleg) [WARNER BROS.]\n[5:05:15] Lostly - Colourways [PURE TRANCE]\n[5:10:25] Scott Bond vs. Solarstone - Red Line Highway (Factor B Back To The Future Mix) (Solarstone Edit) [ARMADA]\n[5:16:29] Sied Van Riel - Atomic Blonde [PURE TRANCE]\n[5:21:43] Martin Roth's Hands On Keane - This Is The Last Time\n[5:27:16] System F ft. Armin van Buuren - Exhale (Elucidus Bootleg Remix) (Solarstone Edit) [PURE TRANCE]\n[5:31:40] Solarstone & Meredith Call - I Found You (Giuseppe Ottaviani Remix) [BLACK HOLE]\n[5:37:12] Faithless - Insomnia (Danny Eaton Rework) [SONY BMG]\n[5:42:00] Solarstone - Motif [PURE TRANCE]\n[5:48:48] Solarstone & Iko - Once (Solarstone Pure Mix) [BLACK HOLE]\n[5:55:36] Solarstone ft. Lucia Holme - The Last Defeat Pt II (Royal Sapien Remix) [SOLARIS]\n[6:02:33] Push - Universal Nation (Gai Barone Remix) [BONZAI]\nw/ Solarstone - Solarcoaster [LOST LANGUAGE]\n[6:09:43] Sasha - Xpander [DECONSTRUCTION]"


# Add ? after the first grouping to also find w/ tracks and tracks w/o cuetimes (e.g. 01. artist - title)
# match = search(r'(?P<cuetime>w/|\[?(\d?:?\d+:\d+)\]?)? (?P<artist>.*) - (?P<title>[^\[\]]+).*$', teststring, MULTILINE)
match = findall(r'\[?(w/|\d?:?\d+:\d+)?\]? (.*) - ([^\[\]\n]+).*$', teststring, MULTILINE)
#groups = match.groups()
tracks = []
for item in match:
# tracks.append({'cue':item[0], 'artist':item[1], 'title':item[2].strip()})
print(item)
# for item in tracks:
# print(item)

#import times from audacity label file
with open('labels.txt', 'r') as audacity_labels:
cuetimes = []
for line in audacity_labels:
time = float(line.split()[0])
min = str(int(time // 60)).zfill(2)
sec = str(int(time) % 60).zfill(2)
frm = str(int((time - int(time))*75)).zfill(2)
cuetimes.append(f'{min}:{sec}:{frm}')

print(cuetimes)

m, s = int(1) * 60 + int(23), 43

print(f'{m}:{s}')

Paul van Dyk - Music Rescues Me Album Launch at Printworks, London (Oct 12, 2018).mp3
class track():
total_tracks = 0
def __init__(self, artist, title, cuetime):
self.__artist = artist
self.__title = title
self.__cuetime = cuetime
self.__trackNumber = track.total_tracks + 1
self.__trackID = track.total_tracks + 1
track.total_tracks += 1
def updateTrackNumber(self, tracklist):
difference = self.trackNumber - tracklist.index(self)
if difference != 1:
self.trackNumber -= difference-1
else:
pass
def adjust_cuetime(self, min_adj, sec_adj, early_or_late):
adjustment = int(min_adj) * 60 + int(sec_adj)
if self.__cuetime:
split_cue = self.__cuetime.split(':')
cue_secs = int(split_cue[0]) * 60 + int(split_cue[1])
if early_or_late == '-':
cue_secs -= adjustment
if cue_secs < 0:
cue_secs = 0
else:
cue_secs += adjustment
self.__cuetime =':'.join([str(cue_secs // 60).zfill(2), str(cue_secs % 60).zfill(2), '00'])
else:
pass
def clean_cuetime(self, cuetime=None):
if cuetime:
self.__cuetime = cuetime
else:
if self.trackNumber == '01' and not self.__cuetime:
self.__cuetime = '00:00:00'
elif self.__cuetime.count(':') == 1:
min_sec = self.__cuetime.split(':')
self.__cuetime = '{0}:{1}:00'.format(min_sec[0].zfill(2), min_sec[1])
else:
hms = self.__cuetime.split(':')
m, s = int(hms[0]) * 60 + int(hms[1]), hms[2]
self.__cuetime = f'{m}:{s}:00'

0 comments on commit 1d9a560

Please sign in to comment.