Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
Old school mix-tape or cd project
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package 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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mathieu Loiseau
Old school mix-tape or cd project
Commits
18ebeb99
Commit
18ebeb99
authored
3 years ago
by
Mathieu Loiseau
Browse files
Options
Downloads
Patches
Plain Diff
author, image, number of tracks
parent
405aea0c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
g_ol_m.py
+4
-1
4 additions, 1 deletion
g_ol_m.py
good_ol_mixtape.py
+20
-9
20 additions, 9 deletions
good_ol_mixtape.py
with
24 additions
and
10 deletions
g_ol_m.py
+
4
−
1
View file @
18ebeb99
...
...
@@ -7,8 +7,11 @@ from good_ol_mixtape import MixTape
parser
=
argparse
.
ArgumentParser
(
description
=
"
Créer une mix-tape
"
)
parser
.
add_argument
(
"
-p
"
,
"
--playlist
"
,
help
=
"
le fichier .m3u8 de la playlist
"
,
type
=
str
)
parser
.
add_argument
(
"
-t
"
,
"
--mix_title
"
,
help
=
"
le titre du mix
"
,
type
=
str
,
default
=
None
)
parser
.
add_argument
(
"
-a
"
,
"
--mix_author
"
,
help
=
"
l
'
auteur du mix
"
,
type
=
str
,
default
=
None
)
parser
.
add_argument
(
"
-i
"
,
"
--mix_image
"
,
help
=
"
la couverture du mix
"
,
type
=
str
,
default
=
None
)
args
=
parser
.
parse_args
()
if
__name__
==
"
__main__
"
:
mx
=
MixTape
(
args
.
playlist
,
args
.
mix_title
)
mx
=
MixTape
(
args
.
playlist
,
args
.
mix_title
,
args
.
mix_author
,
args
.
mix_image
)
mx
.
update_tags
()
print
(
mx
)
This diff is collapsed.
Click to expand it.
good_ol_mixtape.py
+
20
−
9
View file @
18ebeb99
...
...
@@ -28,6 +28,12 @@ class Song:
def
set_numInMix
(
self
,
mixNumber
):
self
.
track
[
'
tracknumber
'
]
=
mixNumber
def
set_totalnum
(
self
,
totalNumber
):
self
.
track
[
'
totaltracks
'
]
=
totalNumber
def
set_albumArtist
(
self
,
albumArtist
):
self
.
track
[
'
albumartist
'
]
=
albumArtist
def
replace_artwork
(
self
,
newImagePath
):
tmpArt
=
[]
for
a
in
self
.
track
[
'
artwork
'
].
values
:
...
...
@@ -39,10 +45,11 @@ class Song:
self
.
track
.
append_tag
(
'
artwork
'
,
a
)
def
update_tag
(
self
):
self
.
track
.
save
()
#self.track.save()
print
(
"
uncomment to update
"
+
str
(
self
))
def
__str__
(
self
):
return
f
"
{
self
.
track
[
'
tracknumber
'
].
first
}
.
{
self
.
track
[
'
album
'
].
first
}
/
{
self
.
title
}
—
{
self
.
artist
}
(track #
{
self
.
o_number
}
of
{
self
.
o_album
}
)
"
return
f
"
{
self
.
track
[
'
tracknumber
'
].
first
}
/
{
self
.
track
[
'
totaltracks
'
].
first
}
.
{
self
.
track
[
'
album
'
].
first
}
/
{
self
.
title
}
—
{
self
.
artist
}
(track #
{
self
.
o_number
}
of
{
self
.
o_album
}
)
"
class
MixTape
:
@classmethod
...
...
@@ -53,26 +60,30 @@ class MixTape:
else
:
return
unquote
(
res
)
def
__init__
(
self
,
pl_path
,
title
=
None
):
def
__init__
(
self
,
pl_path
,
title
=
None
,
author
=
None
,
img
=
None
):
self
.
playlist
=
[]
self
.
title
=
title
num
=
1
self
.
author
=
author
self
.
cover
=
img
num
=
0
for
s
in
m3u8
.
load
(
pl_path
).
segments
:
try
:
if
self
.
title
==
None
:
self
.
playlist
.
append
(
Song
(
MixTape
.
uri2path
(
s
.
uri
)))
else
:
self
.
playlist
.
append
(
Song
(
MixTape
.
uri2path
(
s
.
uri
),
self
.
title
,
num
))
num
+=
1
self
.
playlist
.
append
(
Song
(
MixTape
.
uri2path
(
s
.
uri
),
self
.
title
,
num
,
self
.
author
,
self
.
cover
))
except
ValueError
as
e
:
print
(
e
)
num
-=
1
def
update_tags
(
self
):
for
t
in
self
.
playlist
:
t
.
set_totalnum
(
len
(
self
.
playlist
))
t
.
update_tag
()
def
__str__
(
self
):
res
=
""
for
track
in
self
.
playlist
:
res
+=
track
.
__str__
()
+
"
\n
"
return
res
if
__name__
==
"
__main__
"
:
track
=
Song
(
"
sampleData/archive/02. NoName - Rainforest.flac
"
,
"
test
"
,
5
,
mixCover
=
"
sampleData/CONNECTED.png
"
)
print
(
track
)
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