<tr><th>duration:</th><td>{{video_data.duration}}</td></tr>
<tr><th>definition:</th><td>{{video_data.definition}}</td></tr>
<tr><th>YouTube ID:</th><td>{{video_data.id_}} (<a href="{{youtube_prefix}}{{video_data.id_}}">watch</a>)</td></tr>
-<tr><th>download:</th><td>{% if is_temp %}working on it{% else %}<a href="/{{page_names.download}}/{{video_data.id_}}">{{ file_path if file_path else "please do" }}</a>{% endif %}</td></tr>
+<tr><th>download:</th><td>{% if is_temp %}working on it{% elif file_path %}<a href="/{{page_names.file}}/{{file_digest}}">{{file_path}}</a>{% else %}<a href="/{{page_names.download}}/{{video_data.id_}}">please do</a>{% endif %}</td></tr>
<tr>
<th>linked queries:</th>
<td>
try:
with DbConn() as conn:
file_data = VideoFile.get_by_yt_id(conn, video_id)
+ if file_data.missing:
+ raise NotFoundException
+ self._redirect(Path('/')
+ .joinpath(PAGE_NAMES['file'])
+ .joinpath(file_data.digest.b64))
except NotFoundException:
self.server.downloads.queue_download(video_id)
self._redirect(Path('/')
.joinpath(PAGE_NAMES['yt_result'])
.joinpath(video_id))
- return
- with file_data.full_path.open('rb') as video_file:
- self._send_http(content=video_file.read())
def _send_yt_query_page(self, query_id: QueryId) -> None:
with DbConn() as conn:
video_data = YoutubeVideo.get_one(conn, video_id)
except NotFoundException:
video_data = YoutubeVideo(video_id)
+ file_digest: Optional[str]
+ file_path: Optional[Path]
try:
file = VideoFile.get_by_yt_id(conn, video_id)
- file_path = file.full_path if file.present else None
+ file_digest = file.digest.b64
+ file_path = file.rel_path if file.present else None
except NotFoundException:
- file_path = None
+ file_path, file_digest = None, None
self._send_rendered_template(
_NAME_TEMPLATE_YT_VIDEO,
{'video_data': video_data,
'is_temp': video_id in self.server.downloads.ids_unfinished,
+ 'file_digest': file_digest,
'file_path': file_path,
'youtube_prefix': YOUTUBE_URL_PREFIX,
'queries': linked_queries})