remember video progress, #build

Changes:
- merges video progress API endpoint
- merges fix for auto subscribe reset of playlists
- merges fix for ffmpeg install link builder
This commit is contained in:
simon 2022-02-24 09:43:04 +07:00
commit a25b101c3a
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
3 changed files with 17 additions and 15 deletions

View File

@ -16,7 +16,7 @@ RUN apt-get clean && apt-get -y update && apt-get -y install --no-install-recomm
RUN if [ "$TARGETPLATFORM" = "linux/amd64" ] ; then \
curl -s https://api.github.com/repos/yt-dlp/FFmpeg-Builds/releases/latest \
| grep browser_download_url \
| grep linux64-gpl-4.4.tar.xz \
| grep ".*master.*linux64.*tar.xz" \
| cut -d '"' -f 4 \
| xargs curl -L --output ffmpeg.tar.xz && \
tar -xf ffmpeg.tar.xz --strip-components=2 --no-anchored -C /usr/bin/ "ffmpeg" && \

View File

@ -100,43 +100,42 @@ class VideoApiView(ApiBaseView):
return Response(self.response, status=self.status_code)
class VideoProgressView(APIView):
class VideoProgressView(ApiBaseView):
"""resolves to /api/video/<video_id>/
handle progress status for video
"""
@staticmethod
def get(request, video_id):
def get(self, request, video_id):
"""get progress for a single video"""
user_id = request.user.id
key = f"{user_id}:progress:{video_id}"
video_progress = RedisArchivist().get_message(key)
position = video_progress.get("position", 0)
progress = {
self.response = {
"youtube_id": video_id,
"user_id": user_id,
"position": position,
}
return Response(progress)
return Response(self.response)
@staticmethod
def post(request, video_id):
def post(self, request, video_id):
"""set progress position in redis"""
position = request.data.get("position", 0)
key = f"{request.user.id}:progress:{video_id}"
message = {"position": position}
RedisArchivist().set_message(key, message, expire=False)
self.response = request.data
return Response(request.data)
return Response(self.response)
@staticmethod
def delete(request, video_id):
def delete(self, request, video_id):
"""delete progress position"""
key = f"{request.user.id}:progress:{video_id}"
RedisArchivist().del_message(key)
self.response = {"progress-reset": video_id}
return Response({"progress-reset": video_id})
return Response(self.response)
class ChannelApiView(ApiBaseView):

View File

@ -35,8 +35,11 @@ class YoutubePlaylist(YouTubeItem):
def build_json(self, scrape=False):
"""collection to create json_data"""
if not scrape:
self.get_from_es()
self.get_from_es()
if self.json_data:
subscribed = self.json_data.get("playlist_subscribed")
else:
subscribed = False
if scrape or not self.json_data:
self.get_from_youtube()
@ -44,13 +47,13 @@ class YoutubePlaylist(YouTubeItem):
self.get_entries()
self.json_data["playlist_entries"] = self.all_members
self.get_playlist_art()
self.json_data["playlist_subscribed"] = subscribed
def process_youtube_meta(self):
"""extract relevant fields from youtube"""
self.json_data = {
"playlist_id": self.youtube_id,
"playlist_active": True,
"playlist_subscribed": False,
"playlist_name": self.youtube_meta["title"],
"playlist_channel": self.youtube_meta["channel"],
"playlist_channel_id": self.youtube_meta["channel_id"],