Posted: 2008-03-27 10:16:57
THX bad4you (pls rename to good4you) =)
Code: Select all
// Translated Title
if CanSetField(fieldTranslatedTitle) then
begin
Value := '';
Value := TextBetween(PageText, '<title>', '</title>');
Value := StringReplace(Value, 'Discshop.se - ', '');
Value := StringReplace(Value, ' - Discshop.se', '');
HTMLDecode(Value);
SetField(fieldTranslatedTitle, Value);
end;
Open AMC script editor and simply change every 'movies' on the script to 'music' (there must be 7 'movies' inside, only the word movies - not movie without the s !), and save the script to a new name (discshop_music or similar). Et voilá, you can search and import music dvd.switchcore wrote:would like it to find my music-dvd´s also if possible.
I added a new option 'FilmOrMusic' to search discshop.se music-dvd section.switchcore wrote:would like it to find my music-dvd´s also if possible.
Would be great if the link had worked.bad4u wrote:I added a new option 'FilmOrMusic' to search discshop.se music-dvd section.switchcore wrote:would like it to find my music-dvd´s also if possible.
discshop.se 1.1.0: http://www.bad4u.741.com/full/discshop.se.ifs (copy link into a NEW browser window !)
Code: Select all
(***************************************************
Ant Movie Catalog importation script
www.antp.be/software/moviecatalog/
[Infos]
Authors=Håkan M
Title=Discshop 1.1.1
Description=Import data & picture from www.discshop.se in swedish
Site=www.discshop.se
Language=SE
Version=1.1.1
Requires=3.5.0
Comments=Based on the Discshop-script (v.1.1.0) made by Andreas Fridvall|Updated & modified by Håkan M
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 (default)|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 (default)|3=Take full list, separated by linebreaks
MultipleValuesCountry=1|1|0=Only take first value for Country|1=Take full list, separated by commas (default)|2=Take full list, separated by slashes
MultipleValuesCategory=1|1|0=Only take first value for Category|1=Take full list, separated by commas (default)|2=Take full list, separated by slashes
MultipleValuesLanguages=1|1|0=Only take first value for Languages|1=Take full list, separated by commas (default)|2=Take full list, separated by slashes
FilmOrMusic=0|0|0=Search for movies (default)|1=Search for music-dvd
***************************************************)
program Discshop;
uses
StringUtils1;
var
MovieList: string;
MovieName: string;
MovieURL: string;
MovieNumber: string;
SearchID: string;
SubSite: string;
StartPos: integer;
MovieListLength: integer;
ListEmpty: integer;
// ***** 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 GetOption('BatchMode') = 0 then
begin
// No movies were found
if Pos('Listar alla 0 produkter...', PageText) <> 0 then
begin
ShowMessage('No movie found for this search');
Exit;
end;
// Only one movie was found
if Pos('Listar alla 1 produkter...', PageText) <> 0 then
begin
MovieNumber := TextBetween(PageText, 'ds.php?red=ds_produkt.php&&arg=id@@@', ',,,');
MovieURL := 'http://www.discshop.se/shop/ds_produkt.php?subsite=' + SubSite +'&id=' + MovieNumber;
PageText := GetPage(MovieURL);
AnalyzeMoviePage(PageText);
Exit;
end;
// More that one movie was found
PickTreeClear;
ListEmpty := 1;
MovieList := TextBetween(PageText, '<form action="search_solr.php?ref=&lang=se&subsite=movies&cont=ds"', '</form>');
while ListEmpty = 1 do
begin
if Pos('style="height:75px;">', MovieList) <> 0 then
begin
StartPos := Pos('style="height:75px;">', MovieList)+21;
MovieList := Copy(MovieList, StartPos ,Length(MovieList)-StartPos);
end
else
begin
MovieList := '';
end;
MovieNumber := TextBetween(MovieList, 'ds.php?red=ds_produkt.php&&arg=id@@@', ',,,');
MovieURL := 'http://www.discshop.se/shop/ds_produkt.php?subsite=' + SubSite +'&id=' + MovieNumber;
MovieName := TextBetween(MovieList, 'title=""><b>', '</b>');
// If a movie was found
if MovieName <> '' then
begin
// Add it to the tree
HTMLDecode(MovieName);
HTMLRemoveTags(MovieName);
PickTreeAdd(MovieName, MovieURL);
MovieName :='';
ListEmpty := 1;
end
else
begin
ListEmpty := 0;
end;
end;
if PickTreeExec(MovieURL) then
begin
PageText := GetPage(MovieURL);
AnalyzeMoviePage(PageText);
end;
end
else
begin
if Pos('Listar alla 0 produkter...', PageText) <> 0 then
begin
// BatchNo movies were found
Exit;
end
else
begin
// Batch mode, pick the first available movie
MovieNumber := TextBetween(PageText, 'ds.php?red=ds_produkt.php&&arg=id@@@', ',,,');
MovieURL := 'http://www.discshop.se/shop/ds_produkt.php?subsite=' + SubSite +'&id=' + MovieNumber;
PageText := GetPage(MovieURL);
AnalyzeMoviePage(PageText);
Exit;
end;
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=' + SubSite + '&id=' + MovieNumber;
// URL
if CanSetField(fieldURL) then
SetField(fieldURL, MovieURL);
// Translated Title
if CanSetField(fieldTranslatedTitle) then
begin
Value := '';
Value := TextBetween(PageText, '<title>', '</title>');
Value := StringReplace(Value, 'Discshop.se - ', '');
Value := StringReplace(Value, ' - Discshop.se', '');
HTMLDecode(Value);
SetField(fieldTranslatedTitle, Value);
end;
// Original Title
if CanSetField(fieldOriginalTitle) then
begin
Value := '';
Value := TextBetween(PageText, 'Originaltitel:', '<div class="clfix"></div>');
Value := TextBetween(Value, '<div class="item2">', '</div>');
HTMLDecode(Value);
SetField(fieldOriginalTitle, Value);
end;
// Year
if CanSetField(fieldYear) then
begin
Value := '';
Value := TextBetween(PageText, 'Premiärår:', '<div class="clfix"></div>');
Value := TextBetween(Value, '<div class="item2">', '</div>');
HTMLDecode(Value);
SetField(fieldYear, Value);
end;
// Length
if CanSetField(fieldLength) then
begin
Value := '';
Value := TextBetween(PageText, 'Speltid:', '<div class="clfix"></div>');
Value := TextBetween(Value, '<div class="item2">', ' min</div>');
HTMLDecode(Value);
SetField(fieldLength, Value);
end;
// Director
if CanSetField(fieldDirector) then
begin
Value := '';
Value := TextBetween(PageText, 'Regi:', '<div class="clfix"></div>');
Value := TextBetween(Value, '<div class="item2">', '</div>');
Value := StringReplace(Value, '<BR>', ', ');
Value := StringReplace(Value, '<br>', ', ');
Value := StringReplace(Value, #13#10, '');
Value := StringReplace(Value, #09,'');
Value := StringReplace(Value, ' ', '');
HTMLRemoveTags(Value);
HTMLDecode(Value);
SetField(fieldDirector, Value);
end;
// Rating
if CanSetField(fieldRating) then
begin
Value := '';
Value := TextBetween(PageText, '<div class="rate1">', '</div>');
Value := StringReplace(Value, '<img src="img/design/v5/rate_big_1.gif" border=0>', '1');
Value := StringReplace(Value, '<img src="img/design/v5/rate_big_05.gif" border=0>', '5');
Value := StringReplace(Value, '<img src="img/design/v5/rate_big_0.gif" border=0>', '0');
case Value of
'00000' : Value := '0';
'50000' : Value := '1';
'10000' : Value := '2';
'15000' : Value := '3';
'11000' : Value := '4';
'11500' : Value := '5';
'11100' : Value := '6';
'11150' : Value := '7';
'11110' : Value := '8';
'11115' : Value := '9';
'11111' : Value := '10';
end;
SetField(fieldRating, Value);
end;
// Resolution
if CanSetField(fieldResolution) then
begin
Value := '';
Value := TextBetween(PageText, 'Bild:', '<div class="clfix"></div>');
Value := TextBetween(Value, '<div class="item2">', '</div>');
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 := '';
Value := TextBetween(PageText, 'Format:', '<div class="clfix"></div>');
Value := TextBetween(Value, '<div class="item2">', '</div>');
Value := StringReplace(Value, #13#10, '');
Value := StringReplace(Value, #09,'');
while Pos(' ', Value) = 1 do
Value := Copy(Value, 2, Length(Value));
while Pos(' ', Value) > 0 do
Value := StringReplace(Value, ' ', '');
HTMLDecode(Value);
SetField(fieldVideoFormat, Value);
end;
// MediaType
if CanSetField(fieldMediaType) then
begin
Value := '';
Value := TextBetween(PageText, 'Kartong:', '<div class="clfix"></div>');
Value := TextBetween(Value, '<div class="item2">', '</div>');
HTMLDecode(Value);
SetField(fieldMediaType, Value);
end;
// Writer (Producer Field)
if CanSetField(fieldProducer) then
begin
Value := '';
Value := TextBetween(PageText, 'Manus:', '<div class="clfix"></div>');
Value := TextBetween(Value, '<div class="item2">', '</div>');
Value := StringReplace(Value, '<BR>', ', ');
Value := StringReplace(Value, '<br>', ', ');
Value := StringReplace(Value, '<br/>', ', ');
Value := StringReplace(Value, '<BR/>', ', ');
Value := StringReplace(Value, #13#10, '');
Value := StringReplace(Value, #09,'');
while Pos(' ', Value) = 1 do
Value := Copy(Value, 2, Length(Value));
while Pos(' ', Value) > 0 do
Value := StringReplace(Value, ' ', '');
HTMLRemoveTags(Value);
HTMLDecode(Value);
SetField(fieldProducer, Value);
end;
// Picture
if CanSetPicture then
begin
Value := '';
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;
// Discs
SetField(fieldDisks, ImportList(PageText, GetOption('MultipleValuesDisks'), 'Antal skivor:'));
// 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 := '';
Value := TextBetween(PageText, 'Ljud:', '<div class="clfix"></div>');
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);
while Pos(' ', Value) = 1 do
Value := Copy(Value, 2, Length(Value));
while Pos(' ', Value) > 0 do
Value := StringReplace(Value, ' ', '');
while Pos(' ', Value) = Length(Value)-1 do
Value := Copy(Value, 0, Length(Value)-1);
while Pos(',', Value) = Length(Value)-1 do
Value := Copy(Value, 0, Length(Value)-2);
// Remove the last ', ' in the row
Value2 := Copy(Value, Length(Value)-1, 2);
if Value2 = ', ' then Value := Copy(Value, 0, Length(Value)-2);
SetField(fieldLanguages, Value);
end;
// Subtitles
if CanSetField(fieldSubtitles) then
begin
Value := '';
Value := TextBetween(PageText, 'Text:', '<div class="clfix"></div>');
Value := StringReplace(Value, #13#10,'');
Value := StringReplace(Value, #09,'');
Value := StringReplace(Value, ' ', '');
Value := StringReplace(Value, '<br/>', ', ');
Value2 := TextBetween(Value, '<div id="specifikationer_text" style="display:none;">','</div>');
// 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;
while Pos(' ', Value3) = 1 do
Value3 := Copy(Value3, 2, Length(Value3));
Value3 := StringReplace(Value3, ', ', '');
while Pos(' ', Value3) > 0 do
Value3 := StringReplace(Value3, ' ', ' ');
// Add ', ' instead of space between subtitles
// Value3 := StringReplace(Value3, ' ', ', ');
// Remove the last ', ' in the row
//Value3 := Copy(Value3, 0, Length(Value3)-2);
// Replace ',,' with ','
// Value3 := StringReplace(Value3, ',,', ',');
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 := '';
Value := TextBetween(PageText,'Filmens handling:', '</p>');
if Value = '' then
Value := TextBetween(PageText, 'Filmens handling', '</p>');
if Value = '' then
Value := TextBetween(PageText, 'Beskrivning:', '</p>');
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);
Value := StringReplace(Value, ' Informationen kopierad från discshop.se!','');
Value := StringReplace(Value, ' Info kopierad från discs hop.se!','');
Value := StringReplace(Value, ' Informationen är tagen från discshop.se!','');
Value := StringReplace(Value, ' Informationen är tagen från disc shop.se!','');
Value := StringReplace(Value, ' Informationen hämtad från discshop.se!','');
Value := StringReplace(Value, ' Över 15.000 titlar i lager.','');
Value := StringReplace(Value, ' Över 18.000 titlar i lager.','');
Value := StringReplace(Value, ' Leverans nästa dag.','');
Value := StringReplace(Value, ' Leverans nästa dag.','');
Value := StringReplace(Value, ' Leverans nästa dag om du beställer före 16.00.','');
Value := StringReplace(Value, ' Leverans nästa dag om du beställer före 16.00.','');
Value := StringReplace(Value, ' Beställ före 16.00.','');
Value := StringReplace(Value, ' Beställ före 16.00, leverans nästa dag.','');
Value := StringReplace(Value, ' Köp den på www.discshop.se idag!.','');
HTMLRemoveTags(Value);
HTMLDecode(Value);
SetField(fieldDescription, Value);
end;
// Reviews
if CanSetField(fieldComments) then
begin
Value3 := '';
Value3 := TextBetween(PageText, '<div class="ds_omdomme_cust">', 'Läs alla omdömen');
Value3 := StringReplace(Value3, #9, '');
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>'),'');
while Pos(' ', Value3) = 1 do
Value3 := Copy(Value, 2, Length(Value3));
while Pos(' ', Value3) > 0 do
Value3 := StringReplace(Value3, ' ', '');
while Pos(#13#10 + ' ', Value3) > 0 do
Value3 := StringReplace(Value3, #13#10 + ' ', ' ');
HTMLRemoveTags(Value3);
HTMLDecode(Value3);
Value3 := FullTrim(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 := '';
Value := TextBetween(PageText, StartTag, '<div class="clfix"></div>');
Value := TextBetween(Value, '<div class="item2">', '</div>');
Value := StringReplace(Value, #13#10,'');
Value := StringReplace(Value, #09,'');
Value := StringReplace(Value, '<br/>','<BR>'); // separator for categories
Value := StringReplace(Value, '</br>','<BR>');
Value := StringReplace(Value, ' / ','<BR>'); // separator for some countries
while Pos(' ', Value) = 1 do
Value := Copy(Value, 2, Length(Value));
while Pos(' ', Value) > 0 do
Value := StringReplace(Value, ' ', '');
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
case GetOption('FilmOrMusic') of
0 : SubSite := 'movies';
1 : SubSite := 'music';
end;
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_solr.php?lang=&cont=ds&soktext=' + UrlEncode(MovieName) + '&subsite_set=' + SubSite + '&lang=se&subsite=movies&&ref=')
end;
end;
end
else
ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)');
end.
HMC wrote:I have rewritten some of the code in Discshop v1.1.0 script.
It might need more updates but feel free to test it.
Thanks.HMC wrote:I have rewritten some of the code in Discshop v1.1.0 script.