From 3edf9ba34c080ad7b83cd085106f3a80424c9199 Mon Sep 17 00:00:00 2001 From: Jan Date: Wed, 25 Sep 2019 12:32:18 +0200 Subject: [PATCH] 1st test of track stuff --- clockytracklist.py | 63 ++++++++++++++++++++++++++++++++++++++++++++++ tracktest.py | 7 ++++++ 2 files changed, 70 insertions(+) create mode 100644 clockytracklist.py create mode 100644 tracktest.py diff --git a/clockytracklist.py b/clockytracklist.py new file mode 100644 index 0000000..8141b3a --- /dev/null +++ b/clockytracklist.py @@ -0,0 +1,63 @@ +#!/usr/bin/python + +import json +import os +import time +import copy + +EXTENSIONS=("mp3","ogg","wav","mpa","m4a","flac") + +class ClockyTracklist: + """read and monitor directory with audio files""" + + def __init__(self,path="."): + """do the reading""" + self.path=path + self.tracklist=[] + self.pathlist=[] + self.count=0 + + olddir=os.getcwd() + if(self.path != '.'): + if(not os.path.isdir(self.path)): + print("ERROR: \""+self.path+"\" is not an existing directory") + exit(); + os.chdir(self.path) + + for ent in os.listdir(): + if ent.lower().endswith(EXTENSIONS) and os.access(ent,os.R_OK): + self.tracklist.append(ent) + self.pathlist.append(os.path.join(self.path,ent)) + self.count+=1 + + os.chdir(olddir) + + + def Show(self): + """Print the list""" + print("Tracklist.path = %s" %self.path) + print("Tracklist.count= %d" %self.count) + print("Tracks:") + for track in self.tracklist: + + print (" "+track) + fn=self.path+'\\'+track + if os.access(fn,os.R_OK): + print(fn+"!") + else: + print(fn+"-") + fn=self.path+'/'+track + if os.access(fn,os.R_OK): + print(fn+"!") + else: + print(fn+"-") + + print("Paths:") + for track in self.pathlist: + print (" "+track) + + f=open(track,"r") + if(f): + print("OK") + f.close() + diff --git a/tracktest.py b/tracktest.py new file mode 100644 index 0000000..5751684 --- /dev/null +++ b/tracktest.py @@ -0,0 +1,7 @@ +#!/usr/bin/python + +import clockytracklist + + +tl=clockytracklist.ClockyTracklist("mp3") +tl.Show()