Giter Site home page Giter Site logo

nikotron / dart-tags Goto Github PK

View Code? Open in Web Editor NEW
37.0 3.0 16.0 3.46 MB

ID3 Tag parser written on the pure dart language.

Home Page: https://pub.dartlang.org/packages/dart_tags

License: MIT License

Dart 98.93% Shell 1.07%
flutter dart tag id3 mp3 library dart-tags metadata-extraction metadata-editing metadata

dart-tags's Introduction

Dart Tags

Coverage Status pub package Build Status Awesome Dart MIT

The library for parsing ID3 tags, written in pure Dart.

You can found sample app written with flutter framework here.

License

project under MIT license

Changelogs

full changelog

0.4.1

  • thanx to @antitim for find and reslove issue with a broken images in the tags in this [PR]
  • dependencies update

0.4.0 (Null Safety)

  • thanx for migrating to null safety to @timekone and this PR
  • updated some dependencies

0.3.1

  • implemented separate getting size of frame for id3 v2.3 and v2.4
  • added test case and asset
  • fixed typos, thanx to @algoshipda and his PR
  • fixed APIC picture type error, thanx to @algoshipda and his PR

Instalation

add dependency in pubsec.yaml

dependencies:
  dart_tags: ^0.4.0

Usage

A simple usage example:

import 'dart:io';

import 'package:dart_tags/dart_tags.dart';

main(List<String> args) {
  final tp = new TagProcessor();

  final f = new File(args[0]);

  tp.getTagsFromByteArray(f.readAsBytes()).then((l) => l.forEach((f) => print(f)));
}

Code of conduct

Please refer our code of conduct.

Features and bugs

Please feel free for feature requests and bugs at the issue tracker.

In addition

Thanx for contributing @magodo, @frankdenouter @algoshipda @timekone

Thanx for the Photo by Mink Mingle on Unsplash that we using in unit tests.

dart-tags's People

Contributors

algoshipda avatar antitim avatar codacy-badger avatar magodo avatar nikotron avatar timekone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

dart-tags's Issues

DTB- Bitrate not found in the tags

Describe the bug
can't find the bitrate in the tags using both versions of ID3
Environment

  • Platform Flutter Android
  • Library version 3.0.1
  • Tag type ID3 1.1 and ID3 2.3.0

To Reproduce
Steps to reproduce the behavior:

  1. get the tags using the TagsProcesser
  2. can't find the Bitrate there

Expected behavior
find a tag with the name bitrate

Additional context
i can get that with native android using the MediaMetadataRetriever

DTB-Crashes on ID3 2.2.0

Describe the bug
When parsing the MP3s in my library, the processor crashed with this stack trace:

Unhandled exception:
NoSuchMethodError: The method 'decode' was called on null.
Receiver: null
Tried calling: decode(Uint8Array)
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
#1 ID3V2Reader.parseValues (package:dart_tags/src/readers/id3v2.dart:71:23)
#2 Reader.read. (package:dart_tags/src/readers/reader.dart:13:23)
#3 _RootZone.runUnary (dart:async/zone.dart:1450:54)
#4 _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
#5 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
#6 Future._propagateToListeners (dart:async/future_impl.dart:725:32)
#7 Future._addListener. (dart:async/future_impl.dart:393:9)
#8 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#9 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#10 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:120:13)
#11 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:185:5)

Environment

  • Platform DartVM on Windows 10
  • Library version: 0.3.1
  • Tag type ID3v2.2.0

Expected behavior
Parses and returns tags correctly.

DTB- Can't parse Chinese/Japanese/Korean characters

Describe the bug
Tags with Chinese/Japanese/Korean characters are not parsed and show up like "??"

Environment

  • Platform FLutter 1.20.2
  • Library version 0.3.1
  • Tag type ID3

To Reproduce
Steps to reproduce the behavior:

  1. have a file with chinese/.. characters in the TAGS
  2. print the tags like in the example
  3. See error

Expected behavior
Clear parsing of the text

Error on 'Other' APIC picture type

    test('Wrong APIC tags decoding on on Other picture type.', () async {
      final pic1 = AttachedPicture(
          'image/jpeg', 0x00, 'foo.jpg', picture.readAsBytesSync());

      final tag = Tag()
        ..tags = {'picture': pic1}
        ..type = 'ID3'
        ..version = '2.4';

      final writer = ID3V2Writer();

      final blocks = writer.write(await file2.readAsBytes(), tag);

      final r = ID3V2Reader();
      final f = await r.read(blocks);

      // ignore: avoid_as
      final AttachedPicture pic = (f.tags['picture'] as Map).values.first;
      expect(pic, equals(pic1));
    });

this test will gerenate an error

DTB-It can't decode album cover image of some mp3 files.

Describe the bug
It cannot decode the album image of some mp3 files. I've also tried pasting the imageData(Base64 string) that I got from tag.tags['picture'] into https://base64.guru/converter/decode/file just to check if it will work but it also failed.

Environment

  • Platform [e.g. DartVM, Linux_x64, / Flutter,Android]
  • Library version [e.g. v0.3.1]
  • Tag type [e.g. ID3v2]

To Reproduce
Steps to reproduce the behavior:

  1. Get the imagebytes from tag.tags['picture'] imageData from an mp3.
  2. Display into Image.memory

Produces exception since imageData is invalid.

NOTE: Some mp3s are working and some are not. If you want me to send the sample mp3 file, please let me know your email.

Thanks

Ram Consumption

This is a great library. It has a problem of using a lot of Ram tho. It seems to use up all the available ram to extract the tags and when modifying those tags writing them back does the same thing.

dart_tags

I am running this on a Windows machine because I want to make it for both android and windows

Environment

  • Platform [Windows 7 X64, 8GB ram, i7 processor ]
  • Library version [v0.2.3]

Web Support?

Hello,

I would like to be able to use this library with flutter web, but I am having trouble because this library uses files defined from dart:io and not dart:html. Dart:io is not supported in flutter web, so I am not sure why this library is labelled as working with flutter web?

Artist tag restriction on characters

When i try to include a string greater than or equal to 46 bytes, the writing fails on that mp3 file. It may be true for other tags as well, but observed this on artist tag as am having quite lengthy strings in there.

Example artist string which writes successfully:

Ilaiyaraaja, K. S. Chithra, S. P. Balasubrahmanyam

Example artist string which fails:

Ilaiyaraaja, K. S. Chithra, S. P. BalasubrahmanyamT

Can this library write tags to files ?

does this library write tags to file or just parse them only, I can see this message: "/// Writer could just transform only tags in byte array" in the code.

DTB-Can't catch an error on the TagProcessor().getTagsFromByteArray

Describe the bug
an error happens when reading tags from byteArray and I can't catch it, it will always crash my code and stop everything I am doing.
The error is when decoding comments, see exact error below

Environment

  • Platform Flutter Android
  • Library version 0.3.1
  • Tag type I don't know, can't get there

To Reproduce
Steps to reproduce the behavior:

  1. Nothing, I just passed bytes from a file ( an existing file )
  2. See error

Expected behavior
The error might happen, but I need to be able to catch it.

Additional context

[ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: RangeError (end): Invalid value: Not in inclusive range 3..20: 0
E/flutter (26269): #0      RangeError.checkValidRange (dart:core/errors.dart:357:9)
E/flutter (26269): #1      _TypedIntListMixin.sublist (dart:typed_data-patch/typed_data_patch.dart:462:31)
E/flutter (26269): #2      COMMFrame.decodeBody (package:dart_tags/src/frames/id3v2/comm_frame.dart:35:47)
E/flutter (26269): #3      ID3V2Frame.decode (package:dart_tags/src/frames/id3v2/id3v2_frame.dart:57:39)
E/flutter (26269): #4      ID3V2Reader.parseValues (package:dart_tags/src/readers/id3v2.dart:71:23)
E/flutter (26269): #5      Reader.read.<anonymous closure> (package:dart_tags/src/readers/reader.dart:13:23)
E/flutter (26269): #6      _rootRunUnary (dart:async/zone.dart:1198:47)
E/flutter (26269): #7      _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter (26269): #8      _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
E/flutter (26269): #9      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
E/flutter (26269): #10     Future._propagateToListeners (dart:async/future_impl.dart:725:32)
E/flutter (26269): #11     Future._addListener.<anonymous closure> (dart:async/future_impl.dart:393:9)
E/flutter (26269): #12     _rootRun (dart:async/zone.dart:1190:13)
E/flutter (26269): #13     _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter (26269): #14     _CustomZone.runGuarded (dart:async/zone.dart:997:7)
E/flutter (26269): #15     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23)
E/flutter (26269): #16     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
E/flutter (26269): #17     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
E/flutter (26269): 

Decode

I used EasyTag to change Artist tag to "Полина Гагарина&Егор Крид"
But the package return it like "Полинаጠ〄㌄〄䀄㠄㴄〄☄Егорᨠ䀄㠄㐄�"

version 1.1 and 2.3.0 returned

When I read the ID3 tags from a file I get two entries, one with v1.1 and one with v2.3.0 which is fine, I can filter them so I only get those with version v2.3.0 but I was just wondering if this is safe, or if there is a better way to do this. The tag processor doesn't seem to take a constructor argument so I wonder how this could be done in a clean way.

DTB- Invalid value not in range

Describe the bug
a bug when trying to get the comments out of a file after writing new tags in, that includes new comments

Environment

  • Platform Flutter
  • Library version 0.3.1
  • Tag type ID3 2.4

To Reproduce
Steps to reproduce the behavior:
execute this code :

 final com1 = Comment('eng', 'desc_here', 'lol it is a comment');
      final com2 = Comment('eng', 'desc_here_2', 'lol it is a comment');
      final pic = AttachedPicture(
          'image/jpeg', 0x03, 'foo.jpg', picture.readAsBytesSync());
      final tag = Tag()
        ..tags = {
          'title': 'foo',
          'artist': 'bar',
          'album': 'baz',
          'year': '2010',
          'comment': {
            com1.key: com1,
            com2.key: com2,
          },
          'track': '6',
          'genre': 'Dream',
          'custom': 'Just a tag',
       // No picture used
        }
        ..type = 'ID3'
        ..version = '2.4';

      final writer = ID3V2Writer();
      final blocks = writer.write(await file2.readAsBytes(), tag);

      final r = ID3V2Reader();
      final f = await r.read(blocks);

Additional context
the full error

[ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: RangeError (end): Invalid value: Not in inclusive range 12..30: -1
E/flutter (14192): #0      RangeError.checkValidRange (dart:core/errors.dart:357:9)
E/flutter (14192): #1      List.sublist (dart:core-patch/growable_array.dart:84:38)
E/flutter (14192): #2      ApicFrame.decodeBody (package:dart_tags/src/frames/id3v2/apic_frame.dart:79:25)
E/flutter (14192): #3      ID3V2Frame.decode (package:dart_tags/src/frames/id3v2/id3v2_frame.dart:57:39)
E/flutter (14192): #4      ID3V2Reader.parseValues (package:dart_tags/src/readers/id3v2.dart:71:23)
E/flutter (14192): #5      Reader.read.<anonymous closure> (package:dart_tags/src/readers/reader.dart:13:23)
E/flutter (14192): #6      _rootRunUnary (dart:async/zone.dart:1198:47)
E/flutter (14192): #7      _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter (14192): #8      _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
E/flutter (14192): #9      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
E/flutter (14192): #10     Future._propagateToListeners (dart:async/future_impl.dart:725:32)
E/flutter (14192): #11     Future._completeWithValue (dart:async/future_impl.dart:529:5)
E/flutter (14192): #12     _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:40:15)

Can't set null tags

Describe the bug
i can't find a way to set tags as null like album or artist, i always et the error "The getter 'length' was called on null."

Environment

  • Platform [e.g. DartVM, Linux_x64, / Flutter, iOS]
  • Library version [e.g. v0.2.0]
  • Tag type [e.g. ID3v1.x]

To Reproduce
Steps to reproduce the behavior:

  1. do exactly the same as the tests
  2. set a tag to null
  3. witness the error

Expected behavior
being able to set tags to null
Additional context
the error in full :

E/flutter ( 5639): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: NoSuchMethodError: The getter 'length' was called on null.
E/flutter ( 5639): Receiver: null
E/flutter ( 5639): Tried calling: length
E/flutter ( 5639): #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
E/flutter ( 5639): #1      Utf8Encoder.convert (dart:convert/utf.dart:88:31)
E/flutter ( 5639): #2      Codec.encode (dart:convert/codec.dart:21:32)
E/flutter ( 5639): #3      DefaultFrame.encode (package:dart_tags/src/frames/id3v2/default_frame.dart:19:25)
E/flutter ( 5639): #4      ID3V2Writer.prepareTag.<anonymous closure> (package:dart_tags/src/writers/id3v2.dart:29:31)
E/flutter ( 5639): #5      _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:377:8)
E/flutter ( 5639): #6      ID3V2Writer.prepareTag (package:dart_tags/src/writers/id3v2.dart:17:14)
E/flutter ( 5639): #7      Writer.write (package:dart_tags/src/writers/writer.dart:13:59)

Lyrics Tag showing undefined characters [working solution implemented already]

Thank for your amazing effort to get this library to where it is now, and it has been pretty useful thus far.

I am using this library to extract the lyrics tag from an mp3 file that contains both English and Japanese characters and encountered an issue because the first few characters were showing invalid symbols.

I have already figured out the problem and just wanted to share here how I resolved it.

The first few bytes of the lyrics tag contains the following sequence:

[101, 110, 103, 255, 254, 0, 0, 255, 254, 49, 0, 46, 0, 32, 0,...]

I figured out that to remove the invalid characters, I just need to remove the first seven bytes so that the frame will start at the 8th byte. So I modified your clearFrameData() from id3v2_frame.dart.

List<int> clearFrameData(List<int> bytes) {
    var key = 0;
    for (var i = 0; i < bytes.length; i++) {
      if (bytes[i] == 0xFF && bytes[i + 1] == 0xFE) {
        key = i;
      }
    }
    return bytes.sublist(key);
 }

From the latest release, you seem to have stopped using clearFrameData() so I am just writing this stuff here rather than create a new PR.

32 bit integer frame size for USLT ??

I found lyrics is mis-decoding.

With some debugging, I found the fact that USLT actually uses 32bit integer for frame size.
(what about the other frame?)

If we change USLT frame size to 32 bit integer instead of the sync safe integer, it works.

Can't get album cover if image size is over or equal 1 mb

Hi,

When I try to get album cover as a base64 string I always get wrong base64 string and can't get image from it. Especially for big size(1 mb or more) album covers. If the cover is smaller than 1 mb, I can get image from it's base64 string.

Non-ASCII Glyphs don't work.

Any MP3s with either Greek or Latin characters come up blank for the respective fields with the offending characters.

Speed

Hi, this is really a good library but is very slow.
Is there a way to speed it up?

Unable to catch error "Unhandled Exception: NoSuchMethodError: The method 'decode' was called on null."

Not all the MP3 can be decoded and the console return
[VERBOSE-2:ui_dart_state.cc(199)] Unhandled Exception: NoSuchMethodError: The method 'decode' was called on null. Receiver: null Tried calling: decode(Uint8Array) #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5) #1 ID3V2Reader.parseValues package:dart_tags/…/readers/id3v2.dart:71 #2 Reader.read.<anonymous closure> package:dart_tags/…/readers/reader.dart:13 #3 _rootRunUnary (dart:async/zone.dart:1362:47) <asynchronous suspension>
But the error cannot be catch on try catch or .catchError()
The code just stops at await tp.getTagsFromByteArray(bytes), therefore i can't handle the error.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.