Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added TXXX based tags support #122

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Conversation

Code0987
Copy link

Added a new class for TXXX style tags which have description and value as


<Header for 'User defined text information frame', ID: "TXXX">
Text encoding    $xx
Description    <text string according to encoding> $00 (00)
Value    <text string according to encoding>

ID3 Specs

@hennr
Copy link
Collaborator

hennr commented Apr 1, 2017

Hi @Code0987 ,

thanks for your PR.

Could you please make this patch compile on travis-ci? There is an import used that is not available in the project.
Also please add a test for your new code.

@hennr
Copy link
Collaborator

hennr commented Apr 1, 2017

Related to #55

@coveralls
Copy link

Coverage Status

Coverage decreased (-3.2%) to 60.007% when pulling 43a4827 on Code0987:master into 368fe13 on mpatric:master.

@Code0987
Copy link
Author

Code0987 commented Apr 5, 2017

Import fixed.

I'll write tests asap. Currently I'm not familiar with java tests much.

@hennr
Copy link
Collaborator

hennr commented Apr 5, 2017

Let me know if you have any questions regarding java / JUnit testing, @Code0987

added tests
@Code0987
Copy link
Author

Code0987 commented Apr 9, 2017

@hennr I've added test and updated code also. But I'm not sure if it's right!

@hennr
Copy link
Collaborator

hennr commented Apr 10, 2017

Hi @Code0987 ,

yep, there are some things that should be changed. Add me as a collaborator to your forked project and we can work together on them.

pom.xml Outdated
@@ -46,6 +46,12 @@
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this dependency is never used

@coveralls
Copy link

Coverage Status

Coverage increased (+0.7%) to 62.093% when pulling 4f68fc6 on Code0987:master into 3bd2057 on mpatric:master.

import org.junit.Test;
import static org.junit.Assert.*;

/**
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This info is already held in the git history, please remove

*/
public class ID3v2TXXXFrameDataTest {

public ID3v2TXXXFrameDataTest() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unneeded

public ID3v2TXXXFrameDataTest() {
}

@BeforeClass
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementing these annotations are optional. Simply delete all of the if empty.

public void tearDown() {
}

@org.junit.Test
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@test without the complete path should work.


@org.junit.Test
public void test() throws Exception {
System.out.println("test for txxx frame");
Copy link
Collaborator

@hennr hennr Apr 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove the system.out

}

@org.junit.Test
public void test() throws Exception {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please describe what the test ensures and rename test() according.

"my_custom_text",
"value",
true);
assertEquals(1, frameSets.size());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a best practice to have one assertion per @test annotated method.
The method-/test name should describe what it ensures.

@hennr
Copy link
Collaborator

hennr commented Apr 10, 2017

@Code0987 I merged the upstream master into your fork and added some comments in the test.
Could you update the test please?

@coveralls
Copy link

Coverage Status

Coverage increased (+0.7%) to 62.093% when pulling 051486f on Code0987:master into 3bd2057 on mpatric:master.

@Code0987
Copy link
Author

I followed your comments and have updated tests, let me know anything else to do.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.7%) to 62.093% when pulling aaf7b5f on Code0987:master into 3bd2057 on mpatric:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.7%) to 62.093% when pulling cdfc523 on Code0987:master into 3bd2057 on mpatric:master.

@hennr
Copy link
Collaborator

hennr commented Apr 11, 2017

Thanks @Code0987
Did you have a specific reason why you implemented most public methods in ID3v2TXXXFrameData as static methods?
I would prefer to use instance methods and spare the useFrameUnsynchronisation parameter by re-using the unsynchronisation variable already held in the super class.

@Code0987
Copy link
Author

@hennr No, I was just trying to keep all related code together, as it was a little different for custom tags then all other tags already implemented. I was using your work in a android project using gradle dependency, so I just copied this TXXX extra file, since I wanted not to overwrite over your code, that would break auto-updating and maybe license too.

@hennr
Copy link
Collaborator

hennr commented Apr 11, 2017

OK, so we can change that to instance methods now?

@hennr
Copy link
Collaborator

hennr commented Apr 11, 2017

Another question:
If your code goes upstream the API for most users would be something like this, right?

// given
Mp3File mp3File = new Mp3File("src/test/resources/v23tagwithchapters.mp3");
ID3v2 id3tag = mp3File.getId3v2Tag();
assertNull(id3tag.getCustomText("foo"));

// when
id3tag.setCustomText("foo", "bar");

// then
assertEquals("bar", id3tag.getCustomText("foo"));

This does not work for me at the moment.
Could you add a test that uses the setter and getter of AbstractID3v2Tag? ID3v2TagTest would be a good place for that IMO.

@Code0987
Copy link
Author

Ok, I'll see and update.

@Code0987
Copy link
Author

@hennr
Yes we can change it. I'll update.
And I'll update test also.

bug fix
@coveralls
Copy link

Coverage Status

Coverage increased (+1.03%) to 62.439% when pulling 66bfa17 on Code0987:master into 3bd2057 on mpatric:master.

@hennr
Copy link
Collaborator

hennr commented Apr 19, 2017

Hi @Code0987 , thanks for fixing the code.

Are you willing to change the static methods as well? If so, @mpatric should have another look at this pull request.
Cheers!

protected void unpackFrameData(byte[] bytes) throws InvalidDataException {
int marker = BufferTools.indexOfTerminatorForEncoding(bytes, 1, bytes[0]);

description = new EncodedText(bytes[0], BufferTools.copyBuffer(bytes, 1, marker - 1));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the description has zero length, the marker position could be 0, in which case the copyBuffer will fail. I suggest adding something like what is done in ID3v2UrlFrameData, which checks if marker >= 0 before doing the copy, otherwise sets the description to an empty string.


marker += description.getTerminator().length;

value = new EncodedText(bytes[0], BufferTools.copyBuffer(bytes, marker, bytes.length - marker));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above, check if bytes.length - marker >= 0

if (getClass() != obj.getClass()) {
return false;
}
return false;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why the equals method is not fully implemented? It's returning false for separate object instances that contain the same description and value, but it should return true. Your IDE should be able to generate it for you.

@mpatric
Copy link
Owner

mpatric commented May 29, 2017

To be consistent with how the code is currently structured, the static methods on ID3v2TXXXFrameData should rather be instance methods on AbstractID3v2Tag (even though AbstractID3v2Tag is getting too big... a refactor here is probably long overdue..)

* upstream/master:
  introduce changelog.md and prefer id3v2 over id3v1 for genre and genre description; closes mpatric#120 (mpatric#124)
@coveralls
Copy link

Coverage Status

Coverage increased (+7.8%) to 69.207% when pulling 9ef8e1f on Code0987:master into 00a620b on mpatric:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+7.8%) to 69.207% when pulling 9ef8e1f on Code0987:master into 00a620b on mpatric:master.

@dargmuesli
Copy link

@mpatric @hennr What's the state on this?

@de5car7es
Copy link

Hi

Its really too bad that you still did not approved this pull request.
It works great and I encourage you to combine it.

Is there anything I can do to help in this matter ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants