Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Music Library Maintainer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Canek Peláez Valdés
Music Library Maintainer
Commits
cde79748
Commit
cde79748
authored
6 years ago
by
Canek Peláez Valdés
Browse files
Options
Downloads
Patches
Plain Diff
FileTags: A lot of auxiliary functions.
parent
c14641df
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/mlm/file-tags.vala
+147
-78
147 additions, 78 deletions
lib/mlm/file-tags.vala
with
147 additions
and
78 deletions
lib/mlm/file-tags.vala
+
147
−
78
View file @
cde79748
...
...
@@ -99,6 +99,8 @@ namespace MLM {
private
Gee
.
HashMap
<
string
,
int
?>
int_frames
;
/* Data frames. */
private
Gee
.
HashMap
<
int
,
GLib
.
Bytes
>
data_frames
;
/* Invalid frames. */
private
Gee
.
ArrayList
<
Id3Tag
.
Frame
>
invalid_frames
;
/**
* The artist.
...
...
@@ -273,24 +275,76 @@ namespace MLM {
if
(
tag
.
frames
.
length
==
0
)
return
;
var
invalid_frames
=
new
Gee
.
ArrayList
<
Id3Tag
.
Frame
>();
for
(
int
i
=
0
;
i
<
tag
.
frames
.
length
;
i
++)
{
var
frame
=
tag
.
frames
[
i
];
invalid_frames
=
new
Gee
.
ArrayList
<
Id3Tag
.
Frame
>();
for
(
int
i
=
0
;
i
<
tag
.
frames
.
length
;
i
++)
set_frame
(
tag
.
frames
[
i
]);
foreach
(
Id3Tag
.
Frame
frame
in
invalid_frames
)
{
tag
.
detachframe
(
frame
);
}
invalid_frames
=
null
;
}
/* Sets a frame. */
private
void
set_frame
(
Id3Tag
.
Frame
frame
)
{
if
(
frame
.
id
==
FrameId
.
ARTIST
)
{
string_frames
[
FrameId
.
ARTIST
]
=
_artist
=
frame
.
get_text
(
);
set_artist_frame
(
frame
);
}
else
if
(
frame
.
id
==
FrameId
.
TITLE
)
{
string_frames
[
FrameId
.
TITLE
]
=
_title
=
frame
.
get_text
(
);
set
_title
_
frame
(
frame
);
}
else
if
(
frame
.
id
==
FrameId
.
ALBUM
)
{
string_frames
[
FrameId
.
ALBUM
]
=
_album
=
frame
.
get_text
(
);
set
_album
_
frame
(
frame
);
}
else
if
(
frame
.
id
==
FrameId
.
BAND
)
{
string_frames
[
FrameId
.
BAND
]
=
_band
=
frame
.
get_text
(
);
set_band_frame
(
frame
);
}
else
if
(
frame
.
id
==
FrameId
.
YEAR
)
{
int_frames
[
FrameId
.
YEAR
]
=
_year
=
int
.
parse
(
frame
.
get_text
());
set_year_frame
(
frame
);
}
else
if
(
frame
.
id
==
FrameId
.
TRACK
)
{
set_track_frame
(
frame
);
}
else
if
(
frame
.
id
==
FrameId
.
DISC
)
{
set_disc_frame
(
frame
);
}
else
if
(
frame
.
id
==
FrameId
.
GENRE
)
{
set_genre_frame
(
frame
);
}
else
if
(
frame
.
id
==
FrameId
.
COMMENT
)
{
set_comment_frame
(
frame
);
}
else
if
(
frame
.
id
==
FrameId
.
COMPOSER
)
{
set_composer_frame
(
frame
);
}
else
if
(
frame
.
id
==
FrameId
.
ORIGINAL
)
{
set_original_frame
(
frame
);
}
else
if
(
frame
.
id
==
FrameId
.
PICTURE
)
{
set_picture_frame
(
frame
);
}
else
{
set_invalid_frame
(
frame
);
}
}
/* Sets the artist frame. */
private
void
set_artist_frame
(
Id3Tag
.
Frame
frame
)
{
string_frames
[
FrameId
.
ARTIST
]
=
_artist
=
frame
.
get_text
();
}
/* Sets the artist frame. */
private
void
set_title_frame
(
Id3Tag
.
Frame
frame
)
{
string_frames
[
FrameId
.
TITLE
]
=
_title
=
frame
.
get_text
();
}
/* Sets the album frame. */
private
void
set_album_frame
(
Id3Tag
.
Frame
frame
)
{
string_frames
[
FrameId
.
ALBUM
]
=
_album
=
frame
.
get_text
();
}
/* Sets the band frame. */
private
void
set_band_frame
(
Id3Tag
.
Frame
frame
)
{
string_frames
[
FrameId
.
BAND
]
=
_band
=
frame
.
get_text
();
}
/* Sets the year frame. */
private
void
set_year_frame
(
Id3Tag
.
Frame
frame
)
{
int_frames
[
FrameId
.
YEAR
]
=
_year
=
int
.
parse
(
frame
.
get_text
());
}
/* Sets the track frame. */
private
void
set_track_frame
(
Id3Tag
.
Frame
frame
)
{
string
track
=
frame
.
get_text
();
if
(
track
==
null
)
continue
;
return
;
string_frames
[
FrameId
.
TRACK
]
=
track
;
if
(
track
.
index_of
(
"/"
)
!=
-
1
)
{
string
[]
t
=
track
.
split
(
"/"
);
...
...
@@ -300,16 +354,22 @@ namespace MLM {
_track
=
int
.
parse
(
track
);
_total
=
-
1
;
}
}
else
if
(
frame
.
id
==
FrameId
.
DISC
)
{
_disc
=
int
.
parse
(
frame
.
get_text
());
}
else
if
(
frame
.
id
==
FrameId
.
GENRE
)
{
}
/* Sets the disc frame. */
private
void
set_disc_frame
(
Id3Tag
.
Frame
frame
)
{
int_frames
[
FrameId
.
DISC
]
=
_disc
=
int
.
parse
(
frame
.
get_text
());
}
/* Sets the genre frame. */
private
void
set_genre_frame
(
Id3Tag
.
Frame
frame
)
{
var
g
=
frame
.
get_text
();
if
(
g
==
null
)
continue
;
return
;
_genre
=
Genre
.
index_of
(
g
);
if
(
_genre
!=
-
1
)
{
int_frames
[
FrameId
.
GENRE
]
=
_genre
;
continue
;
return
;
}
int
n
=
int
.
parse
(
g
);
if
(
0
<=
n
&&
n
<
Genre
.
total
())
{
...
...
@@ -318,16 +378,28 @@ namespace MLM {
}
else
{
invalid_frames
.
add
(
frame
);
}
}
else
if
(
frame
.
id
==
FrameId
.
COMMENT
)
{
string_frames
[
FrameId
.
COMMENT
]
=
_comment
=
frame
.
get_comment_text
();
}
else
if
(
frame
.
id
==
FrameId
.
COMPOSER
)
{
string_frames
[
FrameId
.
COMPOSER
]
=
_composer
=
frame
.
get_text
();
}
else
if
(
frame
.
id
==
FrameId
.
ORIGINAL
)
{
string_frames
[
FrameId
.
ORIGINAL
]
=
_original
=
frame
.
get_text
();
}
else
if
(
frame
.
id
==
FrameId
.
PICTURE
)
{
}
/* Sets the comment frame. */
private
void
set_comment_frame
(
Id3Tag
.
Frame
frame
)
{
_comment
=
frame
.
get_comment_text
();
string_frames
[
FrameId
.
COMMENT
]
=
_comment
;
}
/* Sets the composer frame. */
private
void
set_composer_frame
(
Id3Tag
.
Frame
frame
)
{
_composer
=
frame
.
get_text
();
string_frames
[
FrameId
.
COMPOSER
]
=
_composer
;
}
/* Sets the original frame. */
private
void
set_original_frame
(
Id3Tag
.
Frame
frame
)
{
_original
=
frame
.
get_text
();
string_frames
[
FrameId
.
ORIGINAL
]
=
_original
;
}
/* Sets the picture frame. */
private
void
set_picture_frame
(
Id3Tag
.
Frame
frame
)
{
var
fc_data
=
frame
.
get_picture
(
Id3Tag
.
PictureType
.
COVERFRONT
);
if
(
fc_data
!=
null
)
{
...
...
@@ -345,15 +417,12 @@ namespace MLM {
artist_description
=
frame
.
get_picture_description
();
}
}
else
{
GLib
.
warning
(
"Invalid frame ‘%s’ will be deleted.\n"
,
frame
.
id
);
invalid_frames
.
add
(
frame
);
}
}
foreach
(
Id3Tag
.
Frame
frame
in
invalid_frames
)
{
tag
.
detachframe
(
frame
);
}
/* Sets an invalid frame. */
private
void
set_invalid_frame
(
Id3Tag
.
Frame
frame
)
{
GLib
.
warning
(
"Invalid frame ‘%s’ will be deleted.\n"
,
frame
.
id
);
invalid_frames
.
add
(
frame
);
}
/**
...
...
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