mirror of
https://github.com/meeb/tubesync.git
synced 2025-06-25 06:26:37 +00:00
Merge pull request #572 from jameswlane/main
Add Support for TUBESYNC_DIRECTORY_PREFIX Environment Variable
This commit is contained in:
commit
a8997400b2
3
.gitignore
vendored
3
.gitignore
vendored
@ -134,3 +134,6 @@ dmypy.json
|
|||||||
|
|
||||||
Pipfile.lock
|
Pipfile.lock
|
||||||
.vscode/launch.json
|
.vscode/launch.json
|
||||||
|
|
||||||
|
# Ignore Jetbrains IDE files
|
||||||
|
.idea/
|
10
README.md
10
README.md
@ -362,7 +362,7 @@ There are a number of other environment variables you can set. These are, mostly
|
|||||||
useful if you are manually installing TubeSync in some other environment. These are:
|
useful if you are manually installing TubeSync in some other environment. These are:
|
||||||
|
|
||||||
| Name | What | Example |
|
| Name | What | Example |
|
||||||
| --------------------------- | ------------------------------------------------------------ | ------------------------------------ |
|
| --------------------------- | ------------------------------------------------------------ |--------------------------------------|
|
||||||
| DJANGO_SECRET_KEY | Django's SECRET_KEY | YJySXnQLB7UVZw2dXKDWxI5lEZaImK6l |
|
| DJANGO_SECRET_KEY | Django's SECRET_KEY | YJySXnQLB7UVZw2dXKDWxI5lEZaImK6l |
|
||||||
| DJANGO_URL_PREFIX | Run TubeSync in a sub-URL on the web server | /somepath/ |
|
| DJANGO_URL_PREFIX | Run TubeSync in a sub-URL on the web server | /somepath/ |
|
||||||
| TUBESYNC_DEBUG | Enable debugging | True |
|
| TUBESYNC_DEBUG | Enable debugging | True |
|
||||||
@ -376,7 +376,15 @@ useful if you are manually installing TubeSync in some other environment. These
|
|||||||
| HTTP_PASS | Sets the password for HTTP basic authentication | some-secure-password |
|
| HTTP_PASS | Sets the password for HTTP basic authentication | some-secure-password |
|
||||||
| DATABASE_CONNECTION | Optional external database connection details | mysql://user:pass@host:port/database |
|
| DATABASE_CONNECTION | Optional external database connection details | mysql://user:pass@host:port/database |
|
||||||
| VIDEO_HEIGHT_CUTOFF | Smallest video height in pixels permitted to download | 240 |
|
| VIDEO_HEIGHT_CUTOFF | Smallest video height in pixels permitted to download | 240 |
|
||||||
|
| TUBESYNC_DIRECTORY_PREFIX | Controls how downloaded files are organized. | true |
|
||||||
|
|
||||||
|
# TubeSync Directory Mode
|
||||||
|
|
||||||
|
Controls how downloaded files are organized.
|
||||||
|
|
||||||
|
Values:
|
||||||
|
- true: Audio files go to `audio`, video files to `video`.
|
||||||
|
- false: All files are placed in the root of DOWNLOAD_DIR.
|
||||||
|
|
||||||
# Manual, non-containerised, installation
|
# Manual, non-containerised, installation
|
||||||
|
|
||||||
|
@ -6,7 +6,9 @@
|
|||||||
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
from pathlib import Path
|
||||||
from urllib.parse import urlsplit
|
from urllib.parse import urlsplit
|
||||||
from xml.etree import ElementTree
|
from xml.etree import ElementTree
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@ -1714,3 +1716,31 @@ class TasksTestCase(TestCase):
|
|||||||
self.assertEqual(src1.media_source.all().count(), 3)
|
self.assertEqual(src1.media_source.all().count(), 3)
|
||||||
self.assertEqual(src2.media_source.all().count(), 2)
|
self.assertEqual(src2.media_source.all().count(), 2)
|
||||||
self.assertEqual(Media.objects.filter(pk=m22.pk).exists(), False)
|
self.assertEqual(Media.objects.filter(pk=m22.pk).exists(), False)
|
||||||
|
|
||||||
|
class TypeDirectoryPathTestCase(TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.source = Source(
|
||||||
|
directory="test_directory",
|
||||||
|
source_resolution=Source.SOURCE_RESOLUTION_AUDIO,
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_directory_prefix_default(self):
|
||||||
|
"""
|
||||||
|
Test that default directory prefix exist.
|
||||||
|
"""
|
||||||
|
os.environ['TUBESYNC_DIRECTORY_PREFIX'] = ''
|
||||||
|
self.assertEqual(self.source.type_directory_path, Path(settings.DOWNLOAD_AUDIO_DIR) / 'test_directory')
|
||||||
|
|
||||||
|
def test_directory_prefix_true(self):
|
||||||
|
"""
|
||||||
|
Test that when TUBESYNC_DIRECTORY_PREFIX is set to true the directory prefix exist.
|
||||||
|
"""
|
||||||
|
os.environ['TUBESYNC_DIRECTORY_PREFIX'] = 'true'
|
||||||
|
self.assertEqual(self.source.type_directory_path, Path(settings.DOWNLOAD_AUDIO_DIR) / 'test_directory')
|
||||||
|
|
||||||
|
def test_directory_prefix_false(self):
|
||||||
|
"""
|
||||||
|
Test that when TUBESYNC_DIRECTORY_PREFIX is set to false the directory prefix does not exist.
|
||||||
|
"""
|
||||||
|
os.environ['TUBESYNC_DIRECTORY_PREFIX'] = 'false'
|
||||||
|
self.assertEqual(self.source.type_directory_path, Path('.') / 'test_directory')
|
@ -112,6 +112,10 @@ DOWNLOAD_VIDEO_DIR = 'video'
|
|||||||
DOWNLOAD_AUDIO_DIR = 'audio'
|
DOWNLOAD_AUDIO_DIR = 'audio'
|
||||||
SASS_PROCESSOR_ROOT = STATIC_ROOT
|
SASS_PROCESSOR_ROOT = STATIC_ROOT
|
||||||
|
|
||||||
|
directory_prefix = os.getenv('TUBESYNC_DIRECTORY_PREFIX', 'true')
|
||||||
|
if directory_prefix == 'false':
|
||||||
|
DOWNLOAD_VIDEO_DIR = '.'
|
||||||
|
DOWNLOAD_AUDIO_DIR = '.'
|
||||||
|
|
||||||
ROBOTS = '''
|
ROBOTS = '''
|
||||||
User-agent: *
|
User-agent: *
|
||||||
|
Loading…
Reference in New Issue
Block a user