Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
audio-renamer
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
Service Desk
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
Janne Mareike Koschinski
audio-renamer
Commits
1dec25f1
Verified
Commit
1dec25f1
authored
3 years ago
by
Janne Mareike Koschinski
Browse files
Options
Downloads
Patches
Plain Diff
feat: add support for extracting wav files
parent
3dc6e89c
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
extractors/WavExtractor.py
+42
-0
42 additions, 0 deletions
extractors/WavExtractor.py
extractors/get_extractor.py
+4
-0
4 additions, 0 deletions
extractors/get_extractor.py
with
46 additions
and
0 deletions
extractors/WavExtractor.py
0 → 100644
+
42
−
0
View file @
1dec25f1
from
typing
import
Optional
from
mutagen.wave
import
WAVE
from
extractors.MediaExtractor
import
MediaExtractor
from
models.TrackMeta
import
TrackMeta
from
util.extract_numbers
import
extract_numbers
class
WaveExtractor
(
MediaExtractor
):
file
:
WAVE
def
__init__
(
self
,
filename
:
str
):
self
.
file
=
WAVE
(
filename
)
def
extract_tag
(
self
,
tag
:
str
)
->
Optional
[
str
]:
if
tag
not
in
self
.
file
.
tags
:
return
None
return
str
(
self
.
file
.
tags
[
tag
])
def
extract_tags
(
self
)
->
TrackMeta
:
discnumber
,
disctotal
=
extract_numbers
(
self
.
extract_tag
(
'
TPOS
'
))
tracknumber
,
tracktotal
=
extract_numbers
(
self
.
extract_tag
(
'
TRCK
'
))
return
TrackMeta
(
album
=
self
.
extract_tag
(
'
TALB
'
),
albumsort
=
self
.
extract_tag
(
'
TSOA
'
),
albumartist
=
self
.
extract_tag
(
'
TPE2
'
),
albumartistsort
=
self
.
extract_tag
(
'
TSO2
'
),
artist
=
self
.
extract_tag
(
'
TPE1
'
),
artistsort
=
self
.
extract_tag
(
'
TSOP
'
),
catalognumber
=
self
.
extract_tag
(
'
TXXX:CATALOGNUMBER
'
),
discnumber
=
discnumber
,
disctotal
=
disctotal
,
label
=
self
.
extract_tag
(
'
TPUB
'
),
media
=
self
.
extract_tag
(
'
TMED
'
),
originaldate
=
self
.
extract_tag
(
'
TDOR
'
),
originalyear
=
self
.
extract_tag
(
'
TDRC
'
),
title
=
self
.
extract_tag
(
'
TIT2
'
),
titlesort
=
self
.
extract_tag
(
'
TSOT
'
),
tracknumber
=
tracknumber
,
tracktotal
=
tracktotal
,
)
This diff is collapsed.
Click to expand it.
extractors/get_extractor.py
+
4
−
0
View file @
1dec25f1
...
...
@@ -6,6 +6,7 @@ from extractors.FlacExtractor import FlacExtractor
from
extractors.MediaExtractor
import
MediaExtractor
from
extractors.Mp3Extractor
import
Mp3Extractor
from
extractors.Mp4Extractor
import
Mp4Extractor
from
extractors.WavExtractor
import
WaveExtractor
def
get_extractor
(
filename
)
->
Optional
[
MediaExtractor
]:
...
...
@@ -19,5 +20,8 @@ def get_extractor(filename) -> Optional[MediaExtractor]:
return
AacExtractor
(
filename
)
elif
filename
.
endswith
(
"
.mp4
"
)
or
filename
.
endswith
(
"
.m4a
"
):
return
Mp4Extractor
(
filename
)
elif
filename
.
endswith
(
"
.aiff
"
)
or
filename
.
endswith
(
"
.wav
"
)
\
or
filename
.
endswith
(
"
.wave
"
)
or
filename
.
endswith
(
"
.pcm
"
):
return
WaveExtractor
(
filename
)
else
:
return
None
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