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-nonstop
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
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-nonstop
Commits
7603eaa5
Commit
7603eaa5
authored
Apr 06, 2015
by
fred
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fill nonstop zone from filepath
parent
55db83d6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
+26
-0
nonstop/management/commands/create_tracks_from_nonstop.py
nonstop/management/commands/create_tracks_from_nonstop.py
+26
-0
No files found.
nonstop/management/commands/create_tracks_from_nonstop.py
View file @
7603eaa5
...
...
@@ -2,17 +2,37 @@ import mutagen
import
os
from
django.core.management.base
import
BaseCommand
,
CommandError
from
django.utils.text
import
slugify
from
...models
import
NonstopFile
,
Track
,
Artist
from
emissions.models
import
Nonstop
LOCAL_BASE_PATH
=
'/media/nonstop/'
REMOTE_BASE_PATH
=
'/srv/soma/nonstop/'
tranche_slug_mapping
=
{
'Acouphene'
:
'acouphene'
,
'Biodiversite'
:
'biodiversite'
,
'Heure_de_pointe'
:
'l-heure-de-pointe'
,
'Hop_Bop_and_co'
:
'hop-bop-co'
,
'la_panique'
:
'la-panique'
,
'Mange_Disque'
:
'le-mange-disque'
,
'Matins_tranquilles'
:
'matin-tranquille'
,
'Reveries'
:
'reveries'
,
'Up_Beat_Tempo'
:
'up-beat-tempo'
}
class
Command
(
BaseCommand
):
def
handle
(
self
,
verbosity
,
**
kwargs
):
self
.
verbose
=
(
int
(
verbosity
)
>
1
)
kwargs
=
{
'track__isnull'
:
True
}
#kwargs = {}
for
tranche_key
,
tranche_value
in
tranche_slug_mapping
.
items
():
try
:
tranche_slug_mapping
[
tranche_key
]
=
Nonstop
.
objects
.
get
(
slug
=
tranche_value
)
except
Nonstop
.
DoesNotExist
:
continue
for
nonstopfile
in
NonstopFile
.
objects
.
filter
(
**
kwargs
):
filepath
=
nonstopfile
.
filepath
.
replace
(
REMOTE_BASE_PATH
,
LOCAL_BASE_PATH
)
if
self
.
verbose
:
...
...
@@ -31,6 +51,12 @@ class Command(BaseCommand):
artist
,
created
=
Artist
.
objects
.
get_or_create
(
name
=
metadata
.
get
(
'artist'
)[
0
])
track
,
created
=
Track
.
objects
.
get_or_create
(
title
=
metadata
.
get
(
'title'
)[
0
],
artist
=
artist
)
if
'/Tranches/'
in
filepath
:
tranche_name
=
filepath
[
filepath
.
find
(
'Tranches/'
):].
split
(
'/'
)[
1
]
try
:
track
.
nonstop_zones
=
[
tranche_slug_mapping
[
tranche_name
]]
except
KeyError
:
pass
if
' FR'
in
filepath
:
track
.
language
=
'fr'
track
.
cfwb
=
(
' CFWB'
in
filepath
)
...
...
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