Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
django-panik-emissions
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
radiopanik
django-panik-emissions
Commits
22e81694
Commit
22e81694
authored
Dec 26, 2019
by
fred
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
load-from-drupal-json: load soundfiles
parent
6500a7ef
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
1 deletion
+15
-1
emissions/management/commands/load-from-drupal-json.py
emissions/management/commands/load-from-drupal-json.py
+15
-1
No files found.
emissions/management/commands/load-from-drupal-json.py
View file @
22e81694
...
...
@@ -11,7 +11,7 @@ from django.core.management.base import BaseCommand, CommandError
from
django.utils.text
import
slugify
from
django.utils.timezone
import
make_naive
from
...models
import
Emission
,
Episode
,
Diffusion
from
...models
import
Emission
,
Episode
,
Diffusion
,
SoundFile
class
Command
(
BaseCommand
):
...
...
@@ -79,3 +79,17 @@ class Command(BaseCommand):
diffusion
=
Diffusion
(
episode
=
episode
)
diffusion
.
datetime
=
start_datetime
diffusion
.
save
()
if
episode_data
.
get
(
'sound'
)
and
not
episode
.
has_sound
():
orig_path
=
'media/sounds.orig/%s/%s'
%
(
emission
.
slug
,
episode_data
.
get
(
'sound'
).
split
(
'/'
)[
-
1
])
if
not
default_storage
.
exists
(
orig_path
):
response
=
requests
.
get
(
episode_data
.
get
(
'sound'
))
if
response
.
status_code
==
200
:
path
=
default_storage
.
save
(
'sounds.orig/%s/%s'
%
(
emission
.
slug
,
episode_data
.
get
(
'sound'
).
split
(
'/'
)[
-
1
]),
ContentFile
(
response
.
content
))
soundfile
=
SoundFile
(
episode
=
episode
,
podcastable
=
True
,
fragment
=
False
,
title
=
episode
.
title
)
soundfile
.
file
=
default_storage
.
open
(
path
)
soundfile
.
save
()
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