amc file format

If you need help on how to use the program
Post Reply
fidoboy
Posts: 13
Joined: 2006-11-01 12:22:25

amc file format

Post by fidoboy »

I'm developing a plugin for TVedia that reads ant movies database, can u help me with reading the amc file?¿

Regards,

.:FiDo:.
antp
Site Admin
Posts: 9639
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

I can help you, but I need more precise questions ;)
Did you check the help file, page Technical Info -> File Format?
fidoboy
Posts: 13
Joined: 2006-11-01 12:22:25

Post by fidoboy »

I'm reading now the file format info, thanks, but i have some questions... If i open the file for reading binary format, how can i know the leght of each field? the picture is in an array of bytes... how do i know where to finish? I'm using javascript for the script, can u post here a little sample code for reading a single field in the file?

Many thanks in advance,

.:FiDo:.
antp
Site Admin
Posts: 9639
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

The lenght of variable-lenght fields is stored as an integer (4 bytes) before the field itself. Same for the picture.
I do not know much Javascript, so I cannot help you on how to do things with it.
fidoboy
Posts: 13
Joined: 2006-11-01 12:22:25

Post by fidoboy »

Many thanks... ;)
fidoboy
Posts: 13
Joined: 2006-11-01 12:22:25

Post by fidoboy »

I'm using this code in javascript:

objStream = new ActiveXObject("ADODB.Stream");
objStream.Open();
objStream.Type = 1;
objStream.LoadFromFile("D:\\Mis documentos\\Catalogo peliculas\\Mi catalogo.amc");
var dataArr = objStream.Read(35);
...
objStream.Close();
objStream = null;

but dataArr contains a byte array that i don't know how to decode... any ideas??

.:FiDo:.
fidoboy
Posts: 13
Joined: 2006-11-01 12:22:25

Post by fidoboy »

I'm sorry but i'm going crazy with this! I'm not capable of read your delphi file from javascript!! Please, give me some hint, a link or something to read the AMC file from javascript... :cry:
antp
Site Admin
Posts: 9639
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

As I said, I can't help you for doing that in Javascript :/ I am not even sure that it is possible.
Maybe that the XML file format of AMC is easier to read with that?
Knitter
Posts: 9
Joined: 2007-05-19 16:53:00
Location: Leiria, Portugal
Contact:

Post by Knitter »

I also need some help reading the file. I'm using Java and I need to know if the integer that represents the string length is Big Endian or Little Endian. That will help a bit.

Another question, so that I confirm that I'm not thinking this the wrong way:

Your file starts with an integer stating the size of the string
"AMC_3.5 Ant Movie Catalog 3.5.x www.buypin.com www.antp.be" an then has the string, after that there is another integer to tell how long is the owner name field followed by the owner name string?

Generally speaking, to read your file, one would follow these lines:

read an int into x
read x bytes representing the first string
read an int into y
read y bytes representing the owner name

and so on for the header. After that one will go on reading the rest of the fields.
fidoboy
Posts: 13
Joined: 2006-11-01 12:22:25

Post by fidoboy »

I could be very helpfoul if you post here a sample routine using java or javascript for reading the file... it could be of great help for me.... ;)

Regards,
Knitter
Posts: 9
Joined: 2007-05-19 16:53:00
Location: Leiria, Portugal
Contact:

Post by Knitter »

I would like to but I really can't :D
Assuming the integer is Big Endian I would right teh following code to read an integer:

Code: Select all

 DataInputStream din = new DataInputStream(new BufferedInputStream((new FileInputStream("c:\\testcatalog.amc"));

int integersize = din.readInt();
This results in a wrong integer size, so I belive as "541150531" can't be the size of any string ;)

If I assume it's little endian I'll have to read as:

Code: Select all

BufferedInputStream bin = new BufferedInputStream(new FileInputStream("c:\\testcatalog.amc"));

byte[] fourbytes = new byte[4];

bin.read(fourbytes);

int integersize = ((fourbytes[0] & 0xff)) | ((fourbytes[1] & 0xff) << 8) | ((fourbytes[2] & 0xff) << 16) | ((fourbytes[3] & 0xff) << 24);
This results in the number "1129136416"...

So I don't know where to go to.[/code]
antp
Site Admin
Posts: 9639
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

There is a space (0x20) before and after the header string, that you did not include in the quotes in your message, be sure to have these in your code. You have to "skip" these 65 bytes then.

Code: Select all

  strFileHeader35 = ' AMC_3.5 Ant Movie Catalog 3.5.x   www.buypin.com    www.antp.be ';
Then you have the integer size of the owner name, then the owner name itself, etc.

I always forget these big/little endian things, but if I remember correctly Delphi uses little endian, so AMC's file format uses that too.
It would maybe be easier to make a sample catalog with 1 movie and a special value in each file (including file->properties), and then watch the contents with an hexadecimal editor, though that I do not see what is missing in what I said above and in the help file :??:
Knitter
Posts: 9
Joined: 2007-05-19 16:53:00
Location: Leiria, Portugal
Contact:

Post by Knitter »

Well I was reading that the every string had an integer stating the size and, because you didn't said otherwise, I assumed that the first string in the file also had that integer. I was trying to read the first four bytes of the file as an integer.

I then found that those 4 bytes represented " ACM", now I know what I'm doing wrong :)

I would suggest that the either the help file be change or the file format be changed so that *every* string has it's size stated before. It will help make things more correct. If you decide to change the header I have to recompile the software, if you add the size of that first string then even if the header is changed the software works.

It just doesn't make sense to have on string in the all file that does not have it's size before.

I think I can now manage. Thank you.
Knitter
Posts: 9
Joined: 2007-05-19 16:53:00
Location: Leiria, Portugal
Contact:

Post by Knitter »

In the help file you have

Code: Select all

"OwnerName:          string;"
Is the ";" character in the file?
Knitter
Posts: 9
Joined: 2007-05-19 16:53:00
Location: Leiria, Portugal
Contact:

Post by Knitter »

Ok, scratch that :D
Next question: and "Added Date" of 18-05-2007 ended up as a "39220" integer. What does this value represent? The time since Epoch? Most likely not... how can I get the correct date out of this value?
antp
Site Admin
Posts: 9639
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

The header is not a string, it is just the header :D
Its purpose is to identify the version of the program and prevent old programs to read newer formats that they would not be able to read correctly if I add a field.
So of course programs has to be recompiled to use the new file format when it is modified.
XML is a better choice for compatibility with non-existing-yet versions, so maybe some day I may use XML (even if stored in another format) rather than current system.

About the date, indeed it is a special value since a fixed date. It is Delphi's TDateTime format, 0 = 30-12-1899 and each unit is one day (decimal part, not used in this case, is for the time).
Knitter
Posts: 9
Joined: 2007-05-19 16:53:00
Location: Leiria, Portugal
Contact:

Post by Knitter »

If you don't add more than 65 bytes I believe I can live with that :D
I want to be able to read this file format, writing it will most likely not be an option.

So if the date is days after 30-12-1899 I can just subtract todays date, in days, from the assumed zero date and get the number of days.... maybe there is still light at the end of the tunel :D

By the way, fidoboy, I have been able to read the AMC binary file. I always read byte arrays. When reading integer you have to read 4 bytes at a time and convert those 4 bytes into a single integer value. The integer format is little endian. When reading strings you just need to read the number of byte that form the string and every array position will hold the value of the ASCII character it corresponds to. I haven't got to the picture nor the boolean values yet but I think they'll not be a problem.

I'll try to make my spike solution more developer friendly and I'll post the solution. If I can I'll make it tomorrow.

Thanks
Knitter
Posts: 9
Joined: 2007-05-19 16:53:00
Location: Leiria, Portugal
Contact:

Post by Knitter »

Here you have a simple application that will open a ACM file and read some info on it, it's just a spike solution, or a prof of concept if you prefer.
It is written in Java an will output the info to the console, so you must use it from the console, and display a JDialog with an image.

Jar file, just run "java -jar K_Movie_Cataloger_Spikes.jar": http://www.sergio-lopes.org/projectfile ... Spikes.jar
My acm file, must be at "c:\": http://www.sergio-lopes.org/projectfile ... /Anime.amc
The important class: http://www.sergio-lopes.org/projectfile ... eader.java
The Main class, not important: http://www.sergio-lopes.org/projectfile ... /Main.java
The image i used, not necessary, but if you want to compare with the one on the catalog file: http://www.sergio-lopes.org/projectfile ... enshin.jpg

I have yet another question :D
What is the field "Export: Boolean;" for? And where is the option on the Ant Movie Catalog that changes it from false to true?
antp
Site Admin
Posts: 9639
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

It is the "Checked" field that I forgot to rename in the help file :D It corresponds to the checkbox on the left of the title in the movie list. In earlier versions that checkbox was added to allow users to specify which movies had to be included in the HTML export, but later it was extended to other purposes, as it can be used for many things actually.
Post Reply