mirror of
https://github.com/meeb/tubesync.git
synced 2025-06-24 05:56:37 +00:00
Update misc.py
This commit is contained in:
parent
004d98efa5
commit
951b24bbef
@ -1,3 +1,4 @@
|
||||
from pathlib import Path
|
||||
from django.conf import settings
|
||||
from django.core.files.storage import FileSystemStorage
|
||||
from ..choices import Val, YouTube_SourceType
|
||||
@ -6,3 +7,17 @@ from ..choices import Val, YouTube_SourceType
|
||||
media_file_storage = FileSystemStorage(location=str(settings.DOWNLOAD_ROOT), base_url='/media-data/')
|
||||
_srctype_dict = lambda n: dict(zip( YouTube_SourceType.values, (n,) * len(YouTube_SourceType.values) ))
|
||||
|
||||
|
||||
def get_media_file_path(instance, filename):
|
||||
return instance.filepath
|
||||
|
||||
|
||||
def get_media_thumb_path(instance, filename):
|
||||
# we don't want to use alternate names for thumb files
|
||||
if instance.thumb:
|
||||
instance.thumb.delete(save=False)
|
||||
fileid = str(instance.uuid).lower()
|
||||
filename = f'{fileid}.jpg'
|
||||
prefix = fileid[:2]
|
||||
return Path('thumbs') / prefix / filename
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user