Die kleinen Pics sind wirklich klein, aber die meisten sind auch von anderen Filmen.
Ich habe mal alle Pics runtergeladen und nach Größe sortiert, dabei waren (zufällig?) die größten Pics passend zum Titel
Code: Select all
;imdb datenbank auslesen
;imdb datenbank auslesen
;https://www.autohotkey.com/boards/viewtopic.php?f=9&t=88144&sid=fa8f8ea423a47e201330ae4c653b706f
#SingleInstance force
title:="Guardians of the Galaxy Vol. 2"
productiondate:=""
credit:=""
imdbArray:=Object()
;##################################################################### ; anzeige des ergebnisses
;StepEinsArray
data_obj := imdb_poster(title, productiondate, credit) ; suchanfrage bei bing mit anschließender übernahme des retournierten erggebnisses in ein object
For Name, Resultat In data_obj { ; auslesen des retournierten objects
; needle .= name ": " A_Tab Resultat "`n`n"
imdbArray[name] := Resultat
}
;##################################################################### ; anzeige des ergebnisses
;StepZweiArray
data_obj := StepZwei(imdbArray["imdbURL"]) ; suchanfrage bei bing mit anschließender übernahme des retournierten erggebnisses in ein object
For Name, Resultat In data_obj { ; auslesen des retournierten objects
; needle .= name ": " A_Tab Resultat "`n`n"
imdbArray[name] := Resultat
}
imdbArray["ItemFileName"] := StrReplace(imdbArray["ItemFileName"], """")
needle := "PosterLink:`n" imdbArray["PosterLink"] "`n`n"
. "Rating:`n" imdbArray["Rating"] "`n`n"
. "HTMFile:`n" imdbArray["HTMFile"] "`n`n"
. "SmalPicFileName:`n" imdbArray["SmalPicFileName"] "`n`n"
. "imdbURL:`n" imdbArray["imdbURL"] "`n`n"
. "titel:`n" imdbArray["titel"] "`n`n"
. "description:`n" imdbArray["description"] "`n`n"
. "ratingb:`n" imdbArray["ratingb"] "`n`n"
. "ratingvalue:`n" imdbArray["ratingvalue"] "`n`n"
. "bestrating:`n" imdbArray["bestrating"] "`n`n"
. "ItemPicFileName:`n" imdbArray["ItemFileName"] ".jpg`n`n"
. "ItemhtmFileName:`n" imdbArray["ItemFileName"] ".htm`n`n"
Data := imdbArray["PosterLink"] ";"
. imdbArray["Rating"] ";"
. imdbArray["HTMFile"] ";"
. imdbArray["SmalPicFileName"] ";"
. imdbArray["imdbURL"] ";"
. imdbArray["titel"] ";"
. imdbArray["description"] ";"
. imdbArray["ratingb"] ";"
. imdbArray["ratingvalue"] ";"
. imdbArray["bestrating"] ";"
. imdbArray["ItemFileName"] ".jpg;"
. imdbArray["ItemFileName"] ".htm"
UrlDownloadToFile, % imdbArray["PosterLink"], % imdbArray["ItemFileName"] ".jpg" ; download ausgabedatei
UrlDownloadToFile, % imdbArray["imdbURL"], % imdbArray["ItemFileName"] ".htm"
FileAppend, % Data, % imdbArray["ItemFileName"] ".txt" ; anhang zusatzinformation
BilderFull := StepDrei(imdbArray["imdbURL"], imdbArray["ItemFileName"])
imdbPicArray := object()
Loop, Parse, BilderFull, `n`r
imdbPicArray[A_Index] := StrReplace(A_LoopField,"""")
Loop, % imdbPicArray.maxindex() {
If (A_Index>=11)
continue
UrlDownLoadToFile, % imdbPicArray[A_Index], % StrReplace(imdbArray["titel"],"""") A_Space A_Index ".jpg"
ToolTip % A_Index A_Space imdbPicArray[A_Index] "`n" imdbArray["titel"] A_Space A_Index ".jpg"
}
/*
msgbox,,imdbArray["PosterLink"], % imdbArray["PosterLink"]
msgbox,,imdbArray["imdbURL"], % imdbArray["imdbURL"]
msgbox,,imdbArray["ItemFileName"], % imdbArray["ItemFileName"]
msgbox,,needle, % needle
msgbox,,data, % data
*/
;msgbox,,needle, % needle "`n" BilderFull
FileDelete, test99.txt
Return
;##############################################################################################################################################################
imdb_poster(title, productiondate:="", credit:="") { ; https://www.autohotkey.com/boards/viewtopic.php?p=350106#p350106 by Teadrinker
bingURL := "http://www.bing.com/search?q=imdb+" ; erstellung link der bing-suchanfrage
. title
. "/tt+'"
. title
. "'+'"
. productiondate
. "'+'"
. credit
. "'&scope=web&setmkt=en-US&qs=ns&form=QBRE&qb=2"
bingURL := EncodeDecodeURI(bingURL, true, false) ; HTML encodierung
html := UrlDownloadToVar(bingURL) ; übernahme der retournierten suchanfrage in variable
doc := DocumentFromHtml(html) ; konvertierung (?) und übernahme in ein object
results := doc.getElementById("b_results") ; filtern nach element
if !imdbUrl := results.querySelector("a[href*=imdb").href ; validierung
throw "imdb url not found" ; zurück auf los
html := UrlDownloadToVar(imdbUrl) ; übernahme der erfolgreichen filterung in variable
doc := DocumentFromHtml(html) ; übernahme in ein object
Resultat := Object() ; erstellung object
Resultat["PosterLink"] := doc.querySelector(".poster > a > img").src ; filtern nach werten mit übernahme in object
Resultat["Rating"] := doc.querySelector(".ratingValue").innerText ; s.o.
Resultat["HTMFile"] := title A_Space "(" productiondate ")" A_Space credit ".htm" ; s.o.
Resultat["SmalPicFileName"] := title A_Space "(" productiondate ")" A_Space credit ".jpg" ; s.o.
Resultat["imdbURL"] := RegExMatch (imdbURL, ". *? / Tt [^ /] +", imdbURL) ; s.o.
Resultat["HTMLSource"] := html ; s.o.
Return Resultat ; retournierung des objects
}
UrlDownloadToVar(url) {
oHTTP := ComObjCreate("MSXML2.XMLHTTP.6.0")
Loop {
Try {
oHTTP.open("GET", url, false)
oHTTP.send()
status := oHTTP.status
if (status != 200)
nochmal := 1
}
catch e {
Tooltip Fehler
}
} until !nochmal
Return oHTTP.responseText
}
DocumentFromHtml(html) {
doc := ComObjCreate("htmlfile")
doc.write("<meta http-equiv=""X-UA-Compatible"" content=""IE=9"">")
doc.write(html)
Return doc
}
EncodeDecodeURI(str, encode := true, component := true) {
static doc := ComObjCreate("htmlfile")
, _ := doc.write("<meta http-equiv=""X-UA-Compatible"" content=""IE=9"">")
, JS := ObjBindMethod(doc.parentWindow, "eval")
for k, v in [["\", "\\"], ["'", "\'"], ["`r", "\r"], ["`n", "\n"]]
str := StrReplace(str, v[1], v[2])
Return JS.( (encode ? "en" : "de") . "codeURI" . (component ? "Component" : "") . "('" . str . "')" )
}
;##############################################################################################################################################################
StepZwei(URL) {
;url:="https://www.imdb.com/title/tt2357547/"
;urldownloadtofile,%url%,test54321.txt
transform,ucx,chr,34
transform,ucn,chr,10
whr:= ComObjCreate("WinHttp.WinHttpRequest.5.1")
ComObjError(false)
whr.Silent := True ;- script failure = off
whr.SetTimeouts(500,500,500,500)
whr.Open("GET", url,false)
whr.Send()
whr.WaitForResponse(120)
H := whr.ResponseText
;--------------------------------------------------------------------------------
A1x :="<meta property='og:title' content=" , B1x:=" />"
A2x :="<meta name=" . ucx . "description" . ucx . " content=" , B2x:=" />"
A3x :=ucx . "ratingcount" . ucx . ":" , B3x:=","
A4x :=ucx . "ratingvalue" . ucx . ":" , B4x:=ucn
A5x :=ucx . "bestrating" . ucx . ":" , B5x:=","
StepZweiArray := Object()
StepZweiArray["titel"] := xStr(h,,a1x , b1x )
StepZweiArray["description"] := xStr(h,,a2x , b2x )
StepZweiArray["ratingb"] := xStr(h,,a3x , b3x )
StepZweiArray["ratingvalue"] := xStr(h,,a4x , b4x )
StepZweiArray["bestrating"] := xStr(h,,a5x , b5x )
StepZweiArray["ItemFileName"] := SubStr(StepZweiArray["titel"] . " " . StepZweiArray["description"], 1, 200)
return StepZweiArray
}
;##############################################################################################################################################################
;/*
StepDrei(URL, FileName) {
FileDelete, last.txt
FileDelete, test99.txt
;url:="https://www.imdb.com/title/tt7136896/"
F1:=a_scriptdir . "\test99.txt"
urldownloadtofile,%url%,%f1%
fileread,h,%f1% ;- found 111 pictures
;- hier habe ich weniger Bilder ( ? )
/*
whr:= ComObjCreate("WinHttp.WinHttpRequest.5.1")
ComObjError(false)
whr.Silent := True ;- script failure = off
;whr.SetTimeouts(500,500,500,500)
whr.Open("GET", url,false)
whr.Send()
;whr.WaitForResponse(120)
H := whr.ResponseText ;- found 63 pictures
;---------------------------
*/
transform,ucx,chr,34
stringreplace,h,h,.png",.png"`r`n,all
stringreplace,h,h,.jpg",.jpg"`r`n,all
A1x :="http" , B1x:=ucx
;---------------------------
e:=""
loop,parse,h,`n,`r
{
x:=a_loopfield
if x=
continue
if (InStr(x,".jpg")) or (InStr(x,".png"))
{
pict:=xStr(x,,a1x,b1x,,,,,0,0 )
if pict=
continue
e .= pict . "`r`n"
}
}
ifexist,last.txt
filedelete,last.txt
;fileappend,%e%,last.txt,utf-8
FileAppend, % e, % FileName " Bilder.csv", utf-8 ; imdbArray["ItemFileName"], utf-8
;run,last.txt
;e:=""
;h:=""
return e
}
;*/
;#########################
;======================== SKAN xStr =========================
;-------- saved at 7. April 2020 16:34:11 from user SKAN --------------
;- xStr for general text extraction and parsing XML HTML
;- https://www.autohotkey.com/boards/viewtopic.php?f=6&t=74050
xStr(ByRef H, C:=0, B:="", E:="",ByRef BO:=1, EO:="", BI:=1, EI:=1, BT:="", ET:="") {
Local L, LB, LE, P1, P2, Q, N:="", F:=0 ; xStr v0.97 by SKAN on D1AL/D343 @ tiny.cc/xstr
Return SubStr(H,!(ErrorLevel:=!((P1:=(L:=StrLen(H))?(LB:=StrLen(B))?(F:=InStr(H,B,C&1,BO,BI))?F+(BT=N?LB
:BT):0:(Q:=(BO=1&&BT>0?BT+1:BO>0?BO:L+BO))>1?Q:1:0)&&(P2:=P1?(LE:=StrLen(E))?(F:=InStr(H,E,C>>1,EO=N?(F
?F+LB:P1):EO,EI))?F+LE-(ET=N?LE:ET):0:EO=N?(ET>0?L-ET+1:L+1):P1+EO:0)>=P1))?P1:L+1,(BO:=Min(P2,L+1))-P1)
}
;------------------------------------------------------------------
;#####################################