Page 1 of 1

How to display titles without the ", The" ",

Posted: 2003-06-15 04:17:20
by Mguel
I've been trying to make a script to set the title without the ", the" ", A", etc... at the end (Insted of "Matrix, The" to have it automatically set to "The Matrix") but I haven't been able. It's not a surprice though, since I don't know delphi.

I have tried to 'play' with a function called: TransformIMDBTitle used by Curna on the script displayed on this topic.

Any help would be apreciated ;)

Thanks,
Mguel

Posted: 2003-06-15 08:31:17
by antp
You can use Pos function to see if a ", The" is found, and then do something like s := 'The ' + Copy(s, 1, Length(s) - 5);

Posted: 2003-06-15 14:10:53
by Mguel
Thanks, I'll try... and post my results if I succed ;)

Posted: 2003-06-16 00:32:40
by Mguel
OK, I maneged to make it work (I was seriously doubting I could, but I did :D ).

One problem before posting the 'code' for other who want this:
(Edited: I solved the problem so it's not necesary to continue reading, and simply jump to the next post)

How can I define a ' (single quote) on the text to replace.
ie for replacing the >L'< from: >Auberge espagnole, L'<, since I can't put:

Code: Select all

if pos(', L'', Value) > 0 then.... 
or

Code: Select all

s := 'L' ' + Copy(...... 
Thanks.

Posted: 2003-06-16 00:50:09
by Mguel
Ok here is the code I made to get the 'fixed subtitle':

(Before you look at the code remember that I don't know Delphi, so if I made some terrible mistake, or didn't follow the standards please tell me so I can fix it. Also if there is a way to make this shorter, please let me know. Thanks)

Code: Select all

procedure AnalyzeMoviePage(Page: TStringList);
var
  Line, Value, Value2, FullValue, fixtit: string;
  LineNr, nActors, Desc, i: Integer;
  BeginPos, EndPos: Integer;
  Descriptions: TStringList;
begin

  // Original Title & Year
  LineNr := FindLine('<title>', Page, 0);
  Line := Page.GetString(LineNr);
  if LineNr > -1 then
  begin
    BeginPos := pos('<title>', Line);
    if BeginPos > 0 then
      BeginPos := BeginPos + 7;
    EndPos := pos('(', Line);
    if EndPos = 0 then
      EndPos := Length(Line);
    Value := copy(Line, BeginPos, EndPos - BeginPos - 1);
    HTMLDecode(Value);
    //following "if"s are to have the "fixed title", i.e.: to have "The Matrix" instead of "Matrix, The".
    if pos(', The', Value) > 0 then
	begin
    		fixtit := 'The ' + Copy(Value, 1, Length(Value) - 5);
    		SetField(fieldOriginalTitle, fixtit);
  		end else
    if pos(', A', Value) > 0 then
	begin
    		fixtit := 'A ' + Copy(Value, 1, Length(Value) - 3);
    		SetField(fieldOriginalTitle, fixtit);
  		end else
    if pos(', An', Value) > 0 then
	begin
    		fixtit := 'An ' + Copy(Value, 1, Length(Value) - 4);
    		SetField(fieldOriginalTitle, fixtit);
  		end else
    if pos(', As', Value) > 0 then
	begin
    		fixtit := 'As ' + Copy(Value, 1, Length(Value) - 4);
    		SetField(fieldOriginalTitle, fixtit);
  		end else
    if pos(', Ellos', Value) > 0 then
	begin
    		fixtit := 'Ellos ' + Copy(Value, 1, Length(Value) - 7);
    		SetField(fieldOriginalTitle, fixtit);
  		end else
    if pos(', Ellas', Value) > 0 then
	begin
    		fixtit := 'Ellas ' + Copy(Value, 1, Length(Value) - 7);
    		SetField(fieldOriginalTitle, fixtit);
  		end else
    if pos(', El', Value) > 0 then
	begin
    		fixtit := 'El ' + Copy(Value, 1, Length(Value) - 4);
    		SetField(fieldOriginalTitle, fixtit);
  		end else
    if pos(', Los', Value) > 0 then
	begin
    		fixtit := 'Los ' + Copy(Value, 1, Length(Value) - 5);
    		SetField(fieldOriginalTitle, fixtit);
  		end else
    if pos(', Las', Value) > 0 then
	begin
    		fixtit := 'Las ' + Copy(Value, 1, Length(Value) - 5);
    		SetField(fieldOriginalTitle, fixtit);
  		end else
    if pos(', La', Value) > 0 then
	begin
    		fixtit := 'La ' + Copy(Value, 1, Length(Value) - 4);
    		SetField(fieldOriginalTitle, fixtit);
  		end else
    if pos(', Lo', Value) > 0 then
	begin
    		fixtit := 'Lo ' + Copy(Value, 1, Length(Value) - 4);
    		SetField(fieldOriginalTitle, fixtit);
  		end else
    if pos(', Unos', Value) > 0 then
	begin
    		fixtit := 'Unos ' + Copy(Value, 1, Length(Value) - 6);
    		SetField(fieldOriginalTitle, fixtit);
  		end else
    if pos(', Unas', Value) > 0 then
	begin
    		fixtit := 'Unas ' + Copy(Value, 1, Length(Value) - 6);
    		SetField(fieldOriginalTitle, fixtit);
  		end else
    if pos(', Uno', Value) > 0 then
	begin
    		fixtit := 'Uno ' + Copy(Value, 1, Length(Value) - 5);
    		SetField(fieldOriginalTitle, fixtit);
  		end else
    if pos(', Una', Value) > 0 then
	begin
    		fixtit := 'Una ' + Copy(Value, 1, Length(Value) - 5);
    		SetField(fieldOriginalTitle, fixtit);
  		end else
    if pos(', Un', Value) > 0 then
	begin
    		fixtit := 'Un ' + Copy(Value, 1, Length(Value) - 4);
    		SetField(fieldOriginalTitle, fixtit);
  		end else
    if pos(', Les', Value) > 0 then
	begin
    		fixtit := 'Les ' + Copy(Value, 1, Length(Value) - 5);
    		SetField(fieldOriginalTitle, fixtit);
  		end else
    if pos(', Le', Value) > 0 then
	begin
    		fixtit := 'Le ' + Copy(Value, 1, Length(Value) - 4);
    		SetField(fieldOriginalTitle, fixtit);
  		end else
    if pos(', L''', Value) > 0 then
	begin
    		fixtit := 'L''' + Copy(Value, 1, Length(Value) - 4);
    		SetField(fieldOriginalTitle, fixtit);
  		end else
    if pos(', Os', Value) > 0 then
	begin
    		fixtit := 'Os ' + Copy(Value, 1, Length(Value) - 4);
    		SetField(fieldOriginalTitle, fixtit);
  		end else
    if pos(', O', Value) > 0 then
	begin
    		fixtit := 'O ' + Copy(Value, 1, Length(Value) - 3);
    		SetField(fieldOriginalTitle, fixtit);
  		end else
    if pos(', Il', Value) > 0 then
	begin
    		fixtit := 'Il ' + Copy(Value, 1, Length(Value) - 4);
    		SetField(fieldOriginalTitle, fixtit);
  		end else
    if pos(', I', Value) > 0 then
	begin
    		fixtit := 'I ' + Copy(Value, 1, Length(Value) - 3);
    		SetField(fieldOriginalTitle, fixtit);
  		end else
    if pos(', Des', Value) > 0 then
	begin
    		fixtit := 'Des ' + Copy(Value, 1, Length(Value) - 5);
    		SetField(fieldOriginalTitle, fixtit);
  		end else
    if pos(', Der', Value) > 0 then
	begin
    		fixtit := 'Der ' + Copy(Value, 1, Length(Value) - 5);
    		SetField(fieldOriginalTitle, fixtit);
  		end else
    if pos(', Das', Value) > 0 then
	begin
    		fixtit := 'Das ' + Copy(Value, 1, Length(Value) - 5);
    		SetField(fieldOriginalTitle, fixtit);
  		end else
    if pos(', Die', Value) > 0 then
	begin
    		fixtit := 'Die ' + Copy(Value, 1, Length(Value) - 5);
    		SetField(fieldOriginalTitle, fixtit);
  		end else
    if pos(', Den', Value) > 0 then
	begin
    		fixtit := 'Den ' + Copy(Value, 1, Length(Value) - 5);
    		SetField(fieldOriginalTitle, fixtit);
  		end else
    if pos(', Dem', Value) > 0 then
	begin
    		fixtit := 'Dem ' + Copy(Value, 1, Length(Value) - 5);
    		SetField(fieldOriginalTitle, fixtit);
  		end else
    if pos(', Einen', Value) > 0 then
	begin
    		fixtit := 'Einen ' + Copy(Value, 1, Length(Value) - 7);
    		SetField(fieldOriginalTitle, fixtit);
  		end else
    if pos(', Einem', Value) > 0 then
	begin
    		fixtit := 'Einem ' + Copy(Value, 1, Length(Value) - 7);
    		SetField(fieldOriginalTitle, fixtit);
  		end else
    if pos(', Einer', Value) > 0 then
	begin
    		fixtit := 'Einer ' + Copy(Value, 1, Length(Value) - 7);
    		SetField(fieldOriginalTitle, fixtit);
  		end else
    if pos(', Eines', Value) > 0 then
	begin
    		fixtit := 'Eines ' + Copy(Value, 1, Length(Value) - 7);
    		SetField(fieldOriginalTitle, fixtit);
  		end else
    if pos(', Eine', Value) > 0 then
	begin
    		fixtit := 'Eine ' + Copy(Value, 1, Length(Value) - 6);
    		SetField(fieldOriginalTitle, fixtit);
  		end else
    if pos(', Ein', Value) > 0 then
	begin
    		fixtit := 'Ein ' + Copy(Value, 1, Length(Value) - 5);
    		SetField(fieldOriginalTitle, fixtit);
  		end else
    if pos(', Gli', Value) > 0 then
	begin
    		fixtit := 'Gli ' + Copy(Value, 1, Length(Value) - 5);
    		SetField(fieldOriginalTitle, fixtit);
  		end else
    SetField(fieldOriginalTitle, Value);
    BeginPos := pos('(', Line) + 1;
    if BeginPos > 0 then
    begin
      EndPos := pos(')', Line);
      Value := copy(Line, BeginPos, EndPos - BeginPos);
      SetField(fieldYear, Value);
    end;
  end;
I took the words from the "Articles" used by Curna on the TransformIMDBTitle function he used, to have the most complete and universal list as possible. If there is someone wrong, or there are other words that imdb puts at the end, please let me know.

Best regards,
Mguel

Edited: Fixed the extraspace in: fixtit := 'L'' ' + Copy(Value, 1, Length(Value) - 4);

Posted: 2003-06-16 08:19:13
by antp
You put a space after L' but usually there is none there ;)
in fixtit := 'L'' ' + Copy(Value, 1, Length(Value) - 4);
except that, I guess it is ok... it would be easier to use arrays to manage that but I am not sure that current version of script engine supports them. I'll upgrade this engine for version 4 of AMC.

Posted: 2003-06-17 01:08:53
by Mguel
antp wrote:You put a space after L' but usually there is none there ;)
in fixtit := 'L'' ' + Copy(Value, 1, Length(Value) - 4);
OK, thanks ;)