Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tubesync/sync/models/media__tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ def download_finished(self, format_str, container, downloaded_filepath=None):
media.download_date = timezone.now()
media.downloaded_filesize = os.path.getsize(filepath)
media.downloaded_container = container
media.manual_skip = False
media.skip = False
if '+' in format_str:
# Seperate audio and video streams
vformat_code, aformat_code = format_str.split('+')
Expand Down
4 changes: 3 additions & 1 deletion tubesync/sync/templates/sync/media-item.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ <h1 class="truncate">Media <strong>{{ media.key }}</strong> {{ download_state_ic
{% if media.title %}<h2 class="truncate"><strong>{{ media.title }}</strong></h2>{% endif %}
<p class="truncate"><strong><a href="{{ media.url }}" target="_blank"><i class="fas fa-link"></i> {{ media.url }}</a></strong></p>
<p class="truncate">Downloading to: <strong>{{ media.source.directory_path }}</strong></p>
{% if not media.skip and download_state == 'downloaded' %}
{% if download_state == 'downloaded' %}
{% if media.source.is_audio %}
<audio controls src="{% url 'sync:media-content' pk=media.pk %}"></audio>
{% else %}
Expand All @@ -19,6 +19,8 @@ <h1 class="truncate">Media <strong>{{ media.key }}</strong> {{ download_state_ic
{% endif %}

<p class="truncate"><a href="{% url 'sync:media-content' pk=media.pk %}" download="{{ media.filename }}"><strong><i class="fas fa-download"></i> Download</strong></a></p>
{% elif media.can_download %}
<p class="truncate"><a href="{% url 'sync:redownload-media' pk=media.pk %}{% querystring manual=True %}"><strong><i class="fas fa-download"></i> Begin Downloading</strong></a> (please be patient)</p>
{% endif %}
</div>
</div>
Expand Down
16 changes: 15 additions & 1 deletion tubesync/sync/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from .tasks import (
map_task_to_instance, get_error_message,
get_running_tasks, get_media_download_task, get_source_completed_tasks,
check_source_directory_exists, index_source, download_media_image,
check_source_directory_exists, index_source, download_media_image, download_media_file,
)
from .choices import (Val, MediaServerType, SourceResolution, IndexSchedule,
YouTube_SourceType, youtube_long_source_types,
Expand Down Expand Up @@ -686,6 +686,20 @@ def dispatch(self, request, *args, **kwargs):
return super().dispatch(request, *args, **kwargs)

def form_valid(self, form):
# Try to download manually, when can_download was true
media = self.object
if media.can_download:
TaskHistory.schedule(
download_media_file,
str(media.pk),
override=True,
priority=90,
remove_duplicates=True,
retries=3,
retry_delay=600,
vn_fmt=_('Downloading media (manually) for "{}"'),
vn_args=(media.name,),
)
# If the thumbnail file exists on disk, delete it
if self.object.thumb_file_exists:
delete_file(self.object.thumb.path)
Expand Down