using os.path.split() instead of regex (#375)
This commit is contained in:
parent
f67e837cd9
commit
f046a3c177
@ -84,22 +84,23 @@ class FileItem(BaseItem):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def _get_info_from_tag(self):
|
def _get_info_from_tag(self):
|
||||||
match = re.search(r"(.+)\/(.+)\.(.+)", self.uri())
|
path, file_name_ext = os.path.split(self.uri())
|
||||||
assert match is not None
|
file_name, ext = os.path.splitext(file_name_ext)
|
||||||
|
|
||||||
file_path = match[1] + '/'
|
assert path is not None and file_name is not None
|
||||||
file_name = match[2]
|
|
||||||
ext = match[3]
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
im = None
|
im = None
|
||||||
path_thumbnail = file_path + file_name + ".jpg"
|
path_thumbnail = os.path.join(path, file_name + ".jpg")
|
||||||
|
|
||||||
if os.path.isfile(path_thumbnail):
|
if os.path.isfile(path_thumbnail):
|
||||||
im = Image.open(path_thumbnail)
|
im = Image.open(path_thumbnail)
|
||||||
elif os.path.isfile(file_path + "cover.jpg"):
|
else:
|
||||||
im = Image.open(file_path + "cover.jpg")
|
path_thumbnail = os.path.join(path, "cover.jpg")
|
||||||
|
if os.path.isfile(path_thumbnail):
|
||||||
|
im = Image.open(path_thumbnail)
|
||||||
|
|
||||||
if ext == "mp3":
|
if ext == ".mp3":
|
||||||
# title: TIT2
|
# title: TIT2
|
||||||
# artist: TPE1, TPE2
|
# artist: TPE1, TPE2
|
||||||
# album: TALB
|
# album: TALB
|
||||||
@ -114,7 +115,7 @@ class FileItem(BaseItem):
|
|||||||
if "APIC:" in tags:
|
if "APIC:" in tags:
|
||||||
im = Image.open(BytesIO(tags["APIC:"].data))
|
im = Image.open(BytesIO(tags["APIC:"].data))
|
||||||
|
|
||||||
elif ext == "m4a" or ext == "m4b" or ext == "mp4" or ext == "m4p":
|
elif ext == ".m4a" or ext == ".m4b" or ext == ".mp4" or ext == ".m4p":
|
||||||
# title: ©nam (\xa9nam)
|
# title: ©nam (\xa9nam)
|
||||||
# artist: ©ART
|
# artist: ©ART
|
||||||
# album: ©alb
|
# album: ©alb
|
||||||
@ -129,7 +130,7 @@ class FileItem(BaseItem):
|
|||||||
if "covr" in tags:
|
if "covr" in tags:
|
||||||
im = Image.open(BytesIO(tags["covr"][0]))
|
im = Image.open(BytesIO(tags["covr"][0]))
|
||||||
|
|
||||||
elif ext == "opus":
|
elif ext == ".opus":
|
||||||
# title: 'title'
|
# title: 'title'
|
||||||
# artist: 'artist'
|
# artist: 'artist'
|
||||||
# album: 'album'
|
# album: 'album'
|
||||||
@ -162,7 +163,7 @@ class FileItem(BaseItem):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
if not self.title:
|
if not self.title:
|
||||||
self.title = os.path.basename(file_path + file_name)
|
self.title = file_name
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _prepare_thumbnail(im):
|
def _prepare_thumbnail(im):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user