Page 1 of 2

Refer to directory name rather than file name.

Posted: 2012-05-09 22:03:21
by rs232
The way my files are organised at the moment is as follow:

Directory name very precise with original title, english title and year.
Within the directory.... the mess or almost :-)

Is it possible to get query e.g. IMDB using as movie name the directory where .avi/mpg/etc media is contained?

Thanks :-)

P.S. A way would be to use the "last directory" before the media when importing, but the only field I can find is actually the full path including drive name and upper directories.

Posted: 2012-05-10 08:04:50
by soulsnake
I had folder name in last version 4.1.1 [BETA]:
viewtopic.php?t=4844

During import of media files, select column folder instead filename for movie title ;).

Soulsnake.

Posted: 2012-05-10 08:37:51
by rs232
Thanks!

I've installed the latest beta and tried the import. I have to say I can't see any folder reference when importing. As in the non beta there are 3 identical fields with reference to "paths" one of which called URL. All three have to the full path of the dir and not the last dir only.

May be I'm doing something wrong?

Posted: 2012-05-10 08:49:42
by soulsnake
Folder name is after filename:

Folder name: Column 8
Folder name filtered : Column 9

Code: Select all

As in the non beta there are 3 identical fields with reference to "paths" one of which called URL.
There are not identical!
Move mouse on column value and look at window bottom, it is written what this column contains.

Soulsnake.

Posted: 2012-05-10 15:08:45
by rs232
really good thanks! I've managed to make it working

Now, any way to extract the year as it's always contained into directory name between two square brackets e.g. [2003] and add it to the database?

Posted: 2012-05-10 15:23:42
by soulsnake
Now, any way to extract the year as it's always contained into directory name between two square brackets e.g. [2003] and add it to the database?
Yes it is possible.
First: Import movies like you do.
Second: Run a maked script on selected movies to extract year in title with a simple regular expression.

I have not the time to give you the code now because I am busy.
But I will give you the code tonight if you want.

Soulsnake.

Posted: 2012-05-10 15:42:57
by rs232
That's really good, thanks for the support! I would love to get a regular expression example if you don't mind. Also this may help other users

I have one additional question, as I have many movies and they are pretty much well ordered in terms of directory name, what is filename (directory name in this case) recommendation planning to run e.g. the IMDB script to populate the actual movie database?

my movie directory is now called e.g.

English title (original title if any) [year]


when running the IMDB script I get asked to enter manually the tile for almost all the movies I'm feeding to the script.

I've tried the modify the directory name (and so the original name imported!) into:

English title [original title if any] (year)

running into more or less same problem.

manually querying IMDB via web works as follow:

Orignal title (year) --> works immediately
English title (Original title) [year) --> IMDB answer with list of options
English title [year] --> IMDB answer with list of options

Posted: 2012-05-10 16:11:28
by soulsnake
That's really good, thanks for the support! I would love to get a regular expression example if you don't mind. Also this may help other users
I will do, don't worry.
I have one additional question, as I have many movies and they are pretty much well ordered in terms of directory name, what is filename (directory name in this case) recommendation planning to run e.g. the IMDB script to populate the actual movie database?

my movie directory is now called e.g.

English title (original title if any) [year]

when running the IMDB script I get asked to enter manually the tile for almost all the movies I'm feeding to the script.

I've tried the modify the directory name (and so the original name imported!) into:

English title [original title if any] (year)

running into more or less same problem.

manually querying IMDB via web works as follow:

Orignal title (year) --> works immediately
English title (Original title) [year) --> IMDB answer with list of options
English title [year] --> IMDB answer with list of options
I think the better way for you is to modify IMDB script to delete title content after '(' or '['. This way only the english title will be used to search movie on IMDB.
English title --> works immediately ??

Soulsnake.

Posted: 2012-05-10 18:15:49
by soulsnake
Here is the script to copy/paste in script editor.
You can run it on all movies.
It takes your filename (foldername) stored in OriginalTitle and it parse it like this:
- Put English title in Translated title field
- Put Original title in Original title field
- Put Year in Year field

If it is not really what you want say me, I can modify it ;)

Code: Select all

program ParseTitle;
var
  Value, TranslatedTitle, OriginalTitle, Year: string;
  
begin
  Value := GetField(fieldOriginalTitle);
  RegExprSetExec('^(.*)(\(|\[)(.*)(\)|\]).*(\(|\[)(.*)(\)|\]).*$', Value);
  TranslatedTitle := Trim(RegExprSubstitute('$1'));
  OriginalTitle := Trim(RegExprSubstitute('$3'));
  Year := Trim(RegExprSubstitute('$6'));
  //ShowMessage('|' + Value + '|' + ' - |' + TranslatedTitle + '|' + ' - |' + OriginalTitle + '|' +' - |' + Year + '|')
  if (TranslatedTitle <> '') and (OriginalTitle <> '') and (Year <> '') then
  begin
    SetField(fieldTranslatedTitle, TranslatedTitle)
    SetField(fieldOriginalTitle, OriginalTitle)
    SetField(fieldYear, Year)
  end;
end.
Soulsnake.

Posted: 2012-05-12 17:00:02
by rs232
That's brilliant! Thanks :-)
I did a run and it seems to pick up almost everything! The only thing I've noticed is that it will not get the year into the database e.g. [2007] if the movie does not have a original language reference. e.g.

my movie (la mia pelicula) [2007] --> works fine

my movie [2007] --> will not import the year




Apart from this little input on the ParseTitle script these are my considerations now:

1) I can leave the directory names as they are. However... see point 2

2) I would have to modify the IMDB script to query by original name + year (coming from database year and not original name) in between round brackets.

e.g. Titanic (1997)

2a) Changing the IMDB script to query by *translated name (year)* if the *original name (year)* is not found, would be outstanding!



Beside this IMDB or not, just simply importing media I've run into this little issue:

A) when importing media if I have one directory with a 1.4 Gb movie this is often split in two .avi files. This automatically implies:
- Double record in the database
- half length of the movie per record (minutes)

Thanks again for the excellent support!

Posted: 2012-05-13 17:40:39
by soulsnake
I did a run and it seems to pick up almost everything! The only thing I've noticed is that it will not get the year into the database e.g. [2007] if the movie does not have a original language reference. e.g.

my movie (la mia pelicula) [2007] --> works fine

my movie [2007] --> will not import the year
I modify the code bellow to take this case into account ;).

Code: Select all

program ParseTitle;

// Parse title like:
// Translated title (Original Title if any) [Year] or Translated title [Original Title if any] (Year)

// For example:
// Titanic [1997] or Titanic (1997)
// Titanic (Titanic) [2007] or Titanic [Titanic] (2007)

var
  Value, TranslatedTitle, OriginalTitle, Year: string;
  
begin
  Value := GetField(fieldOriginalTitle);
  // (1) Title is like this ? -> Translated title (Original Title) [Year]
  RegExprSetExec('^(.*)(\(|\[)(.*)(\)|\]).*(\(|\[)(.*)(\)|\]).*$', Value);
  TranslatedTitle := Trim(RegExprSubstitute('$1'));
  OriginalTitle := Trim(RegExprSubstitute('$3'));
  Year := Trim(RegExprSubstitute('$6'));
  //ShowMessage('|' + Value + '|' + ' - |' + TranslatedTitle + '|' + ' - |' + OriginalTitle + '|' +' - |' + Year + '|')
  if (TranslatedTitle <> '') and (OriginalTitle <> '') and (Year <> '') then
  begin // (1) Yes
    SetField(fieldTranslatedTitle, TranslatedTitle)
    SetField(fieldOriginalTitle, OriginalTitle)
    SetField(fieldYear, Year)
  end
  else
  begin // (1) No
    // (2) Title is like this ? -> Translated title [Year]
    RegExprSetExec('^(.*)(\(|\[)(.*)(\)|\]).*$', Value);
    TranslatedTitle := Trim(RegExprSubstitute('$1'));
    OriginalTitle := TranslatedTitle;
    Year := Trim(RegExprSubstitute('$3'));
    //ShowMessage('|' + Value + '|' + ' - |' + TranslatedTitle + '|' + ' - |' + OriginalTitle + '|' +' - |' + Year + '|')
    if (TranslatedTitle <> '') and (OriginalTitle <> '') and (Year <> '') then
    begin // (2) Yes
      SetField(fieldTranslatedTitle, TranslatedTitle)
      SetField(fieldOriginalTitle, OriginalTitle)
      SetField(fieldYear, Year)
    end
    else
    begin // (2) No
      // Do nothing
    end;
  end;
end.
1) I can leave the directory names as they are. However... see point 2
Sorry, I don't understand what you mean.
You want titles in translated title and original title fields like are they after running script or keep titles are thay berore run script ?
If it is the second option you want, just comment this lines:

Code: Select all

      SetField(fieldTranslatedTitle, TranslatedTitle)
      SetField(fieldOriginalTitle, OriginalTitle)
like this:

Code: Select all

      //SetField(fieldTranslatedTitle, TranslatedTitle)
      //SetField(fieldOriginalTitle, OriginalTitle)
2) I would have to modify the IMDB script to query by original name + year (coming from database year and not original name) in between round brackets.

e.g. Titanic (1997)

2a) Changing the IMDB script to query by *translated name (year)* if the *original name (year)* is not found, would be outstanding!
I need to know how you want titles in translated title and original title fields before to make any change ;).
A) when importing media if I have one directory with a 1.4 Gb movie this is often split in two .avi files. This automatically implies:
- Double record in the database
- half length of the movie per record (minutes)
In media import window, you have an option (checkbox to check) to merge multi disks/files.
By default, filenames of multi disks have to be like this to be merged:

Code: Select all

Movie title ... cd1.avi
Movie title ... cd2.avi
Movie title ... cd3.avi
...
But you can change disk pattern if you want in same window.

Soulsnake.

Posted: 2012-05-13 19:35:17
by rs232
I have to say, the more I use this tool the more I realise how powerful it is! You can pretty much do anything once you get familiar with the scripting :-)
I see as a user a need to have a unified naming convention. Nobody is using the same way to classify the own media, but perhaps giving
an advice could be helpful for other people. I'm not say that the naming convention I'm using is perfects (actually far from) but at least it's consistent
and using e.g. ant rename I can change brackets, case or rename the whole lot in a matter of minutes.
So... how about an advice of naming convention for the users?

Answering what written so far:
The latest version of the ParseTitle script works well! The only thing is (but absolutely acceptable!!) that if a movie is called e.g.:

Titanic [1997]

this will have "Titanic" as original as well as the translated title. Not an issue at all, so very please with it as it is!


IMPORTING MEDIA:

A) Multiple files per title: I did check the "merge media" as advised however a directory with the two files called:
dir:-
4 (Chetyre) [2005]
files cointained:-
4 AKA Chetyre (2005) 1.avi
4 AKA Chetyre (2005) 2.avi


These two files are imported as individual movies.

B) subtitles when importing media, I have subtitles in .srt but they are not found. Yes or no would already be a good info to me if any of the subs extension file is found in the directory: .srt|.idx|.sub|.ssa

IMDB:
A) When running the IMDB script: Sometime I'm sometime asked for an alternative title. I guess this happen because the query on the original name failed.
I like the user interaction but can I suggest you provide additional info to the user when asking for human input?
Example a priceless piece of information would be the full path of the file. Another good info could be the year (if any available)

B) talking about the IMDB script itself. I assume the script is asking for user input ONLY if an exact unique match is found. If this is true, how about having the query using the main title until a "("is found, example as follow.
Given a directory called:

Super duper movie title (original Polish title) (Malaysian title) (Spanish title) (n... alternative titles) [year]

would look for: Super duper movie title
the idea being: try first the title before the first "(", if this is not found run the query using the title within the first (),
if not the title within the second () and so on until a single record is found in IMDB or alternative titles are not found.

In summary try:
- Super duper movie title
- Polish title
- Malaysian title
- Spanish title
- n... alternative titles

if any of the above query return a single unique match --> use it!

C) If running the script I enter a title manually modifying the default option given (which comes from the -Original name- I seem to understand), this input will replace the Original title in the database AND remove the translated title. Not sure if this is wanted but it does happen... One example below:
Before the IMDB script is run:
Translated: 10 1/2
Original: Dix et demi

After:
Translated: 10 1/2
Original:

Please forget about these following comments I made in my previous post: I think my point IMDB B) above encompasses what I was trying to say in a much better way. I've also noticed that adding the year in the IMDB query doesn't help.
2) I would have to modify the IMDB script to query by original name + year (coming from database year and not original name) in between round brackets.

e.g. Titanic (1997)

2a) Changing the IMDB script to query by *translated name (year)* if the *original name (year)* is not found, would be outstanding!

Posted: 2012-05-13 21:50:05
by soulsnake
I have to say, the more I use this tool the more I realise how powerful it is! You can pretty much do anything once you get familiar with the scripting :-)
Yes, you are right, AMC is very powerfull mainly if you have some knowledge with "Pascal language" for scripting.
It is not so difficult to learn it and write your own scripts ;).
Answering what written so far:
The latest version of the ParseTitle script works well! The only thing is (but absolutely acceptable!!) that if a movie is called e.g.:

Titanic [1997]

this will have "Titanic" as original as well as the translated title. Not an issue at all, so very please with it as it is!
Yes this is normal.
If you don't want this, just comment this last line:
SetField(fieldOriginalTitle, OriginalTitle)
like this:
//SetField(fieldOriginalTitle, OriginalTitle)
IMPORTING MEDIA:

A) - Multiple files per title: I did check the "merge media" as advised however a directory with the two files called:
dir:-
4 (Chetyre) [2005]
files cointained:-
4 AKA Chetyre (2005) 1.avi
4 AKA Chetyre (2005) 2.avi

These two files are imported as individual movies.
In your case you don't have 'cd' tag before number.
Don't worry, you can change disk tag pattern like this, it should work too with movie names like in your example:

Code: Select all

(cd[0-9]{1,3}| [0-9]{1,3}.)
B) - subtitles when importing media, I have subtitles in .srt but they are not found. Yes or no would already be a good info to me if any of the subs extension file is found in the directory: .srt|.idx|.sub|.ssa
AMC only imports subtitles included in video.
It doesn't check if external subtitles exist.
IMDB

...
A) B) It is not me who maintains this script, but it is a good suggestion.
C) To re-run script on skipped movies, just select skipped movies in list and re-run script only on selection (select this option in scripting window before to run script) ;).

Soulsnake.

Posted: 2012-05-14 12:57:39
by rs232
Great, I'm doing big progress with my database :-)

The multiple file merge under single title worked fine.

So I guess you mean only .mkv for built in subtitles... Can I suggest to look into for external subtitles files too? I think it's quite easy to check the presence of the sub file/s

IMDB:

Sorry I thought you were maintaining the IMDB script... anybody I can forward these suggestion to?

Still talking about IMDB, let's say I have a database with 10 movies and run the IMDB script, if I add 2 movies and re-run IMDB script this will ask again information on the existing movies such as movie title to run the query. IMDB does store the movie URL into the database. I think it should check the existence of this field before re-asking question to the user as it's unthinkable to re-provide the details over and over again. Another very doable option would be to store uniquely the IMDB url into the media folder. I've seen this don somewhere else.

General feature request:
Considering the database can become stupidly large (and slow accordingly I guess) is there any chance to appy a logical division sich as folders? As it is not the only think I can think about is to have a new database every N movies or e.g. one for every letter A,B,C... X,Y,Z

my 2 cents :-)

Posted: 2012-05-14 14:25:11
by soulsnake
Can I suggest to look into for external subtitles files too? I think it's quite easy to check the presence of the sub file/s
How can I guess the language of the subtitles in the files .str/... ?
If you store filename in a field during import, maybe we could write a script for your personnal use to check if external file .str/... exists and add languages of subtitles in the corresponding field.
Still talking about IMDB, let's say I have a database with 10 movies and run the IMDB script, if I add 2 movies and re-run IMDB script this will ask again information on the existing movies such as movie title to run the query.
I don't understand why you re-run IMDB script on movies already filled by IMDB ???
Considering the database can become stupidly large (and slow accordingly I guess) is there any chance to appy a logical division sich as folders? As it is not the only think I can think about is to have a new database every N movies or e.g. one for every letter A,B,C... X,Y,Z
Unless your database exceeds 20 000 movies, it should not be a problem for AMC to manage them in one catalog ;).
Personnaly, I make a new folder named with current date each time I have to add new movies in AMC (in same catalog of course).

Soulsnake.

Posted: 2012-05-15 07:07:28
by rs232
Well as mentioned above having a record saying subtitles yes/no it's already a great piece of info, of course knowing the language would be perfect! So having any .srt/.sub or any other subtitle file would mean yes basically, otherwise no. Just an idea...
Oh and... yes! I do store the full movie path+filename under "source:" I was using URL but that's where the IMDB scripts writes the IMDB URL so had to change.


I don't really re-run the IMDB script on all the movies again. Sorry this question should have been on media import and not IMDB. What I was trying to ask is:
The very first time I run the media import it's fine as it gets all the movies and store them into the AMC database. Later I optionally run the PaseTitles and IMDB script and that's crystal clear to me now :-) But how about if I add movies to the file system in different directories and re-run a media import after 2 weeks and 30 movies?
I have my movies organised by name using parent directory letters like: A,B,C,D... X,Y,Z. So "Titanic" would be under "T" per say.
I could somehow manage to find the latest movies added but still I would have to browse manually the dir and add them to AMC.
Would it be possible to have a flag when importing media to check if the files I'm trying to import using -media import- are already in the database or not?
With such a option I can just re-import the whole root directory and only movies not already in the database will be imported.
At the same time an option "purge movies not on the file system any more" would clear up record of deleted movies from the database.

Great news on the database performance! I wish I had 20000 movies lol! My was just a point of discussion I have to admit I'm not experiencing performance problem. I was just thinking about the future

Posted: 2012-05-15 12:30:54
by soulsnake
Well as mentioned above having a record saying subtitles yes/no it's already a great piece of info, of course knowing the language would be perfect! So having any .srt/.sub or any other subtitle file would mean yes basically, otherwise no. Just an idea...
Why not but for now I think the better way is to make a personnal script to fill subtitle field like you want when an external file .str/.sub exists in your movie directory (if it is the place where you put .str/.sub for a movie).
I will give you the code to do this when I will have a little more time ;).
I don't really re-run the IMDB script on all the movies again. Sorry this question should have been on media import and not IMDB. What I was trying to ask is:
The very first time I run the media import it's fine as it gets all the movies and store them into the AMC database. Later I optionally run the PaseTitles and IMDB script and that's crystal clear to me now :-) But how about if I add movies to the file system in different directories and re-run a media import after 2 weeks and 30 movies?
I have my movies organised by name using parent directory letters like: A,B,C,D... X,Y,Z. So "Titanic" would be under "T" per say.
I could somehow manage to find the latest movies added but still I would have to browse manually the dir and add them to AMC.
Would it be possible to have a flag when importing media to check if the files I'm trying to import using -media import- are already in the database or not?
With such a option I can just re-import the whole root directory and only movies not already in the database will be imported.
At the same time an option "purge movies not on the file system any more" would clear up record of deleted movies from the database.
Ok, I think the better way is to add an option in "import media" window to uncheck movies (in list to import) whose filename already exists in database.
For this you have to select a field where filename is stored (with or without fullpath, the comparison will be done only on file name with extension).
In your case, you will select 'source' field.
In this way, only movies with a filename that doesn't exist in database will be checked and so imported.
What do you think ?

To remove movies whose file doesn't exist anymore, a little script can be used to check if file doesn't exist and set a special flag on this movies (for example check the checkbox of this movie or set a specific color tag to this movie).
In this way you will can delete movies with this special flag.

Soulsnake.

Posted: 2012-05-15 15:17:49
by rs232
I will give you the code to do this when I will have a little more time wink.


Take you time, I feel already very lucky to have gotten where I'm at the moment :)
Ok, I think the better way is to add an option in "import media" window to uncheck movies (in list to import) whose filename already exists in database.
I like this! If you ask me: I think there's a need to add a "Full path" (including filename as I've found sometime different movies with same filename!!) field to the default database. This field can then be used by media import for the scope you mentioned.
If you decide to go this way can I just add a suggestion? Once the directories are scanned can you list the checked files (to be imported) first? This would simplify the management/identification of new files.
To remove movies whose file doesn't exist any more, a little script can be used to check if file doesn't exist and set a special flag on this movies
I'm sure I'm not the only user of import media ;-) and I guess other users would like this PruneDatabase function to be available somehow. I do like the colours/marking of records to be manually removed, perhaps you may want to reserve a special colour for this so that users can't make mistakes marking a good record as pruned.

I think in this thread there's a bunch of good ideas for your next beta release :-)

Posted: 2012-05-16 09:31:47
by soulsnake
Take you time, I feel already very lucky to have gotten where I'm at the moment
Here is the script to find external subtitles in the folder of movie.
In: field Source to get full path of movie file
Out: field Subtitles with STR and/or SUB value if .srt and/or .sub file has been found for current movie.
I make the assumption that you have one movie by folder.
If you have more than one movie by folder, script need to be modify to search subtitles files with the same name of movie file.

Code: Select all

program FindExternalSubtitles;
var
  Value, FullPath, Path, Subtitles: string;

begin
  // Init subtitles value
  Subtitles := '';
  // Get full path from field Source
  FullPath := GetField(fieldSource);
  // Extrat path from full path
  Path := ExtractFilePath(FullPath);

  // List .str files in directory
  Value := ListDirectory(Path, '*.str');
  // If .str has been found
  if Value <> '' then
  begin
    if Subtitles <> '' then
      Subtitles := Subtitles + ', ';
    Subtitles := Subtitles + 'STR';
  end;

  // List .sub files in directory
  Value := ListDirectory(Path, '*.sub');
  // If .sub has been found
  if Value <> '' then
  begin
    if Subtitles <> '' then
      Subtitles := Subtitles + ', ';
    Subtitles := Subtitles + 'SUB';
  end;
  
  // Write subtitles value in field Subtitles
  SetField(fieldSubtitles, Subtitles)
end.
I like this! If you ask me: I think there's a need to add a "Full path" (including filename as I've found sometime different movies with same filename!!) field to the default database. This field can then be used by media import for the scope you mentioned.
If you decide to go this way can I just add a suggestion? Once the directories are scanned can you list the checked files (to be imported) first? This would simplify the management/identification of new files.
Ok, I will do it.
About just filename or full path, I will make comparison between selected field value and "just filename" of movie found + selected field value and "full path" of movie found. If one of them match, the movie will be unchecked.
In this way user you can store the full path or just the filename in a field in order to make comparison with existing movies and new movies.
I'm sure I'm not the only user of import media ;-) and I guess other users would like this PruneDatabase function to be available somehow. I do like the colours/marking of records to be manually removed, perhaps you may want to reserve a special colour for this so that users can't make mistakes marking a good record as pruned.
Or I can just give the choice to the user of color to use in script option ;).
I think in this thread there's a bunch of good ideas for your next beta release :-)
Yes, and a lot of work... :D
I will try to add these new features to the next release.

Soulsnake.

Posted: 2012-05-16 18:08:07
by rs232
In: field Source to get full path of movie file
Is sounds great! I've just tested it yet. I had to change two reference from STR into SRT ;) but it works great!
I make the assumption that you have one movie by folder.
I definitely have some movies split in two files. So yes it has only one movie per folder but sometime there are 2 video files and 2 sub files.
In this way user you can store the full path or just the filename in a field in order to make comparison with existing movies and new movies.
Super!

One thing I noticed yesterday is, this is very little and almost meaning less... not not quiet!

When you use media import and scan the directory you have the option to assign fields to columns. I've also found the great icons on the right to load and save the field<->column association. Despite the fact that clicking load every time you open the import it's very trivial and quick I think the save settings should be loaded automatically by default. This program it's kind of personal according to the way you set it. Once you found the right association you'll always use them. So I think once this is saved it should be loaded automatically.
If you update the database every e.g. 2 weeks you might forget to click load and import messed up data. Last think you want is inconsistent info in the database. Anything that help preventing this in my opinion is welcome. Do you agree?


Finally I personally think it makes more sense to have the full size of the movie in the filesize fiels when it comes to movies made by multiple files. So a current 750+750 would be instead a simple 1500. That's easier to read and the "sort by file size" work as it's meant to be ;)

Many thanks again :)