Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import os
import logging
from UltraStarSongFile import UltraStarSongFile
class FileValidator:
def __init__(self):
pass
def validate(self, songfile_object: UltraStarSongFile):
basepath = os.path.abspath(os.path.dirname(songfile_object.path))
txtfile = os.path.basename(songfile_object.path)
if songfile_object.mp3 != "":
audiopath = os.path.join(basepath, songfile_object.mp3)
if not os.path.isfile(audiopath):
logging.error(f"{txtfile} has invalid mp3.")
return False
else:
logging.error(f"{txtfile} has no mp3!")
return False
if songfile_object.video != "":
logging.info(songfile_object.video)
videopath = os.path.join(basepath, songfile_object.video)
logging.info(videopath)
if not os.path.isfile(videopath):
logging.error(f"{txtfile} has invalid videofile.")
return False
else:
logging.info(f"{txtfile} has no videofile.")
if songfile_object.background != "":
backgroundpath = os.path.join(basepath, songfile_object.background)
if not os.path.isfile(backgroundpath):
logging.error(f"{txtfile} has invalid backgroundfile.")
return False
else:
logging.info(f"{txtfile} has no backgroundfile.")
if songfile_object.cover != "":
coverpath = os.path.join(basepath, songfile_object.cover)
if not os.path.isfile(coverpath):
logging.error(f"{txtfile} has invalid coverfile")
return False
else:
logging.info(f"{txtfile} has no coverfile.")
return True
def validate_mp3(self, songfile_object: UltraStarSongFile):
basepath = os.path.abspath(os.path.dirname(songfile_object.path))
txtfile = os.path.basename(songfile_object.path)
if songfile_object.mp3 != "":
audiopath = os.path.join(basepath, songfile_object.mp3)
if not os.path.isfile(audiopath):
logging.error(f"{txtfile} has invalid mp3.")
return False
else:
logging.error(f"{txtfile} has no mp3!")
return False
return True