Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mymusiclist
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Brian Guadalupe
mymusiclist
Commits
92469da4
Commit
92469da4
authored
Nov 03, 2017
by
Brian Guadalupe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Parse the song data to populate the songs table, fixes issue
#4
parent
64829ae8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
populate_songs.py
SQL/populate_songs.py
+30
-0
No files found.
SQL/populate_songs.py
0 → 100644
View file @
92469da4
# run in Django shell ONLY!!!
# python manage.py shell
# >>> exec(open('./SQL/populate_songs.py').read())
from
core.models
import
*
def
extract_song_title
(
s
):
clean
=
[]
i
=
1
for
t
in
s
.
split
(
' ÷'
):
if
t
==
''
:
continue
u
=
t
.
strip
(
'
\n
'
)
.
split
()
if
u
[
0
]
==
'.flac'
or
u
[
0
]
==
'.mp3'
or
u
[
0
]
==
'.dts'
:
clean
.
append
(
' '
.
join
(
t
.
strip
(
'
\n
'
)
.
split
()[
2
:])[:
-
len
(
u
[
0
])])
i
+=
1
return
clean
def
prettify_genre
(
g
):
return
', '
.
join
([
h
.
replace
(
'_'
,
' '
)
for
h
in
g
.
split
()])
for
song
in
Song
.
objects
.
filter
(
song_name__startswith
=
"."
):
songlst
=
extract_song_title
(
song
.
song_name
)
for
e
in
songlst
:
Song
.
objects
.
create
(
song_name
=
e
,
genre
=
prettify_genre
(
song
.
genre
),
artist
=
song
.
artist
,
album
=
song
.
album
)
# uncomment the next line if you want to delete the original entry after parsing
# song.delete()
# if something messed up above, uncomment these lines
# for song in Song.objects.exclude(song_name__startswith="."):
# song.delete()
\ No newline at end of file
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