mirror of
https://github.com/meeb/tubesync.git
synced 2025-06-23 13:36:35 +00:00
Reorganize misc.py
This commit is contained in:
parent
26372efe25
commit
0d1f066fce
@ -1,16 +1,19 @@
|
||||
# These are referenced from the migration files
|
||||
|
||||
from .misc import (
|
||||
from ._migrations import (
|
||||
get_media_file_path,
|
||||
get_media_thumb_path,
|
||||
media_file_storage,
|
||||
)
|
||||
|
||||
# The actual model classes
|
||||
# The order starts with independent classes
|
||||
# then the classes that depend on them follow.
|
||||
|
||||
from .media import Media
|
||||
from .source import Source
|
||||
from .metadata import Metadata
|
||||
from .metadata_format import MetadataFormat
|
||||
from .media_server import MediaServer
|
||||
|
||||
from .source import Source
|
||||
from .media import Media
|
||||
from .metadata import Metadata
|
||||
from .metadata_format import MetadataFormat
|
||||
|
||||
|
@ -1,18 +1,9 @@
|
||||
from pathlib import Path
|
||||
from django.conf import settings
|
||||
from django.core.files.storage import FileSystemStorage
|
||||
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 _nfo_element(nfo, label, text, /, *, attrs={}, tail='\n', char=' ', indent=2):
|
||||
element = nfo.makeelement(label, attrs)
|
||||
element.text = text
|
||||
element.tail = tail + (char * indent)
|
||||
return element
|
||||
|
||||
|
||||
def get_media_file_path(instance, filename):
|
12
tubesync/sync/models/_private.py
Normal file
12
tubesync/sync/models/_private.py
Normal file
@ -0,0 +1,12 @@
|
||||
from ..choices import Val, YouTube_SourceType
|
||||
|
||||
|
||||
_srctype_dict = lambda n: dict(zip( YouTube_SourceType.values, (n,) * len(YouTube_SourceType.values) ))
|
||||
|
||||
|
||||
def _nfo_element(nfo, label, text, /, *, attrs={}, tail='\n', char=' ', indent=2):
|
||||
element = nfo.makeelement(label, attrs)
|
||||
element.text = text
|
||||
element.tail = tail + (char * indent)
|
||||
return element
|
||||
|
@ -26,11 +26,11 @@ from ..matching import (get_best_combined_format, get_best_audio_format,
|
||||
get_best_video_format)
|
||||
from ..choices import ( Val, Fallback, MediaState, SourceResolution,
|
||||
YouTube_AudioCodec, YouTube_VideoCodec)
|
||||
from .source import Source
|
||||
from .misc import (
|
||||
media_file_storage, _srctype_dict, _nfo_element,
|
||||
get_media_thumb_path, get_media_file_path,
|
||||
from ._migrations import (
|
||||
media_file_storage, get_media_thumb_path, get_media_file_path,
|
||||
)
|
||||
from ._private import _srctype_dict, _nfo_element
|
||||
from .source import Source
|
||||
|
||||
|
||||
class Media(models.Model):
|
||||
|
@ -20,7 +20,8 @@ from ..youtube import (
|
||||
get_media_info as get_youtube_media_info,
|
||||
get_channel_image_info as get_youtube_channel_image_info,
|
||||
)
|
||||
from .misc import _srctype_dict, media_file_storage
|
||||
from ._migrations import media_file_storage
|
||||
from ._private import _srctype_dict
|
||||
|
||||
|
||||
class Source(db.models.Model):
|
||||
|
Loading…
Reference in New Issue
Block a user