Commit e7492586 authored by Canek Peláez's avatar Canek Peláez
Browse files

Merge branch 'master' of aztlan.fciencias.unam.mx:canek/mlm

parents 8c7e1ab2 cde79748
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -10,3 +10,9 @@ custom_target(
  command: [msgfmt, '--desktop', '--template', '@INPUT@',
            '-d', podir, '-o', '@OUTPUT@'],
)

icon_dir = join_paths(datadir, 'icons', 'hicolor', 'scalable', 'apps')
install_data(
  'mlm.svg',
  install_dir: icon_dir
)
+86 −53
Original line number Diff line number Diff line
@@ -22,35 +22,55 @@

#include <id3tag.h>

#ifndef _ID3TAG_EXTRA_H
#define _ID3TAG_EXTRA_H
#pragma once

/**
 * Enumeration of types of picture.
 * http://id3lib.sourceforge.net/id3/id3v2.4.0-structure.txt
 */
enum id3_picture_type {
        ID3_PICTURETYPE_OTHER         = 0,  /* Other */
        ID3_PICTURETYPE_PNG32ICON     = 1,  /* 32x32 pixels 'file icon' (PNG only) */
        ID3_PICTURETYPE_OTHERICON     = 2,  /* Other file icon */
        ID3_PICTURETYPE_COVERFRONT    = 3,  /* Cover (front) */
        ID3_PICTURETYPE_COVERBACK     = 4,  /* Cover (back) */
        ID3_PICTURETYPE_LEAFLETPAGE   = 5,  /* Leaflet page */
        ID3_PICTURETYPE_MEDIA         = 6,  /* Media (e.g. lable side of CD) */
        ID3_PICTURETYPE_LEADARTIST    = 7,  /* Lead artist/lead performer/soloist */
        ID3_PICTURETYPE_ARTIST        = 8,  /* Artist/performer */
        ID3_PICTURETYPE_CONDUCTOR     = 9,  /* Conductor */
        ID3_PICTURETYPE_BAND          = 10, /* Band/Orchestra */
        ID3_PICTURETYPE_COMPOSER      = 11, /* Composer */
        ID3_PICTURETYPE_LYRICIST      = 12, /* Lyricist/text writer */
        ID3_PICTURETYPE_REC_LOCATION  = 13, /* Recording Location */
        ID3_PICTURETYPE_RECORDING     = 14, /* During recording */
        ID3_PICTURETYPE_PERFORMANCE   = 15, /* During performance */
        ID3_PICTURETYPE_VIDEO         = 16, /* Movie/video screen capture */
        ID3_PICTURETYPE_FISH          = 17, /* A bright coloured fish */
        ID3_PICTURETYPE_ILLUSTRATION  = 18, /* Illustration */
        ID3_PICTURETYPE_ARTISTLOGO    = 19, /* Band/artist logotype */
        ID3_PICTURETYPE_PUBLISHERLOGO = 20  /* Publisher/Studio logotype */
        /* Other */
        ID3_PICTURETYPE_OTHER         = 0,
        /* 32x32 pixels 'file icon' (PNG only) */
        ID3_PICTURETYPE_PNG32ICON     = 1,
        /* Other file icon */
        ID3_PICTURETYPE_OTHERICON     = 2,
        /* Cover (front) */
        ID3_PICTURETYPE_COVERFRONT    = 3,
        /* Cover (back) */
        ID3_PICTURETYPE_COVERBACK     = 4,
        /* Leaflet page */
        ID3_PICTURETYPE_LEAFLETPAGE   = 5,
        /* Media (e.g. lable side of CD) */
        ID3_PICTURETYPE_MEDIA         = 6,
        /* Lead artist/lead performer/soloist */
        ID3_PICTURETYPE_LEADARTIST    = 7,
        /* Artist/performer */
        ID3_PICTURETYPE_ARTIST        = 8,
        /* Conductor */
        ID3_PICTURETYPE_CONDUCTOR     = 9,
        /* Band/Orchestra */
        ID3_PICTURETYPE_BAND          = 10,
        /* Composer */
        ID3_PICTURETYPE_COMPOSER      = 11,
        /* Lyricist/text writer */
        ID3_PICTURETYPE_LYRICIST      = 12,
        /* Recording Location */
        ID3_PICTURETYPE_REC_LOCATION  = 13,
        /* During recording */
        ID3_PICTURETYPE_RECORDING     = 14,
        /* During performance */
        ID3_PICTURETYPE_PERFORMANCE   = 15,
        /* Movie/video screen capture */
        ID3_PICTURETYPE_VIDEO         = 16,
        /* A bright coloured fish */
        ID3_PICTURETYPE_FISH          = 17,
        /* Illustration */
        ID3_PICTURETYPE_ILLUSTRATION  = 18,
        /* Band/artist logotype */
        ID3_PICTURETYPE_ARTISTLOGO    = 19,
        /* Publisher/Studio logotype */
        ID3_PICTURETYPE_PUBLISHERLOGO = 20
};

/**
@@ -59,7 +79,8 @@ enum id3_picture_type {
 * @param id the id of the frame.
 * @return the frame with the given id, or NULL if not found.
 */
struct id3_frame*     id3_tag_search_frame               (struct id3_tag*       tag,
struct id3_frame*
id3_tag_search_frame               (struct id3_tag*       tag,
                                    const char*           id);

/**
@@ -68,7 +89,8 @@ struct id3_frame* id3_tag_search_frame (struct id3_tag*
 * @param ptype the picture type.
 * @return the frame with the given type, or NULL if not found.
 */
struct id3_frame*     id3_tag_search_picture_frame       (struct id3_tag*       tag,
struct id3_frame*
id3_tag_search_picture_frame       (struct id3_tag*       tag,
                                    enum id3_picture_type ptype);

/**
@@ -77,7 +99,8 @@ struct id3_frame* id3_tag_search_picture_frame (struct id3_tag*
 * @param id the id of the new text frame.
 * @return a newly created text frame with the given id.
 */
struct id3_frame*     id3_tag_create_text_frame          (struct id3_tag*       tag,
struct id3_frame*
id3_tag_create_text_frame          (struct id3_tag*       tag,
                                    const char*           id);

/**
@@ -86,7 +109,8 @@ struct id3_frame* id3_tag_create_text_frame (struct id3_tag*
 * @param lang the language of the new comment frame.
 * @return a newly created comment frame with the given language.
 */
struct id3_frame*     id3_tag_create_comment_frame       (struct id3_tag*       tag,
struct id3_frame*
id3_tag_create_comment_frame       (struct id3_tag*       tag,
                                    const char*           lang);

/**
@@ -95,7 +119,8 @@ struct id3_frame* id3_tag_create_comment_frame (struct id3_tag*
 * @param ptype the picture type of the new picture frame.
 * @return a newly created picture frame with the given picture type.
 */
struct id3_frame*     id3_tag_create_picture_frame       (struct id3_tag*       tag,
struct id3_frame*
id3_tag_create_picture_frame       (struct id3_tag*       tag,
                                    enum id3_picture_type ptype);

/**
@@ -103,14 +128,16 @@ struct id3_frame* id3_tag_create_picture_frame (struct id3_tag*
 * @param frame the id3 frame.
 * @return the text of the id3 frame, or NULL if the frame has no text.
 */
char*                 id3_frame_get_text                 (struct id3_frame*     frame);
char*
id3_frame_get_text                 (struct id3_frame*     frame);

/**
 * Sets the text of an id3 frame.
 * @param frame the id3 frame.
 * @param text the new text of the id3 frame.
 */
void                  id3_frame_set_text                 (struct id3_frame*     frame,
void
id3_frame_set_text                 (struct id3_frame*     frame,
                                    const char*           text);

/**
@@ -118,14 +145,16 @@ void id3_frame_set_text (struct id3_frame*
 * @param frame the id3 frame.
 * @return the comment text of the id3 frame, or NULL if the frame is not text.
 */
char*                 id3_frame_get_comment_text         (struct id3_frame*     frame);
char*
id3_frame_get_comment_text         (struct id3_frame*     frame);

/**
 * Sets the comment text of an id3 frame.
 * @param frame the id3 frame.
 * @param text the new comment text of the id3 frame.
 */
void                  id3_frame_set_comment_text         (struct id3_frame*     frame,
void
id3_frame_set_comment_text         (struct id3_frame*     frame,
                                    const char*           text);

/**
@@ -135,7 +164,8 @@ void id3_frame_set_comment_text (struct id3_frame*
 * @param[out] length the picture data length.
 * @return the picture data, or NULL if there is no picture data.
 */
unsigned char*        id3_frame_get_picture              (struct id3_frame*     frame,
unsigned char*
id3_frame_get_picture              (struct id3_frame*     frame,
                                    enum id3_picture_type ptype,
                                    int*                  length);

@@ -145,7 +175,8 @@ unsigned char* id3_frame_get_picture (struct id3_frame*
 * @param bytes the new picture data.
 * @param length the new picture data length.
 */
void                  id3_frame_set_picture              (struct id3_frame*     frame,
void
id3_frame_set_picture              (struct id3_frame*     frame,
                                    unsigned char*        bytes,
                                    unsigned int          length,
                                    const char*           desc);
@@ -155,14 +186,16 @@ void id3_frame_set_picture (struct id3_frame*
 * @param frame the id3 frame.
 * @return the picture description, or NULL if there is no picture description.
 */
char*                 id3_frame_get_picture_description  (struct id3_frame*     frame);
char*
id3_frame_get_picture_description  (struct id3_frame*     frame);

/**
 * Sets the picture description of an id3 frame.
 * @param frame the id3 frame.
 * @param desc the new picture description.
 */
void                  id3_frame_set_picture_description  (struct id3_frame*     frame,
void
id3_frame_set_picture_description  (struct id3_frame*     frame,
                                    const char*           desc);

/**
@@ -170,13 +203,13 @@ void id3_frame_set_picture_description (struct id3_frame*
 * @param frame the id3 frame.
 * @return the binary data of an id3 frame, or NULL if there is no binary data.
 */
union id3_field*      id3_frame_get_binary_data          (struct id3_frame*     frame);
union id3_field*
id3_frame_get_binary_data          (struct id3_frame*     frame);

/**
 * Returns the picture type of an id3 frame.
 * @param frame the id3 frame.
 * @return the picture type of the frame.
 */
enum id3_picture_type id3_frame_get_picture_type         (struct id3_frame*     frame);

#endif /* _ID3TAG_EXTRA_H */
enum id3_picture_type
id3_frame_get_picture_type         (struct id3_frame*     frame);
+147 −78
Original line number Diff line number Diff line
@@ -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);
        }

        /**