[REL] DVD Empire fix
[REL] DVD Empire fix
I like to use DVD Empire so I thought I'd try my hand at a fix. Try it out and lemme know how it works.
BTW this is my first post so my apologies if I didn't follow protocol.
* EDIT *
deleted code due to update below....
BTW this is my first post so my apologies if I didn't follow protocol.
* EDIT *
deleted code due to update below....
Last edited by deadeye on 2009-02-19 20:38:21, edited 1 time in total.
And once again
Thanks, that makes a new script a lot less urgent.
Some notes:
- When you copy the script to forum, you should prefer a complete copy. To do so, open the script file with an external editor and you will see some more lines on the beginning of the script, which hold some information and preferences (e.g. script options) that might get lost when you copy it from the internal editor.
- The script still misses some import values like original title and media type, producer field imports producers + directors (e.g. on "No country for old men" you will have "Scott Rudin,Ethan Coen,Joel Coen,Ethan Coen,Joel Coen" as producers then.
- On "Audio format" section the script imports some values to fieldComments, others to fieldLanguages. This is an error from previous script version. It should probably be fieldAudioFormat for all, I guess.
But nice job so far!
Thanks, that makes a new script a lot less urgent.
Some notes:
- When you copy the script to forum, you should prefer a complete copy. To do so, open the script file with an external editor and you will see some more lines on the beginning of the script, which hold some information and preferences (e.g. script options) that might get lost when you copy it from the internal editor.
- The script still misses some import values like original title and media type, producer field imports producers + directors (e.g. on "No country for old men" you will have "Scott Rudin,Ethan Coen,Joel Coen,Ethan Coen,Joel Coen" as producers then.
- On "Audio format" section the script imports some values to fieldComments, others to fieldLanguages. This is an error from previous script version. It should probably be fieldAudioFormat for all, I guess.
But nice job so far!
deadeye,
I can not thank you enough. Myself, as well as countless others, use DVDEmpire.com as our prime DVD resource.
I just copied your new script, opened the editor in the old script and pasted this new one over it, works like a charm again.
A big debt of gratitude for your time and effort. If you ever need assistance in other areas of PC/DVD information/functions, pm me, maybe I can assist you.
Respectfully
oneacer
I can not thank you enough. Myself, as well as countless others, use DVDEmpire.com as our prime DVD resource.
I just copied your new script, opened the editor in the old script and pasted this new one over it, works like a charm again.
A big debt of gratitude for your time and effort. If you ever need assistance in other areas of PC/DVD information/functions, pm me, maybe I can assist you.
Respectfully
oneacer
Last edited by oneacer on 2009-02-18 00:23:17, edited 1 time in total.
I think I fixed the original title field
[/code]
Code: Select all
// DVDEmpire.com Script
// Version 2.0.3 bugfixed picturedownload (20070106/bad4u)
// Version 2.0.4 bugfixed description & medium type import (20080403/bad4u)
// bugfixed changed search results (20090217/deadeye)
program From_dvdempire;
var
MovieName: string;
MovieName2: string;
// -------------------------------------------------------------------------------------------------------
function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
var
i: Integer;
begin
result := -1;
if StartAt < 0 then
StartAt := 0;
for i := StartAt to List.Count-1 do
if Pos(Pattern, List.GetString(i)) <> 0 then
begin
result := i;
Break;
end;
end;
// -------------------------------------------------------------------------------------------------------
function GetValues(Line : String; UseCommaDelimiter : Boolean): String;
var
Value : String;
StartPos : Integer;
EndPos : Integer;
Delimiter : String;
begin
Result := '';
Line := StringReplace(Line, '•', '');
if (UseCommaDelimiter) then
Delimiter := ','
else
Delimiter := #13 + #10;
while(true) do
begin
StartPos := Pos('">', Line) + 2;
EndPos := Pos('</a>', Line);
Value := Copy(Line, StartPos, EndPos - StartPos);
Line := Copy(Line, EndPos + 1, Length(Line) - EndPos);
if (EndPos < StartPos) then
break;
Value := Trim(Value);
HTMLDecode(Value);
HTMLRemoveTags(Value);
if (Length(Result) > 0) then
Result := Result + Delimiter;
Result := Result + Value;
end;
end;
// -------------------------------------------------------------------------------------------------------
procedure GetInfo(Page: TStringList; ItemID: String);
var Line, Value, Text, AudioFormat : String;
LineNR, StartPos, EndPos, LineNrEnd, i, y : Integer;
LineCR: Boolean;
begin
//originální název
LineNr := FindLine('<title>', Page, 0);
if LineNr >-1 then begin
Line := Page.GetString(LineNr);
StartPos := Pos('<title>',Line);
EndPos := Pos('- DVD-Video | DVD Empire </title>', Line);
Value := Copy(Line, StartPos, EndPos-StartPos);
if Pos(' / ', Value) > 0 then
Value := Copy(Value, 0, Pos(' / ', Value));
HTMLRemoveTags(Value);
HTMLDecode(Value);
SetField(fieldOriginalTitle, Value);
end;
// Medium Type
if (LineNr >-1) and (Pos(' / ', Line) > 0) and (GetOption('SetMediumType')=1) then begin
StartPos := Pos(' / ',Line);
EndPos := Pos('</title>', Line);
Value := Copy(Line, StartPos+3,EndPos-StartPos-3);
HTMLRemoveTags(Value);
HTMLDecode(Value);
SetField(fieldMediaType, Value);
end;
// URL
SetField(fieldURL,'http://www.dvdempire.com/Exec/v4_item.asp?item_id=' + ItemID);
//Rating
LineNr := FindLine('<b>Rating:</b>', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
StartPos := Pos('<b>Rating:</b>',Line) + Length('<b>Rating:</b>');
Line := copy(Line, StartPos, Length(Line) - StartPos);
Value := trim( copy(Line, 1, pos('<br />', Line) - 1) );
SetField(fieldRating, Value);
end;
// Year
LineNr := FindLine('<b>Production Year:</b>', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
StartPos := Pos('<b>Production Year:</b>', Line) + Length('<b>Production Year:</b>');
Line := Copy(Line, StartPos, Length(Line) - StartPos + 1);
EndPos := Pos(' ',Line);
if EndPos > 0 then
Value := Trim( Copy(Line, 1, EndPos - 1) )
else
Value := Trim( Copy(Line, 1, 5));
SetField(fieldYear, Value);
end;
// Runtime
LineNr := FindLine('<b>Length:</b>', Page, 0);
if LineNr >-1 then begin
Line := Page.GetString(LineNr);
StartPos := Pos('<b>Length:</b>', Line) + Length('<b>Length:</b>');
Line := Copy(Line, StartPos, Length(Line) - StartPos);
EndPos := Pos('mins',Line);
Value := Trim( Copy(Line, 1, EndPos - 1) );
SetField(fieldLength, trim(Value));
end;
// Director
LineNr := FindLine('<b>Directors:</b>', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
StartPos := Pos('<b>Directors:</b>', Line) + Length('<b>Directors:</b>');;
Line := Copy(Line, StartPos, Length(Line) - StartPos - 1);
EndPos := Pos('</td>', Line);
Line := Copy(Line, 1, EndPos - 1);
Value := GetValues(Line, true);
SetField(fieldDirector, Value);
end;
// Producer
LineNr := FindLine('<b>Producers:</b>', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
StartPos := Pos('<b>Producers:</b>', Line) + Length('<b>Producers:</b>');;
Line := Copy(Line, StartPos, Length(Line) - StartPos - 1);
EndPos := Pos('</td>', Line);
Line := Copy(Line, 1, EndPos - 1);
Value := GetValues(Line, true);
SetField(fieldProducer, Value);
end;
// Actors
LineNr := FindLine('<b>Actors:</b>', Page, 0);
if LineNr > -1 then
begin
Line := Page.GetString(LineNr);
StartPos := Pos('<b>Actors:</b>', Line) + Length('<b>Actors:</b>');;
Line := Copy(Line, StartPos, Length(Line) - StartPos - 1);
EndPos := Pos('</td>', Line);
Line := Copy(Line, 1, EndPos - 1);
Value := GetValues(Line, false);
SetField(fieldActors, Value);
end;
// Picture
LineNr := FindLine('http://images.dvdempire.com/gen/movies/', Page, 0);
if LineNr > -1 then
begin
Line := 'http://images.dvdempire.com/gen/movies/' + ItemID + 'h.jpg';
GetPicture(Line);
end
else
LineNr := FindLine('http://images2.dvdempire.com/gen/movies/', Page, 0);
if LineNr > -1 then
begin
Line := 'http://images2.dvdempire.com/gen/movies/' + ItemID + 'h.jpg';
GetPicture(Line);
end;
// AudioFormat
LineNr := FindLine('PCM Stereo', Page, 0);
if LineNr > -1 then
begin
If Length(AudioFormat)<>0 then AudioFormat := AudioFormat+', ';
AudioFormat := AudioFormat+'PCM Stereo';
SetField(fieldComments, AudioFormat);
end;
LineNr := FindLine('Dolby Digital Stereo', Page, 0);
if LineNr > -1 then
begin
If Length(AudioFormat)<>0 then AudioFormat := AudioFormat+', ';
AudioFormat := AudioFormat+'Dolby Digital Stereo';
SetField(fieldLanguages, AudioFormat);
end;
LineNr := FindLine('Dolby Digital 5.0', Page, 0);
if LineNr > -1 then
begin
If Length(AudioFormat)<>0 then AudioFormat := AudioFormat+', ';
AudioFormat := AudioFormat+'Dolby Digital 5.0';
SetField(fieldLanguages, AudioFormat);
end;
LineNr := FindLine('Dolby Digital 5.1', Page, 0);
if LineNr > -1 then
begin
If Length(AudioFormat)<>0 then AudioFormat := AudioFormat+', ';
AudioFormat := AudioFormat+'Dolby Digital 5.1';
SetField(fieldLanguages, AudioFormat);
end;
LineNr := FindLine('Dolby Digital Surround', Page, 0);
if LineNr > -1 then
begin
If Length(AudioFormat)<>0 then AudioFormat := AudioFormat+', ';
AudioFormat := AudioFormat+'Dolby Digital Surround';
SetField(fieldLanguages, AudioFormat);
end;
LineNr := FindLine('DTS Stereo', Page, 0);
if LineNr > -1 then
begin
If Length(AudioFormat)<>0 then AudioFormat := AudioFormat+', ';
AudioFormat := AudioFormat+'DTS Stereo';
SetField(fieldLanguages, AudioFormat);
end;
LineNr := FindLine('DTS Surround', Page, 0);
if LineNr > -1 then
begin
If Length(AudioFormat)<>0 then AudioFormat := AudioFormat+', ';
AudioFormat := AudioFormat+'DTS Surround';
SetField(fieldLanguages, AudioFormat);
end;
LineNr := FindLine('DTS 5.1', Page, 0);
if LineNr > -1 then
begin
If Length(AudioFormat)<>0 then AudioFormat := AudioFormat+', ';
AudioFormat := AudioFormat+'DTS 5.1';
SetField(fieldLanguages, AudioFormat);
end;
// Description
LineNr := FindLine('<td width="100%" valign="top" class="fontsmall3">', Page, 0) + 1;
LineNrEnd := FindLine('</td>', Page, LineNR) - 1;
if LineNr > 0 then
begin
for i := LineNR to LineNrEnd do begin
LineCR:=false;
Value := Page.GetString(i);
If Pos('<br><br>', Value) <> 0 then LineCR:=true;
Value:=StringReplace(Value, '>i<', '> <');
HTMLRemoveTags(Value);
HTMLDecode(Value);
for y := 1 to Length(Value) do begin
If Ord(Copy(Value, y, 1))=9 then begin
Value:=Copy(Value, 1, y-1)+' '+Copy(Value, y+1, Length(Value));
end;
end;
Value := Trim(Value);
Text:=Text+Value+Chr(13)+Chr(10);
If LineCR=true then Text:=Text+Chr(13)+Chr(10);
end;
SetField(fieldDescription,Copy(Text, 1, Length(Text)-4));
end;
end;
// -------------------------------------------------------------------------------------------------------
procedure AnalyzePage(Address: string);
var
Page: TStringList;
LineNr, StartPos, EndPos, L, EndPos2: Integer;
Line, TempValue: string;
ItemID, MovieAddress, MovieTitle : string;
AddItem : Boolean;
begin
PickTreeClear;
Page := TStringList.Create;
Page.Text := GetPage(Address);
LineNr := FindLine('<title>DVD Empire - Item -', Page, 0);
if LineNr >-1 then
begin
LineNr := FindLine('javascript:itemHelp(', Page, 0);
Line := Trim(Page.GetString(LineNr));
// parameters are separated by ', '
StartPos := pos(''', ''', Line) + 4; // move past the delimiter
Line := copy(Line, StartPos, length(Line) - StartPos + 1); // skip the starting quotes
ItemID := copy(Line, 0, pos(''', ''', Line) - 1);
GetInfo(Page,ItemID);
end
else
begin
LineNr := FindLine('</strong> Matches Found', Page, 0);
if LineNr >-1 then
begin
Line := Page.GetString(LineNr);
StartPos := pos('<strong>', Line) + Length('<strong>');
L := StrToInt('0'+ Copy(Line, StartPos, pos('</strong>', Line) - StartPos),1);
PickTreeAdd(IntToStr(L)+' Matches found', '');
If L>0 Then
begin
// Find Films
LineNr := FindLine('<b><a href=''/Exec/v4_item.asp?item_id=', Page, LineNr + 1);
if LineNr >-1 then begin
Line := Trim( Page.GetString(LineNr) );
repeat
// find the item id
StartPos := Pos('<b><a href=''/Exec/v4_item.asp?item_id=', Line) + 38;
EndPos := StartPos;
if (EndPos < 1) then
break;
repeat
TempValue := Copy(Line, EndPos, 1);
if (TempValue = '>') then
break;
EndPos := EndPos + 1;
until(EndPos < 1);
EndPos := EndPos - 1;
ItemID := Copy(Line, StartPos, EndPos - StartPos);
MovieAddress := 'http://www.dvdempire.com/Exec/v4_item.asp?item_id=' + ItemID;
// discard the stuff we've already processed
EndPos := EndPos + 2;
Line := Copy(Line, EndPos, Length(Line) - EndPos - 1);
// find the movie name
StartPos := 1;
Line := Copy(Line, StartPos, Length(Line) - StartPos);
EndPos := Pos('</a>', Line);
MovieTitle := Copy(Line, 1, EndPos - 1);
// add it to the tree
HTMLDecode(Movietitle);
HTMLRemoveTags(MovieTitle);
// exclusion list -- these are false positives, not really titles
AddItem := true;
if (MovieTitle = 'Only Used Available') then
AddItem := false;
if (AddItem) then
PickTreeAdd(MovieTitle, MovieAddress);
L := L - 1;
until (L = 0);
end;
end;
end;
Page.Free;
if PickTreeExec(Address) then
begin
Page := TStringList.Create;
Page.Text := GetPage(Address);
ItemID :=copy(Address, 51, 8);
GetInfo(Page,ItemID);
end;
end;
//DisplayResults;
end;
// -------------------------------------------------------------------------------------------------------
// Begin program
begin
if CheckVersion(3,5,0) then
begin
PickListClear;
MovieName := GetField(fieldOriginalTitle);
if MovieName = '' then MovieName := GetField(fieldTranslatedTitle);
if Input('Import from www.dvdempire.com', 'Enter the title of the movie:', MovieName) then begin
MovieName2:=MovieName;
MovieName:=StringReplace(MovieName, '’', Chr(39));
MovieName:=AnsiLowerCase(MovieName);
MovieName:=AnsiUpFirstLetter(MovieName);
if pos('The ', MovieName)=1 then MovieName:=StringReplace(MovieName, 'The ', '');
// the &pp=5 makes sure we display all results in one page!
AnalyzePage('http://www.dvdempire.com/Exec/v5_search_item.asp?string='+URLEncode(MovieName)+'&pp=5');
end
end
else
ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)');
end.
Let's try this again:
* fixed the directors name also showing up in producer field
* fixed media type
* fixed video format
* audio format and language now show first entry
* added subtitles and number of discs
http://rapidshare.com/files/199695371/dvdempire.ifs
Nordge1, this one will hang occasionally when searching a long title. Shorten the name and it works fine. I've got a couple of ideas on how to fix that so we'll see.
I'm still looking at cleaning it up more and other ways to make it better so let me know guys.
* fixed the directors name also showing up in producer field
* fixed media type
* fixed video format
* audio format and language now show first entry
* added subtitles and number of discs
http://rapidshare.com/files/199695371/dvdempire.ifs
Nordge1, this one will hang occasionally when searching a long title. Shorten the name and it works fine. I've got a couple of ideas on how to fix that so we'll see.
I'm still looking at cleaning it up more and other ways to make it better so let me know guys.
Hi deadeye,
Again, a BIG thanks on fixing this script.
Side note: Hey, there is another script that I use, that is broke at the moment, when I can not find what I am lookig for on DVDEmpire.com, which is very rare, as DVDEmpire is by far the best.
http://www.cduniverse.com/default.asp?s ... =678155445
The movie section on cduniverse.com at the above link is another very good resource for DVD information. I cetainly understand you are a busy person, but this script would be another big plus if at your leisure you could look at it.
BTW, I suppose I should start a new thread on this (cduniverse.com) if you recommend.
Thnx
Again, a BIG thanks on fixing this script.
Side note: Hey, there is another script that I use, that is broke at the moment, when I can not find what I am lookig for on DVDEmpire.com, which is very rare, as DVDEmpire is by far the best.
http://www.cduniverse.com/default.asp?s ... =678155445
The movie section on cduniverse.com at the above link is another very good resource for DVD information. I cetainly understand you are a busy person, but this script would be another big plus if at your leisure you could look at it.
BTW, I suppose I should start a new thread on this (cduniverse.com) if you recommend.
Thnx
oneacer, I have used DVD Empire a lot lately and I have found everything I have searched for though not always on the first try. Some titles will cause the script to behave badly.
Example - search for the movie "It" and DVD Empire will return over 29,000 results. However if you tell it to search for "It Stephen King", it will return a little over 100 results, much easier to handle.
Regarding cduniverse, it looks like the script was only meant to retrieve the picture. Is that correct?
Example - search for the movie "It" and DVD Empire will return over 29,000 results. However if you tell it to search for "It Stephen King", it will return a little over 100 results, much easier to handle.
Regarding cduniverse, it looks like the script was only meant to retrieve the picture. Is that correct?
dead eye,
Sorry, I just now opened the cduniverse script, and see it is very limited.
Not an issue, you can always copy and paste the info from their movie section on their web site if you ever find the need.
With regards to DVDEmpire.com, I recently had one lock up on me. I was searching for "Mirrors", the new DVD with Keiffer Sutherland. I then went to there web site, typed in Mirrrors and it brought it right up. I did notice however that it listed it as "Mirrors: Unrated". So I open up Ant, searched again, this time typing in "Mirrors: Unrated", and it brought it right up. It would appear that being specific would be a good rule of thumb.
Again, if I might be able to assit you on any tech/pc/software issues, PM me.
Thanks
Sorry, I just now opened the cduniverse script, and see it is very limited.
Not an issue, you can always copy and paste the info from their movie section on their web site if you ever find the need.
With regards to DVDEmpire.com, I recently had one lock up on me. I was searching for "Mirrors", the new DVD with Keiffer Sutherland. I then went to there web site, typed in Mirrrors and it brought it right up. I did notice however that it listed it as "Mirrors: Unrated". So I open up Ant, searched again, this time typing in "Mirrors: Unrated", and it brought it right up. It would appear that being specific would be a good rule of thumb.
Again, if I might be able to assit you on any tech/pc/software issues, PM me.
Thanks
You should limit the number of search results, as that would speed up the script execution by far for titles with too many results, while it does not affect titles with less results. This could be done on linedeadeye wrote:Some titles will cause the script to behave badly.
Example - search for the movie "It" and DVD Empire will return over 29,000 results. However if you tell it to search for "It Stephen King", it will return a little over 100 results, much easier to handle.
Code: Select all
AnalyzePage('http://www.dvdempire.com/Exec/v5_search_item.asp?string='+URLEncode(MovieName)+'&pp=5');
Also, the script does a keyword search (looking for the search term in the entire page) rather than just in the title. I have been testing it with the title search here and it seems to work well.
I think in combination with your suggestion it would be a much better script.
The line would look like this:
Thanks.
I think in combination with your suggestion it would be a much better script.
The line would look like this:
Code: Select all
AnalyzePage('http://www.dvdempire.com/Exec/v5_search_item.asp?string='+URLEncode(MovieName)+'&pp=3&search_refined=32');
Okay, I've updated the script to version 2.0.7 with the following changes:
* Tweaked search to give better results
- search titles only
- limit to 50 results
* Added Blu-ray search (change MediaType script option)
* Added large/small picture option (change PictureType script option)
* Put MPAA rating (PG, PG-13, R) in Comments field
Get it here:
http://rapidshare.com/files/202600812/dvdempire.ifs
* Tweaked search to give better results
- search titles only
- limit to 50 results
* Added Blu-ray search (change MediaType script option)
* Added large/small picture option (change PictureType script option)
* Put MPAA rating (PG, PG-13, R) in Comments field
Get it here:
http://rapidshare.com/files/202600812/dvdempire.ifs