Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
strolchibot
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dnns01
strolchibot
Commits
7245bbb7
Commit
7245bbb7
authored
3 years ago
by
dnns01
Browse files
Options
Downloads
Patches
Plain Diff
Make clip controls optional
parent
350c3f1c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
strolchguru/templates/strolchguru_home.html
+3
-1
3 additions, 1 deletion
strolchguru/templates/strolchguru_home.html
strolchguru/views.py
+10
-7
10 additions, 7 deletions
strolchguru/views.py
with
13 additions
and
8 deletions
strolchguru/templates/strolchguru_home.html
+
3
−
1
View file @
7245bbb7
...
@@ -37,12 +37,14 @@
...
@@ -37,12 +37,14 @@
<body
style=
"background: black;"
>
<body
style=
"background: black;"
>
<video
id=
"clip"
autoplay
<video
id=
"clip"
autoplay
controls
{%
if
controls
%}
controls
{%
endif
%}
{%
if
mode =
=
"
loop
"
%}
{%
if
mode =
=
"
loop
"
%}
loop
loop
{%
else
%}
{%
else
%}
onended=
"window.location.reload(true)"
onended=
"window.location.reload(true)"
{%
endif
%}
{%
endif
%}
src=
"/media/clips/{{ clip.clip_id }}.mp4"
>
src=
"/media/clips/{{ clip.clip_id }}.mp4"
>
</video>
</video>
<div
id=
"caption"
>
<div
id=
"caption"
>
...
...
This diff is collapsed.
Click to expand it.
strolchguru/views.py
+
10
−
7
View file @
7245bbb7
import
random
import
random
from
django.forms.models
import
model_to_dict
from
django.forms.models
import
model_to_dict
from
django.http
import
HttpResponse
,
JsonResponse
from
django.http
import
HttpResponse
,
JsonResponse
,
Http404
from
django.shortcuts
import
render
,
get_object_or_404
from
django.shortcuts
import
render
,
get_object_or_404
from
.models
import
Clip
from
.models
import
Clip
def
home
(
request
)
->
HttpResponse
:
def
home
(
request
)
->
HttpResponse
:
controls
=
True
if
request
.
GET
.
get
(
"
controls
"
)
==
"
1
"
else
False
clips
=
list
(
Clip
.
objects
.
filter
(
is_published
=
True
,
is_downloaded
=
True
))
clips
=
list
(
Clip
.
objects
.
filter
(
is_published
=
True
,
is_downloaded
=
True
))
clip
=
random
.
choice
(
clips
)
clip
=
random
.
choice
(
clips
)
return
render
(
request
,
'
strolchguru_home.html
'
,
context
=
{
'
clip
'
:
clip
,
'
mode
'
:
"
random_clips
"
})
return
render
(
request
,
'
strolchguru_home.html
'
,
context
=
{
'
clip
'
:
clip
,
'
mode
'
:
"
random_clips
"
,
'
controls
'
:
controls
})
def
clip
(
request
,
id
)
->
HttpResponse
:
def
clip
(
request
,
id
)
->
HttpResponse
:
controls
=
True
if
request
.
GET
.
get
(
"
controls
"
)
==
"
1
"
else
False
clip
=
get_object_or_404
(
Clip
,
pk
=
id
)
clip
=
get_object_or_404
(
Clip
,
pk
=
id
)
return
render
(
request
,
'
strolchguru_home.html
'
,
context
=
{
'
clip
'
:
clip
,
'
mode
'
:
"
loop
"
})
if
not
clip
.
is_published
:
raise
Http404
()
return
render
(
request
,
'
strolchguru_home.html
'
,
context
=
{
'
clip
'
:
clip
,
'
mode
'
:
"
loop
"
,
'
controls
'
:
controls
})
def
clip_json
(
request
,
id
)
->
JsonResponse
:
def
clip_json
(
request
,
id
)
->
JsonResponse
:
...
@@ -25,7 +32,3 @@ def clip_json(request, id) -> JsonResponse:
...
@@ -25,7 +32,3 @@ def clip_json(request, id) -> JsonResponse:
return
JsonResponse
(
json
)
return
JsonResponse
(
json
)
except
Clip
.
DoesNotExist
:
except
Clip
.
DoesNotExist
:
return
JsonResponse
({
"
error
"
:
"
Clip with this id does not exist
"
})
return
JsonResponse
({
"
error
"
:
"
Clip with this id does not exist
"
})
# def clips_today(request) -> HttpResponse:
# clips = twitch_api.get_clips(today=True)
# return render(request, 'strolchguru_home.html', context={'clip': clip, 'url_name': "clips_today"})
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment