Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
C
cp_video_dokku
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alexandr Dzehil
cp_video_dokku
Commits
3c3c8c4f
Commit
3c3c8c4f
authored
Mar 28, 2023
by
Ilya Simonov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add save video to playlist if update playlist
parent
15e41312
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
5 deletions
+24
-5
models.cpython-39.pyc
apps/core/__pycache__/models.cpython-39.pyc
+0
-0
utils.cpython-39.pyc
apps/core/__pycache__/utils.cpython-39.pyc
+0
-0
signals.py
apps/core/signals.py
+4
-1
utils.py
apps/core/utils.py
+20
-4
No files found.
apps/core/__pycache__/models.cpython-39.pyc
View file @
3c3c8c4f
No preview for this file type
apps/core/__pycache__/utils.cpython-39.pyc
View file @
3c3c8c4f
No preview for this file type
apps/core/signals.py
View file @
3c3c8c4f
...
...
@@ -2,7 +2,7 @@ from django.conf import settings
from
django.dispatch
import
receiver
from
django.db.models.signals
import
post_save
from
.
import
models
,
tasks
from
.
import
models
,
tasks
,
utils
@
receiver
(
post_save
,
sender
=
models
.
Video
)
...
...
@@ -17,3 +17,6 @@ def post_save_playlist(sender, instance, created, **kwargs):
instance
.
json
=
f
'{settings.DOMAIN_NAME}/api/playlist/{instance.id}/'
instance
.
mrss
=
f
'{settings.DOMAIN_NAME}/api/playlist/{instance.id}/mrss'
instance
.
save
()
if
instance
.
type
==
models
.
DYNAMIC
:
utils
.
add_video_to_new_playlist
(
instance
)
apps/core/utils.py
View file @
3c3c8c4f
...
...
@@ -6,10 +6,6 @@ from moviepy.editor import VideoFileClip
from
.models
import
Video
,
Playlist
,
TagToObject
,
DYNAMIC
def
asset_upload
(
instance
,
filename
):
return
f
'videos/{filename}'
def
generate_thumbnail
(
video_path
,
video_name
):
clip
=
VideoFileClip
(
video_path
)
thumbnail_name
=
video_name
.
split
(
'.'
)[
0
]
...
...
@@ -41,3 +37,23 @@ def add_video_to_playlist(video):
for
playlist
in
playlists
:
playlist
.
videos
.
add
(
video
)
def
add_video_to_new_playlist
(
playlist
):
video_content_type
=
ContentType
.
objects
.
get_for_model
(
Video
)
playlist_content_type
=
ContentType
.
objects
.
get_for_model
(
Playlist
)
tag_ids
=
list
(
TagToObject
.
objects
.
filter
(
content_type
=
playlist_content_type
,
object_id
=
playlist
.
id
,
)
.
values_list
(
'tag_id'
,
flat
=
True
))
if
tag_ids
:
video_ids
=
list
(
TagToObject
.
objects
.
filter
(
content_type
=
video_content_type
,
tag_id__in
=
tag_ids
,
)
.
values_list
(
'object_id'
,
flat
=
True
))
if
video_ids
:
for
video
in
Video
.
objects
.
filter
(
id__in
=
video_ids
):
playlist
.
videos
.
add
(
video
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment