[REL][SE] discshop.se

If you made a script you can offer it to the others here, or ask help to improve it. You can also report here bugs & problems with existing scripts.
a_dent
Posts: 2
Joined: 2006-01-08 14:45:57
Location: Ronneby, Sweden

[REL][SE] discshop.se

Post by a_dent »

This is my first attempt to write a script for amc. This script fetches movie information from the Swedish reseller Discshop. It gets most information including the pictures. There are some customization options available under Script options. The script is based on the IMDB-script v.2.04.

The script uses the latest StringUtils1.pas (v.3) from
http://www.antp.be/temp/scripts/StringUtils1.pas

I'm hereby releasing version 0.9 (without any guarantees). Please give me comments.

http://www.fridvall.se/amc/discshop.se.ifs

Code: Select all

(***************************************************

Ant Movie Catalog importation script
www.antp.be/software/moviecatalog/

[Infos]
Authors=Andreas Fridvall
Title=Discshop
Description=Import data & picture from www.discshop.se in swedish
Site=www.discshop.se
Language=SE
Version=0.9
Requires=3.5.0
Comments=Based on the IMDB-script (v.2.04) made by Antoine Potten, KaraGarga
License=This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
GetInfo=1

[Options]
BatchMode=0|0|0=Normal working mode, prompts user when needed|1=Does not display any window, takes the first movie found
MultipleValuesActors=3|3|0=Only take first value for Actors|1=Take full list, separated by commas|2=Take full list, separated by slashes|3=Take full list, separated by linebreaks
MultipleValuesCountry=1|1|0=Only take first value for Country|1=Take full list, separated by commas|2=Take full list, separated by slashes
MultipleValuesCategory=1|1|0=Only take first value for Category|1=Take full list, separated by commas|2=Take full list, separated by slashes
MultipleValuesLanguages=1|1|0=Only take first value for Languages|1=Take full list, separated by commas|2=Take full list, separated by slashes

***************************************************)

program Discshop;

uses
  StringUtils1;

var
  MovieName: string;
  MovieURL: string;
  MovieNumber: string;

// ***** analyzes the results page that asks to select a movie from a list *****

procedure AnalyzeResultsPage(Address: string);
var
  PageText: string;
  Value: string;
begin
  PageText := GetPage(Address);
  if (Pos('<TITLE>Discshop.se</TITLE>', PageText) = 0) then
  begin
    AnalyzeMoviePage(PageText)
  end else
  begin
    if Pos('Hittade inga produkter som matchade din sökning</div>', PageText) > 0 then
    begin
      if GetOption('BatchMode') = 0 then
        ShowMessage('No movie found for this search');
      Exit;
    end;
    if GetOption('BatchMode') = 0 then
    begin
      PickTreeClear;
      Value := TextBetween(PageText, '<td><span class="GREY"><b>', '</b>');
      if Value <> '' then
      begin
        HTMLRemoveTags(Value);
        HTMLDecode(Value);
        PickTreeAdd(Value, '');
      end;

      Value := TextBetween(PageText, '<table border="0" cellpadding="0" cellspacing="0" width="570" class="PRODUCTSTABLE">', '<!-- END: Innehåll... //-->');
      AddMovieTitles(Value);
      if PickTreeExec(Address) then
        AnalyzeResultsPage(Address);
    end
    else
    begin
      // batch mode, pick the first available movie
      Value := TextBetween(PageText, '<table border="0" cellpadding="0" cellspacing="0" width="570" class="PRODUCTSTABLE">', '<!-- END: Innehåll... //-->');
      if Value <> '' then
        AnalyzeResultsPage('http://www.discshop.se/shop/ds_produkt.php?subsite=movies&id=' + TextBetween(Value, '<a class=''PRODUCTLINK'' href="ds.php?red=ds_produkt.php&&arg=id@@@', ',,,'))
      else
      begin
        ShowMessage('No movie found for this search');
        Exit;
      end;
    end;
  end;
end;

// ***** adds the titles contained in the table *****

function AddMovieTitles(List: string): Boolean;
var
  Value: string;
  Address: string;
begin
  Result := False;
  Value := TextBetween(List, '<tr height=''50'' valign=''top''>', '<tr bgcolor=''#DDDDDD'' height=''1''>');
  List := RemainingText;
  while Value <> '' do
  begin
    Address := TextBetween(Value, '<a class=''PRODUCTLINK'' href="ds.php?red=ds_produkt.php&&arg=id@@@', ',,,');
    Value := TextBetween(Value, '@@@movies,,,"><b>', '</b>');
    HTMLRemoveTags(Value);
    HTMLDecode(Value);
    PickTreeAdd(Value, 'http://www.discshop.se/shop/ds_produkt.php?subsite=movies&id=' + Address);
    Result := True;
    Value := TextBetween(List, '<tr height=''50'' valign=''top''>', '<tr bgcolor=''#DDDDDD'' height=''1''>');
    List := RemainingText;
  end;
end;

// ***** analyzes the page containing movie information *****

procedure AnalyzeMoviePage(PageText: string);
var
  Value, Value2, Value3: string;
  p: Integer;
  rating : Real;
begin
  MovieNumber := TextBetween(PageText, 'ds.php?red=ds_produkt.php&&arg=id@@@', ',,,');
  MovieURL := 'http://www.discshop.se/shop/ds_produkt.php?subsite=movies&id=' + MovieNumber;
  // URL
  if CanSetField(fieldURL) then
    SetField(fieldURL, MovieURL);
  // Translated Title
  if CanSetField(fieldTranslatedTitle) then
  begin
    Value := TextBetween(PageText, '<TITLE>', '</TITLE>');
    Value := TextAfter(Value, ' - ');
    HTMLDecode(Value);
    SetField(fieldTranslatedTitle, Value);
  end;

  // Original Title
  if CanSetField(fieldOriginalTitle) then
  begin
    Value := TextBetween(PageText, 'Originaltitel:', '</TR>');
    Value := TextBetween(Value, '<TD>', '</TD>');
    HTMLDecode(Value);
    SetField(fieldOriginalTitle, Value);
  end;

  // Year
  if CanSetField(fieldYear) then
  begin
    Value := TextBetween(PageText, 'Premiärår:', '</TR>');
    Value := TextBetween(Value, '<TD>', '</TD>');
    HTMLDecode(Value);
    SetField(fieldYear, Value);
  end;

  // Length
  if CanSetField(fieldLength) then
  begin
    Value := TextBetween(PageText, 'Speltid:', '</TR>');
    Value := TextBetween(Value, '<TD>', ' min</TD>');
    HTMLDecode(Value);
    SetField(fieldLength, Value);
  end;

  // Director
  if CanSetField(fieldDirector) then
  begin
    Value := TextBetween(PageText, 'Regi:', '</TR>');
    Value := TextBetween(Value, '<TD>', '</TD>');
    Value := StringReplace(Value, '<BR>', ', ');
    Value := StringReplace(Value, #13#10, '');
    Value := StringReplace(Value, #09,'');
    HTMLRemoveTags(Value);
    HTMLDecode(Value);
    SetField(fieldDirector, Value);
  end;

  // Writer (Producer Field)
  if CanSetField(fieldProducer) then
  begin
    Value := TextBetween(PageText, 'Manus:', '</TR>');
    Value := TextBetween(Value, '<TD>', '</TD>');
    Value := StringReplace(Value, '<BR>', ', ');
    Value := StringReplace(Value, #13#10, '');
    Value := StringReplace(Value, #09,'');
    HTMLRemoveTags(Value);
    HTMLDecode(Value);
    SetField(fieldProducer, Value);
  end;

  // Picture
  if CanSetPicture then
  begin
    Value := TextBetween(PageText, '<IMG SRC="http://www.discshop.se/shop/img/omslag/front_normal/','"');
    if Value <> '' then
      Value := 'http://www.discshop.se/shop/img/omslag/front_large/' + Value;
      GetPicture(Value);
  end;

  // Country
  if CanSetField(fieldCountry) then
    SetField(fieldCountry, ImportList(PageText, GetOption('MultipleValuesCountry'), 'Produktionsland:'));

  // Category
  if CanSetField(fieldCategory) then
    SetField(fieldCategory, ImportList(PageText, GetOption('MultipleValuesCategory'), 'Genre:'));

  // Language
  if CanSetField(fieldLanguages) then
  begin
    Value := TextBetween(PageText, 'Ljud:', '</TR>');
    Value := TextBetween(Value, '<DIV ID="specifikationer_sprak_alla" STYLE="display:none;">', '</DIV>');
    Value := Copy(Value,1,LastPos('<BR>',Value)-1);

    Value := StringReplace(Value, #13#10,'');
    Value := StringReplace(Value, #09,'');
    Value := StringReplace(Value, ' ','');
    case GetOption('MultipleValuesLanguages') of
      0: if Pos('<BR>',Value)>0 then Value := TextBefore(Value, '<BR>', '');
      1: Value := StringReplace(Value, '<BR>', ', ');
      2: Value := StringReplace(Value, '<BR>', ' / ');
      3: Value := StringReplace(Value, '<BR>', #13#10);
    end;
    HTMLRemoveTags(Value);
    HTMLDecode(Value);
    SetField(fieldLanguages, Value);
  end;

  // Subtitles
  if CanSetField(fieldSubtitles) then
  begin
    Value := TextBetween(PageText, '<DIV ID="specifikationer_text" STYLE="display:none;">', '</DIV>');
    Value := StringReplace(Value, #13#10,'');
    Value := StringReplace(Value, #09,'');
    Value := StringReplace(Value, ' ', '');

    Value2 := TextBetween(Value, '<TD>','</TD>');
    // discshop uses two diffrent layouts for subtitle listnings
    if Value2='' then
    begin
      Value3 := Copy(Value,1,LastPos('<br>',Value)-1);  // remove the last <br>
      Value3 := StringReplace(Value3, '<br>', ', ');
    end
    else
    begin
      Value := RemainingText;
      Value3 := '';
      while Value2 <> '' do
      begin
        if Value3='' then
          Value3 := Value2
        else
          Value3 := Value3 + ', ' + Value2;
        Value2 := TextBetween(Value, '<TD>','</TD>');
        Value := RemainingText;
      end;
    end;
    HTMLRemoveTags(Value3);
    HTMLDecode(Value3);
    SetField(fieldSubtitles, Value3);
  end;

  // Actors
  if CanSetField(fieldActors) then
    SetField(fieldActors, ImportList(PageText, GetOption('MultipleValuesActors'), 'Skådespelare:'));

  // Description
  if CanSetField(fieldDescription) then
  begin
    Value := TextBetween(PageText, 'Filmens handling:', '<BR>');
    if Value = '' then Value := TextBetween(PageText, 'Beskrivning:', '<BR>');
    Value := TextAfter(Value, '<br>');
    Value := StringReplace(Value, '<FONT COLOR="white">i</FONT>', ' ');
    Value := StringReplace(Value, #13#10,'');
    Value := StringReplace(Value, #09,'');
    Value := StringReplace(Value, '<br>', #13#10);
    HTMLRemoveTags(Value);
    HTMLDecode(Value);
    SetField(fieldDescription, Value);
  end;

end;

// ***** Imports lists like Genre, Country, etc. depending of the selected option *****

function ImportList(PageText: string; MultipleValues: Integer; StartTag: string): string;
var
  Value: string;
begin
  Value := TextBetween(PageText, StartTag, '</TR>');
  Value := TextBetween(Value, '<TD>', '</TD>');
  Value := StringReplace(Value, #13#10,'');
  Value := StringReplace(Value, #09,'');
  Value := StringReplace(Value, ' <FONT COLOR="#6C6C6C">/</FONT> ','<BR>');   // separator for categories
  Value := StringReplace(Value, ' / ','<BR>');   // separator for some countries

  case MultipleValues of
  0: if Pos('<BR>',Value)>0 then Value := TextBefore(Value, '<BR>', '');
  1: Value := StringReplace(Value, '<BR>', ', ');
  2: Value := StringReplace(Value, '<BR>', ' / ');
  3: Value := StringReplace(Value, '<BR>', #13#10);
  end;
  HTMLRemoveTags(Value);
  HTMLDecode(Value);
  Result := Value;
end;

// ***** beginning of the program *****

begin
  if CheckVersion(3,5,0) then
  begin
    MovieName := '';

    if GetOption('BatchMode') = 2 then
    begin
      MovieName := GetField(fieldURL);
      if Pos('discshop.se', MovieName) = 0 then
        MovieName := '';
    end;

    if MovieName = '' then
      MovieName := GetField(fieldOriginalTitle);
    if MovieName = '' then
      MovieName := GetField(fieldTranslatedTitle);

    if GetOption('BatchMode') = 0 then
    begin
      if not Input('Discshop.se import', 'Enter the title of the movie:', MovieName) then
        Exit;
    end
    else
      Sleep(500);
    if MovieName <> '' then
    begin
      if Pos('discshop.se', MovieName) > 0 then
        AnalyzeResultsPage(MovieName)
      else
      begin
        MovieName := StringReplace(MovieName, '&', 'and');
        AnalyzeResultsPage('http://www.discshop.se/shop/search_result.php?subsite=movies&__search=1&showImages=1&nosearch_page=1&sok_typ=titel&_q=' + UrlEncode(MovieName))
      end;
    end;
  end
  else
    ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)');
end.
antp
Site Admin
Posts: 9629
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Thanks ;)
kinetix
Posts: 32
Joined: 2003-02-23 08:03:44
Location: Sweden

Post by kinetix »

DUKTIGT!!!

Fin lösning med att ta bort de "osynliga" vita i:na ;)

Jag har inte testat scriptet fullt ut, men jag har inte haft några problem hittills iaf...

:grinking:
Noe
Posts: 3
Joined: 2006-01-10 15:29:55
Location: Sweden

Post by Noe »

Great

I've really been waiting for this script!
I't seems to work perfectly the short amount of time I've tested it.

Good job and thank you!

-----------

Som jag har väntat på detta scriptet.
Det verkar funka perfekt det lilla jag sett hittills.

Tack så jättemycket!
Bra jobbat!

:) :grinking:
Noe
Posts: 3
Joined: 2006-01-10 15:29:55
Location: Sweden

Post by Noe »

Är det medvetet att scriptet aldrig kan hitta musikdvd:er på Discshop?

Jag har jämfört med dvd:er som finns på sidan men scriptet kan inte hitta dom trots att jag har sett till att allt är rättstavat.

Om det är medvetet utelämnat, kan man önska att det kommer i en ev. senare version?

För övrigt har jag inte hittat några fel på det :)
a_dent
Posts: 2
Joined: 2006-01-08 14:45:57
Location: Ronneby, Sweden

Post by a_dent »

I'm aware of the fact that this script doesn't include music dvds. But I think it's a good suggestion and I will probably include it in the next release.

I'm glad that you find the script useful!
sweborn
Posts: 12
Joined: 2007-10-17 23:16:52

Post by sweborn »

I have modify the script in description section. I took away everything in bold style in this example:

****Uppdraget de två blir tilldelade handlar i stort om att granska... Informationen hämtad från discshop.se! Beställ före 16.00. Leverans nästa dag. Filmen är full av underbara scener... disableSelection(document.getElementById("text_handling"));

Code: Select all

// Description
  if CanSetField(fieldDescription) then
  begin
    Value := TextBetween(PageText,'Filmens handling:', '<BR>');
    if Value = '' then Value := TextBetween(PageText, 'Beskrivning:', '<BR>');
    Value := TextAfter(Value, '<br>');
    Value := StringReplace(Value, '    ', '');
    Value := StringReplace(Value, 'disableSelection(document.getElementById("text_handling"));', '');
    Value := StringReplace(Value, TextBetween(Value, '<span style="display: none;">', '</span>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<span style=" display: none;">', '</span>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<span style=" display: none">', '</span>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<span style="display: none">', '</span>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<i style="display: none;">', '</i>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<i style=" display: none;">', '</i>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<i style=" display: none">', '</i>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<i style="display: none">', '</i>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<b style="display: none;">', '</b>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<b style=" display: none;">', '</b>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<b style=" display: none">', '</b>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<b style="display: none">', '</b>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<span style="display:none;">', '</span>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<span style=" display:none;">', '</span>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<span style=" display:none">', '</span>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<span style="display:none">', '</span>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<i style="display:none;">', '</i>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<i style=" display:none;">', '</i>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<i style=" display:none">', '</i>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<i style="display:none">', '</i>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<b style="display:none;">', '</b>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<b style=" display:none;">', '</b>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<b style=" display:none">', '</b>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<b style="display:none">', '</b>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<span class="infoText1234">', '</span>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<i class="infoText1234">', '</i>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<b class="infoText1234">', '</b>'),'');
    Value := StringReplace(Value, '<FONT COLOR="white">i</FONT>', ' ');
    Value := StringReplace(Value, #13#10,'');
    Value := StringReplace(Value, #09,'');
    Value := StringReplace(Value, '<br>', #13#10);
    HTMLRemoveTags(Value);
    HTMLDecode(Value);
    SetField(fieldDescription, Value);
  end;

u28151
Posts: 6
Joined: 2007-10-02 18:36:44

Sounds great!

Post by u28151 »

Will you post your modified script for download?

brgds

U
sweborn
Posts: 12
Joined: 2007-10-17 23:16:52

Post by sweborn »

Shore... here is the modified script. Unfortunately i cant upload the scriptfile so here is the hole code.
Change from the original script:
*Deleted som annoying text in Description
*User comments
*Rating

Code: Select all

(***************************************************

Ant Movie Catalog importation script
www.antp.be/software/moviecatalog/

[Infos]
Authors=Andreas Fridvall
Title=Discshop
Description=Import data & picture from www.discshop.se in swedish
Site=www.discshop.se
Language=SE
Version=0.9
Requires=3.5.0
Comments=Based on the IMDB-script (v.2.04) made by Antoine Potten, KaraGarga
License=This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
GetInfo=1

[Options]
BatchMode=0|0|0=Normal working mode, prompts user when needed|1=Does not display any window, takes the first movie found
MultipleValuesActors=3|3|0=Only take first value for Actors|1=Take full list, separated by commas|2=Take full list, separated by slashes|3=Take full list, separated by linebreaks
MultipleValuesCountry=1|1|0=Only take first value for Country|1=Take full list, separated by commas|2=Take full list, separated by slashes
MultipleValuesCategory=1|1|0=Only take first value for Category|1=Take full list, separated by commas|2=Take full list, separated by slashes
MultipleValuesLanguages=1|1|0=Only take first value for Languages|1=Take full list, separated by commas|2=Take full list, separated by slashes

***************************************************)

program Discshop;

uses
  StringUtils1;

var
  MovieName: string;
  MovieURL: string;
  MovieNumber: string;

// ***** analyzes the results page that asks to select a movie from a list *****

procedure AnalyzeResultsPage(Address: string);
var
  PageText: string;
  Value: string;
begin
  PageText := GetPage(Address);
  if (Pos('<TITLE>Discshop.se</TITLE>', PageText) = 0) then
  begin
    AnalyzeMoviePage(PageText)
  end else
  begin
    if Pos('Hittade inga produkter som matchade din sökning</div>', PageText) > 0 then
    begin
      if GetOption('BatchMode') = 0 then
        ShowMessage('No movie found for this search');
      Exit;
    end;
    if GetOption('BatchMode') = 0 then
    begin
      PickTreeClear;
      Value := TextBetween(PageText, '<td><span class="GREY"><b>', '</b>');
      if Value <> '' then
      begin
        HTMLRemoveTags(Value);
        HTMLDecode(Value);
        PickTreeAdd(Value, '');
      end;

      Value := TextBetween(PageText, '<table border="0" cellpadding="0" cellspacing="0" width="570" class="PRODUCTSTABLE">', '<!-- END: Innehåll... //-->');
      AddMovieTitles(Value);
      if PickTreeExec(Address) then
        AnalyzeResultsPage(Address);
    end
    else
    begin
      // batch mode, pick the first available movie
      Value := TextBetween(PageText, '<table border="0" cellpadding="0" cellspacing="0" width="570" class="PRODUCTSTABLE">', '<!-- END: Innehåll... //-->');
      if Value <> '' then
        AnalyzeResultsPage('http://www.discshop.se/shop/ds_produkt.php?subsite=movies&id=' + TextBetween(Value, '<a class=''PRODUCTLINK'' href="ds.php?red=ds_produkt.php&&arg=id@@@', ',,,'))
      else
      begin
        ShowMessage('No movie found for this search');
        Exit;
      end;
    end;
  end;
end;

// ***** adds the titles contained in the table *****

function AddMovieTitles(List: string): Boolean;
var
  Value: string;
  Address: string;
begin
  Result := False;
  Value := TextBetween(List, '<tr height=''50'' valign=''top''>', '<tr bgcolor=''#DDDDDD'' height=''1''>');
  List := RemainingText;
  while Value <> '' do
  begin
    Address := TextBetween(Value, '<a class=''PRODUCTLINK'' href="ds.php?red=ds_produkt.php&&arg=id@@@', ',,,');
    Value := TextBetween(Value, '@@@movies,,,"><b>', '</b>');
    HTMLRemoveTags(Value);
    HTMLDecode(Value);
    PickTreeAdd(Value, 'http://www.discshop.se/shop/ds_produkt.php?subsite=movies&id=' + Address);
    Result := True;
    Value := TextBetween(List, '<tr height=''50'' valign=''top''>', '<tr bgcolor=''#DDDDDD'' height=''1''>');
    List := RemainingText;
  end;
end;

// ***** analyzes the page containing movie information *****

procedure AnalyzeMoviePage(PageText: string);
var
  Value, Value2, Value3: string;
  p: Integer;
  rating : Real;
begin
  MovieNumber := TextBetween(PageText, 'ds.php?red=ds_produkt.php&&arg=id@@@', ',,,');
  MovieURL := 'http://www.discshop.se/shop/ds_produkt.php?subsite=movies&id=' + MovieNumber;
  
  // URL
  

  if CanSetField(fieldURL) then
    SetField(fieldURL, MovieURL);


  // Translated Title
  if CanSetField(fieldTranslatedTitle) then
  begin
    Value := TextBetween(PageText, '<TITLE>', '</TITLE>');
    Value := TextAfter(Value, ' - ');
    HTMLDecode(Value);
    SetField(fieldTranslatedTitle, Value);
  end;

  // Original Title
  if CanSetField(fieldOriginalTitle) then
  begin
    Value := TextBetween(PageText, 'Originaltitel:', '</TR>');
    Value := TextBetween(Value, '<TD>', '</TD>');
    HTMLDecode(Value);
    SetField(fieldOriginalTitle, Value);
  end;

  // Year
  if CanSetField(fieldYear) then
  begin
    Value := TextBetween(PageText, 'Premiärår:', '</TR>');
    Value := TextBetween(Value, '<TD>', '</TD>');
    HTMLDecode(Value);
    SetField(fieldYear, Value);
  end;

  // Length
  if CanSetField(fieldLength) then
  begin
    Value := TextBetween(PageText, 'Speltid:', '</TR>');
    Value := TextBetween(Value, '<TD>', ' min</TD>');
    HTMLDecode(Value);
    SetField(fieldLength, Value);
  end;

  // Director
  if CanSetField(fieldDirector) then
  begin
    Value := TextBetween(PageText, 'Regi:', '</TR>');
    Value := TextBetween(Value, '<TD>', '</TD>');
    Value := StringReplace(Value, '<BR>', ', ');
    Value := StringReplace(Value, #13#10, '');
    Value := StringReplace(Value, #09,'');
    HTMLRemoveTags(Value);
    HTMLDecode(Value);
    SetField(fieldDirector, Value);
  end;

  
  
  // Rating
  if CanSetField(fieldRating) then
  begin
    Value := TextBetween(PageText, 'Kundbetyg:', '<br>');
    Value := TextBetween(Value , '<b>', '</b>');
    SetField(fieldRating, FloatToStr(StrToFloat(Value)*2));
  end;

  // Resolution
  if CanSetField(fieldResolution) then
  begin
    Value := TextBetween(PageText, 'Bild:', '</TR>');
    Value := TextBetween(Value, '<TD>', '</TD>');
    Value := StringReplace(Value, #13#10, '');
    Value := StringReplace(Value, #09,'');
    Value := StringReplace(Value, '(anamorfisk)','');
    HTMLDecode(Value);
    SetField(fieldResolution, Value);
  end;

  // VideoFormat
  if CanSetField(fieldVideoFormat) then
  begin
    Value := TextBetween(PageText, 'Format:', '</TR>');
    Value := TextBetween(Value, '<TD>', '</TD>');
    Value := StringReplace(Value, #13#10, '');
    Value := StringReplace(Value, #09,'');
    HTMLDecode(Value);
    SetField(fieldVideoFormat, Value);
  end;

// MediaType
  if CanSetField(fieldMediaType) then
  begin
    Value := TextBetween(PageText, 'Kartong:', '</TR>');
    Value := TextBetween(Value, '<TD>', '</TD>');
    HTMLDecode(Value);
    SetField(fieldMediaType, Value);
  end;

  // Writer (Producer Field)
  if CanSetField(fieldProducer) then
  begin
    Value := TextBetween(PageText, 'Manus:', '</TR>');
    Value := TextBetween(Value, '<TD>', '</TD>');
    Value := StringReplace(Value, '<BR>', ', ');
    Value := StringReplace(Value, #13#10, '');
    Value := StringReplace(Value, #09,'');
    HTMLRemoveTags(Value);
    HTMLDecode(Value);
    SetField(fieldProducer, Value);
  end;

  // Picture
  if CanSetPicture then
  begin
    Value := TextBetween(PageText, '<IMG SRC="http://www.discshop.se/shop/img/omslag/front_normal/','"');
    if Value <> '' then
      Value := 'http://www.discshop.se/shop/img/omslag/front_large/' + Value;
      GetPicture(Value);
  end;

  // Country
  if CanSetField(fieldCountry) then
    SetField(fieldCountry, ImportList(PageText, GetOption('MultipleValuesCountry'), 'Produktionsland:'));

  // Category
  if CanSetField(fieldCategory) then
    SetField(fieldCategory, ImportList(PageText, GetOption('MultipleValuesCategory'), 'Genre:'));

  // Language
  if CanSetField(fieldLanguages) then
  begin
    Value := TextBetween(PageText, 'Ljud:', '</TR>');
    Value := TextBetween(Value, '<DIV ID="specifikationer_sprak_alla" STYLE="display:none;">', '</DIV>');
    Value := Copy(Value,1,LastPos('<BR>',Value)-1);

    Value := StringReplace(Value, #13#10,'');
    Value := StringReplace(Value, #09,'');
    Value := StringReplace(Value, ' ','');
    case GetOption('MultipleValuesLanguages') of
      0: if Pos('<BR>',Value)>0 then Value := TextBefore(Value, '<BR>', '');
      1: Value := StringReplace(Value, '<BR>', ', ');
      2: Value := StringReplace(Value, '<BR>', ' / ');
      3: Value := StringReplace(Value, '<BR>', #13#10);
    end;
    HTMLRemoveTags(Value);
    HTMLDecode(Value);
    SetField(fieldLanguages, Value);
  end;

  // Subtitles
  if CanSetField(fieldSubtitles) then
  begin
    Value := TextBetween(PageText, '<DIV ID="specifikationer_text" STYLE="display:none;">', '</DIV>');
    Value := StringReplace(Value, #13#10,'');
    Value := StringReplace(Value, #09,'');
    Value := StringReplace(Value, ' ', '');

    Value2 := TextBetween(Value, '<TD>','</TD>');
    // discshop uses two diffrent layouts for subtitle listnings
    if Value2='' then
    begin
      Value3 := Copy(Value,1,LastPos('<br>',Value)-1);  // remove the last <br>
      Value3 := StringReplace(Value3, '<br>', ', ');
    end
    else
    begin
      Value := RemainingText;
      Value3 := '';
      while Value2 <> '' do
      begin
        if Value3='' then
          Value3 := Value2
        else
          Value3 := Value3 + ', ' + Value2;
        Value2 := TextBetween(Value, '<TD>','</TD>');
        Value := RemainingText;
      end;
    end;
    HTMLRemoveTags(Value3);
    HTMLDecode(Value3);
    SetField(fieldSubtitles, Value3);
  end;

  // Actors
  if CanSetField(fieldActors) then
    SetField(fieldActors, ImportList(PageText, GetOption('MultipleValuesActors'), 'Skådespelare:'));

  // Description
  if CanSetField(fieldDescription) then
  begin
    Value := TextBetween(PageText,'Filmens handling:', '<BR>');
    if Value = '' then Value := TextBetween(PageText, 'Beskrivning:', '<BR>');
    Value := TextAfter(Value, '<br>');
    Value := StringReplace(Value, '    ', '');
    Value := StringReplace(Value, 'disableSelection(document.getElementById("text_handling"));', '');
    Value := StringReplace(Value, TextBetween(Value, '<span style="display: none;">', '</span>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<span style=" display: none;">', '</span>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<span style=" display: none">', '</span>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<span style="display: none">', '</span>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<i style="display: none;">', '</i>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<i style=" display: none;">', '</i>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<i style=" display: none">', '</i>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<i style="display: none">', '</i>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<b style="display: none;">', '</b>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<b style=" display: none;">', '</b>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<b style=" display: none">', '</b>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<b style="display: none">', '</b>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<span style="display:none;">', '</span>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<span style=" display:none;">', '</span>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<span style=" display:none">', '</span>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<span style="display:none">', '</span>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<i style="display:none;">', '</i>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<i style=" display:none;">', '</i>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<i style=" display:none">', '</i>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<i style="display:none">', '</i>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<b style="display:none;">', '</b>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<b style=" display:none;">', '</b>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<b style=" display:none">', '</b>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<b style="display:none">', '</b>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<span class="infoText1234">', '</span>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<i class="infoText1234">', '</i>'),'');
    Value := StringReplace(Value, TextBetween(Value, '<b class="infoText1234">', '</b>'),'');
    Value := StringReplace(Value, '<FONT COLOR="white">i</FONT>', ' ');
    Value := StringReplace(Value, #13#10,'');
    Value := StringReplace(Value, #09,'');
    Value := StringReplace(Value, '<br>', #13#10);
    HTMLRemoveTags(Value);
    HTMLDecode(Value);
    SetField(fieldDescription, Value);
  end;


 if CanSetField(fieldComments) then

 begin
    Value3 := TextBetween(PageText, '<a href="javascript:toggleOmdome(1)">', '» Läs alla omdömen');
    Value3 := StringReplace(Value3, '			', '');
    Value3 := StringReplace(Value3, '<b> ', 'Betyg: ');
    Value3 := StringReplace(Value3, '</b></font>', '/5.0');
    Value3 := StringReplace(Value3, TextBetween(Value3, 'HSPACE=6 BORDER=0>', '</A>'),'');
    HTMLRemoveTags(Value3);
    HTMLDecode(Value3);
    SetField(fieldComments, Value3);
  end;
end;

// ***** Imports lists like Genre, Country, etc. depending of the selected option *****

function ImportList(PageText: string; MultipleValues: Integer; StartTag: string): string;
var
  Value: string;
begin
  Value := TextBetween(PageText, StartTag, '</TR>');
  Value := TextBetween(Value, '<TD>', '</TD>');
  Value := StringReplace(Value, #13#10,'');
  Value := StringReplace(Value, #09,'');
  Value := StringReplace(Value, ' <FONT COLOR="#6C6C6C">/</FONT> ','<BR>');   // separator for categories
  Value := StringReplace(Value, ' / ','<BR>');   // separator for some countries

  case MultipleValues of
  0: if Pos('<BR>',Value)>0 then Value := TextBefore(Value, '<BR>', '');
  1: Value := StringReplace(Value, '<BR>', ', ');
  2: Value := StringReplace(Value, '<BR>', ' / ');
  3: Value := StringReplace(Value, '<BR>', #13#10);
  end;
  HTMLRemoveTags(Value);
  HTMLDecode(Value);
  Result := Value;
end;

// ***** beginning of the program *****

begin
  if CheckVersion(3,5,0) then
  begin
    MovieName := '';

    if GetOption('BatchMode') = 2 then
    begin
      MovieName := GetField(fieldURL);
      if Pos('discshop.se', MovieName) = 0 then
        MovieName := '';
    end;

    if MovieName = '' then
      MovieName := GetField(fieldOriginalTitle);
    if MovieName = '' then
      MovieName := GetField(fieldTranslatedTitle);

    if GetOption('BatchMode') = 0 then
    begin
      if not Input('Discshop.se import', 'Enter the title of the movie:', MovieName) then
        Exit;
    end
    else
      Sleep(500);
    if MovieName <> '' then
    begin
      if Pos('discshop.se', MovieName) > 0 then
        AnalyzeResultsPage(MovieName)
      else
      begin
        MovieName := StringReplace(MovieName, '&', 'and');
        AnalyzeResultsPage('http://www.discshop.se/shop/search_result.php?subsite=movies&__search=1&showImages=1&nosearch_page=1&sok_typ=titel&_q=' + UrlEncode(MovieName))
      end;
    end;
  end
  else
    ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)');
end.
antp
Site Admin
Posts: 9629
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

Post by antp »

Thanks.
surfmike
Posts: 5
Joined: 2008-03-05 09:05:07

Post by surfmike »

Hi!

And thx for a great software and swedish film info grabber!!!

Though it seems that the "Description" doesn´t follow anymore.

I tried to understand/modify the code, but unfortunately I´m a lousy hacker... :/

Help me please...
bad4u
Posts: 1148
Joined: 2006-12-11 22:54:46

Post by bad4u »

Here's a new version of discshop.se script.

discshop.se 0.9.2: http://update.antp.be/amc/scripts/discshop.se.ifs

I fixed the description import, formatted the comments field slightly and added a new feature to the script:
You now can show all results pages instead of only 20 results. Simply hit the 'Find more' button on results list, to go to the next results page.
surfmike
Posts: 5
Joined: 2008-03-05 09:05:07

Post by surfmike »

I'm sorry to bother you in this matter, but I believe Discshop has done severe changes in how to present their movie information.

I've tried both the former script and the new one, but both ends up totally empty except the URL.
Noe
Posts: 3
Joined: 2006-01-10 15:29:55
Location: Sweden

Post by Noe »

surfmike wrote:I'm sorry to bother you in this matter, but I believe Discshop has done severe changes in how to present their movie information.

I've tried both the former script and the new one, but both ends up totally empty except the URL.
Exactly the same thing happens to me.
Discshop has rebuilt their site and I guess that's why we have problems with the script.

Please, can someone tallented try to get this script to work again?

Thank you!
bad4u
Posts: 1148
Joined: 2006-12-11 22:54:46

Post by bad4u »

Because of website changes the script can't be fixed with some minor code changes, it needs a complete workover.. nearly all import functions are broken.
I will release a fixed version the next days, if noone else does before.
surfmike
Posts: 5
Joined: 2008-03-05 09:05:07

Post by surfmike »

bad4u, as much as I am ashamed that I can't help you because of my no talent in this matter, the much I appreciate your effort!!!

Thx
bad4u
Posts: 1148
Joined: 2006-12-11 22:54:46

Post by bad4u »

discshop.se 1.0.0: http://www.bad4u.741.com/full/discshop.se.ifs (copy link into a NEW browser window !)

Complete overwork because of website changes. There still might be some things to do like an other formatting of the comments section, but I do not know previous layout, so someone else will have to do this later if he doesn't like it. Besides there will be no rating import on comments as they changed the rating system to 'stars' (as what I can see from the code, they used numbers for this before and imported single user ratings to comments field), nethertheless I added support for the stars on general rating import.

A comment on previous script version said that "discshop uses two different layouts for subtitle listings", so maybe there are films that still have problems, but I did not find such during my (short) tests. If you find bugs please do not forget to name the film.
corpes
Posts: 3
Joined: 2008-03-24 14:38:27

Post by corpes »

I've got this error message when I'm using the new scriptversion:

"Script error in "DISCSHOP": unknown identifier: FULLTRIM at line 419"
bad4u
Posts: 1148
Joined: 2006-12-11 22:54:46

Post by bad4u »

corpes wrote:I've got this error message when I'm using the new scriptversion:

"Script error in "DISCSHOP": unknown identifier: FULLTRIM at line 419"
Seems you have an outdated version of StringUtils1.pas, as the FullTrim function is part of this file (at least since StringUtils1 Version 4 from 2006) and the discshop.se script uses this unit.

Please download latest version of StringUtils1 from http://update.antp.be/amc/scripts/archi ... Utils1.pas and copy it to your scripts folder.
corpes
Posts: 3
Joined: 2008-03-24 14:38:27

Post by corpes »

bad4u wrote:
corpes wrote:I've got this error message when I'm using the new scriptversion:

"Script error in "DISCSHOP": unknown identifier: FULLTRIM at line 419"
Seems you have an outdated version of StringUtils1.pas, as the FullTrim function is part of this file (at least since StringUtils1 Version 4 from 2006) and the discshop.se script uses this unit.

Please download latest version of StringUtils1 from http://update.antp.be/amc/scripts/archi ... Utils1.pas and copy it to your scripts folder.
Thanx, now it work's fine!
Post Reply