imdb datenbank auslesen Topic is solved

Stelle Fragen zur Programmierung mit Autohotkey

Moderator: jNizM

effel
Posts: 542
Joined: 16 Jan 2018, 13:34

imdb datenbank auslesen

15 Mar 2021, 17:25

Hallo, beim stöbern fand ich hier https://www.autohotkey.com/boards/viewtopic.php?p=350106#p350106 den passenden Code zum erweitern meiner Filmdatenbank.

Von imdb.com werden Informationen zu jedem Film bereitgestellt.

Nun gibt es noch weitere Daten, wie z.B...
Director: Lionel Steketee
Writer: Daive Cohen (screenplay)
Stars: Kev Adams, Jamel Debbouze, Vanessa Guide | See full cast & crew »...

die man ohne Anmeldung saugen kann, aber im Code leider nicht berücksichtigt wurden.

Ich gebe es ehrlich zu, meine Versuche an diese Daten zu kommen, scheitern schon im Ansatz, weil ich mit dem Code nicht klar komme.

Ich konnte nicht mal nachverfolgen wie der Autor an die Rating Daten kommt.

Das mit dem HTML auslesen ist ein Schwachpunkt bei mir und will mir nicht ins Hirn :shock:

Vielleicht hat ja auch jemand was fertiges? um an solche Daten zu kommen?
Auf der Webseite ist noch weiterer interessanter Content... zu jedem Film kann man auch einiges an Bildern finden.



Code: Select all

; https://www.autohotkey.com/boards/viewtopic.php?p=350106#p350106
;HTML DOM  AutoHotkeyCommunity
;https://www.autohotkey.com/boards/viewtopic.php?f=76&t=80466&hilit=imdb
title := "aladin"
productiondate := "2018"
credit := "Kev Adams, Jamel Debbouze, Vanessa Guide"
imdbArray := Object()
data_obj := imdb_poster(title, productiondate, credit)
For Name, Resultat In data_obj {
needle .= name ": " A_Tab Resultat "`n`n"
imdbArray[name] := Resultat
needle2 := "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"
}
msgbox % needle2
/*
---------------------------
Imdb_poster.ahk
---------------------------
HTMFile: 		aladin (2018) Kev Adams, Jamel Debbouze, Vanessa Guide.htm
imdbURL: 		https://www.imdb.com/title/tt7136896/
PosterLink: 		https://m.media-amazon.com/images/M/MV5BYjBhMTY0NzgtMWFiOS00NGRjLTgyMTUtZTg5YWZmM2VjZTdjXkEyXkFqcGdeQXVyNTc5OTMwOTQ@._V1_UY268_CR9,0,182,268_AL_.jpg
Rating: 		3,5/10 
SmalPicFileName: 	aladin (2018) Kev Adams, Jamel Debbouze, Vanessa Guide.jpg
---------------------------
OK   
---------------------------
*/

;##################################################################################################
; https://www.autohotkey.com/boards/viewtopic.php?p=350106#p350106 by Teadrinker
  imdb_poster(title, productiondate:="", credit:="") {
; bingURL = http://www.bing.com/search?q=imdb+aladin/tt+'aladin'+'2018'+'%credit%'&scope=web&setmkt=en-US&qs=ns&form=QBRE&qb=2
  bingURL = http://www.bing.com/search?q=imdb+%title%/tt+'%title%'+'%productiondate%'+'%credit%'&scope=web&setmkt=en-US&qs=ns&form=QBRE&qb=2
  bingURL := EncodeDecodeURI(bingURL, true, false)
  html := UrlDownloadToVar(bingURL)
  doc := DocumentFromHtml(html)
  results := doc.getElementById("b_results")
  if !imdbUrl := results.querySelector("a[href*=imdb").href
     throw "imdb url not found"
  html := UrlDownloadToVar(imdbUrl)
  doc := DocumentFromHtml(html)

  UrlDownloadToFile, % doc.querySelector(".poster > a > img").src, % title A_Space "(" productiondate ")" A_Space credit ".jpg"
  UrlDownloadToFile, % html, % title A_Space "(" productiondate ")" A_Space credit ".htm"
  FileAppend, % html, % title A_Space "(" productiondate ")" A_Space credit ".htm"

  Resultat := Object()
  Resultat["PosterLink"] 	:= doc.querySelector(".poster > a > img").src
  Resultat["Rating"] 		:= doc.querySelector(".ratingValue").innerText
  Resultat["HTMFile"] 		:= title A_Space "(" productiondate ")" A_Space credit ".htm"
  Resultat["SmalPicFileName"] 	:= title A_Space "(" productiondate ")" A_Space credit ".jpg"
  Resultat["imdbURL"] 		:= RegExMatch (imdbURL, ". *? / Tt [^ /] +", imdbURL)
  Return Resultat
}

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 . "')" )
}
garry
Posts: 3740
Joined: 22 Dec 2013, 12:50

Re: imdb datenbank auslesen  Topic is solved

16 Mar 2021, 03:06

XSTR von SKAN

zeige URL's mit Bildern :

Code: Select all

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
run,last.txt
e:=""
h:=""
return
;======================== 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)  
}
;------------------------------------------------------------------
hier auch ein jpg url welches gross ist , fand die anderen Bilder zu klein
result :

Code: Select all

TITEL="Aladdin 2 (2018) - IMDb"
"Directed by Lionel Steketee.  With Kev Adams, Jamel Debbouze, Vanessa Guide, Eric Judor. The suite of the New Adventures of Aladin."
RatingCount= 861
Rating-Average= "3.5" / "10.0"
IMAGE= "https://m.media-amazon.com/images/M/MV5BYjBhMTY0NzgtMWFiOS00NGRjLTgyMTUtZTg5YWZmM2VjZTdjXkEyXkFqcGdeQXVyNTc5OTMwOTQ@._V1_.jpg"
script:

Code: Select all

url:="https://www.imdb.com/title/tt7136896/"
;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:=","
A6x :=ucx . "image" . ucx . ":"       ,  B6x:=","

titel       :=xStr(h,,a1x , b1x )
description :=xStr(h,,a2x , b2x )
rating      :=xStr(h,,a3x , b3x )
ratingvalue :=xStr(h,,a4x , b4x )
bestrating  :=xStr(h,,a5x , b5x )
image       :=xStr(h,,a6x , b6x )


msgbox,TITEL=%titel%`n%description%`nRatingCount=%rating%`nRating-Average=%ratingvalue% /%bestrating%`nIMAGE=%image%
;ifexist,test52.txt
;  filedelete,test52.txt
;fileappend,TITEL=%titel%`r`n%description%`r`nRatingCount=%rating%`r`nRating-Average=%ratingvalue% /%bestrating%`r`nIMAGE=%image%`r`n,test52.txt,UTF-8
;run,test52.txt
return
;======================== 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)  
}
;------------------------------------------------------------------

Last edited by garry on 16 Mar 2021, 08:35, edited 1 time in total.
effel
Posts: 542
Joined: 16 Jan 2018, 13:34

Re: imdb datenbank auslesen

16 Mar 2021, 12:53

Hallo, Garry das funguziert echt gut :D

Ich werde es mal mit ein paar Files versuchen

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

Danke für deine Mühen

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)  
}
;------------------------------------------------------------------
;#####################################
garry
Posts: 3740
Joined: 22 Dec 2013, 12:50

Re: imdb datenbank auslesen

17 Mar 2021, 05:10

@effel vielen Dank für den komplexen Skript ( arrays, function etc ) , findet Film auch wenn man den Titel falsch oder unvollständig schreibt ( via Bing )
Legst Du Deinen Skript in 'Skripte und Funktionen' ?
effel
Posts: 542
Joined: 16 Jan 2018, 13:34

Re: imdb datenbank auslesen

17 Mar 2021, 17:02

Hallo @garry, ich freue mich dass es dir gefällt

Ich bin grade dabei noch weitere Daten von der IMDB Webseite zu saugen. Das nimmt Zeit in Anspruch, aber ich komme gut voran.

Wenn ich alles geschafft habe kann ich es gerne in Skripte und Funktionen posten, aber nur wenn ich dich als Autor ganz oben nennen darf ;) denn das meiste ist von dir... noch!

Code: Select all

A9x :="Cast overview, first billed only" 
B9x:="View production, box office, & company info"
StepZweiArray["CastOverviewA"] := xStr(h,,a9x , b9x )
;MsgBox,,CastOverviewA, % imdbArray["CastOverviewA"],2
HH := StepZweiArray["CastOverviewA"]

 A10x=<tr class="         ;- Begin
 B10x=<tr class="         ;- END
 AllNames := "" 
 BO := 1                  ; Starting position
  While Name := xStr(HH,,A10x,B10x,BO)   ; H,,B,E,BO
  StepZweiArray["CastOverviewB", A_Index] := Name
garry
Posts: 3740
Joined: 22 Dec 2013, 12:50

Re: imdb datenbank auslesen

17 Mar 2021, 17:34

nein, ich habe nur einen Bruchteil beigetragen , Skript/Funktion ist vom user SKAN ( xSTR )
https://www.autohotkey.com/boards/viewtopic.php?f=6&t=74050
ich verstehe nur die Ahk-basic Befehle ( if .. then .. goto )
... und DEIN Skript mit Mediathek läuft sehr gut , ich hatte es verfremdet
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: imdb datenbank auslesen

18 Mar 2021, 06:54

Erweiterter Ansatz. Folgender Service dient hierbei als Quelle ...
The Open Movie Database - The OMDb API is a RESTful web service to obtain movie information, all content and images on the site are contributed and maintained by our users.
... wobei für folgende Schlüssel die Werte im JSON-Format retourniert werden:
Title|Year|Rated|Released|Runtime|Genre|Director|Writer|Actors|Plot|Language|Country|Awards|Poster|Ratings|Metascore|imdbRating|imdbVotes|imdbID|Type|DVD|BoxOffice|Production|Website|Response

Code: Select all

MsgBox % OMDb("Blade Runner")		; Beispielabfrage mit Titel des gesuchten Films (hier zum Film "Blade Runner" von 1982). Alternativ kann auch ..
MsgBox % OMDb("tt1856101")			; .. die imdb-ID eines gesuchten Films im Format 'tt<nummer>' übergeben werden (hier zum Film "Blade Runner 2049" von 2017)

OMDb(param:="") {
	if !param
		Return "Missing parameter"
	param	:=	SubStr(param,1,2)="tt"	? "i=" . param
			:	(param != "")			? "t=" . StrReplace(param,A_Space,"+")
			:	""

	myAPIkey:=	<hier muss dein eigener APIKey eingetragen werden>	; und von dort bekommst du diesen per mail zugeschickt: http://omdbapi.com/apikey.aspx
	dataReq	:=	"http://www.omdbapi.com/?apikey="
			.	 myAPIkey
			.	"&"
			.	 param
	Return UrlDownloadToVar(dataReq)
	}

UrlDownloadToVar(url) {
	req := ComObjCreate("Msxml2.XMLHTTP")
	req.open("GET", url, False)
	req.Send()
	Return req.responseText
	}
PS. Bei Weiterprozessierung der Ausgabe zu beachten: der Schlüssel 'Ratings' liefert mitunter mehrere Anbieterergebnisse! Ich werde hierzu zeitnah ein (leicht) erweitertes Script unter 'Skripte und Funktionen' veröffentlichen.
PPS. OMDb greift für Poster scheinbar auf Amazon zurück. Die 'Größe' eines Bildes lässt sich direkt im Link vergößern/-kleinern. Das Bild wird AFAICS beim download entsprechend skaliert.

Have phun 8-)
just me
Posts: 9424
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: imdb datenbank auslesen

20 Mar 2021, 04:49

Moin,

ich kann nicht wirklich nachvollziehen, warum SKAN seine xStr() Funktion ausdrücklich für HTML/XML-Daten empfiehlt. Darin verbirgt sich ja im Prinzip nur eine InStr() -> InStr() -> SubStr() Folge mit den bekannten Schwächen der 'einfachen' Stringfunktionen; allerdings in einer kaum lesbaren Form.

HTML/XML-Daten haben ja den Vorteil, dass sie strukturiert sind und dass man mit den passenden COM-Objekten direkt auf die Strukturen zugreifen kann. Wenn man sich wiederholt mit solchen Daten beschäftigen will oder muss, lohnt es sich meiner Meinung nach schon, sich auch mit den HTML/XML-Objekten zu beschäftigen. Dabei ist w3schools.com/ eine sehr nützliche Informationsquelle.

Wenn Interesse besteht, versuche ich zu zeigen, wie das aussehen könnte.
effel
Posts: 542
Joined: 16 Jan 2018, 13:34

Re: imdb datenbank auslesen

20 Mar 2021, 06:14

just me wrote:
20 Mar 2021, 04:49
Wenn Interesse besteht, versuche ich zu zeigen, wie das aussehen könnte.
Hallo Just Me, ja gerne, ich bin sehr daran interessiert den Umgang mit COM-Objekten zu verstehen.

Wenn ich eine Seite vorschlagen darf, dann wäre es eine beliebige imdb Webseite, wie z. B. https://www.imdb.com/title/tt0337593/?ref_=rvi_tt

Hier beiße ich auf Granit wenn ich ohne xStr() an folgende Daten kommen möchte:

Code: Select all

 "R",
  "actor": [
    {
      "@type": "Person",
      "url": "/name/nm0195439/",
      "name": "James D\u0027Arcy"
    },
    {
      "@type": "Person",
      "url": "/name/nm0605943/",
      "name": "Roger Morlidge"
    },
    {
      "@type": "Person",
      "url": "/name/nm0000270/",
      "name": "Gabrielle Anwar"
    },
    {
      "@type": "Person",
      "url": "/name/nm0000352/",
      "name": "Vincent D\u0027Onofrio"
    }
  ],
  "director": {
    "@type": "Person",
    "url": "/name/nm0857280/",
    "name": "Graham Theakston"
  },
  "creator": [
    {
      "@type": "Person",
      "url": "/name/nm0039328/",
      "name": "Piers Ashworth"
    },
    {
      "@type": "Person",
      "url": "/name/nm0236279/",
      "name": "Arthur Conan Doyle"
    },
    {
      "@type": "Organization",
      "url": "/company/co0489955/"
    },
    {
      "@type": "Organization",
      "url": "/company/co0073776/"
    },
    {
      "@type": "Organization",
      "url": "/company/co0020879/"
    },
    {
      "@type": "Organization",
      "url": "/company/co0086742/"
    },
    {
      "@type": "Organization",
      "url": "/company/co0086743/"
    },
    {
      "@type": "Organization",
      "url": "/company/co0006634/"
    },
    {
      "@type": "Organization",
      "url": "/company/co0014957/"
    }
  ],
  "
garry
Posts: 3740
Joined: 22 Dec 2013, 12:50

Re: imdb datenbank auslesen

20 Mar 2021, 07:47

Mit rss und xml hatte ich keine Probleme, da logisch aufgebaut

Hier kann man sehr gut DLF Radio hören, suchen etc ...

Code: Select all

run,https://srv.deutschlandradio.de/themes/dradio/script/aod/index.html?audioMode=2&audioID=4&state=
return

habe hier ein Beispiel mit DLF , resultat sind denn xml Dateien , einfach zum lesen , bei blick.ch chaotisch gelöst

Code: Select all

f1:=a_scriptdir . "\DLF_AllPodcasts5.txt"
transform,s,chr,34

;url=https://www.blick.ch                        ;- hier mal kompliziert gelöst , weiss nicht nach was suchen ( Beginn,Ende )
oft bieten sie kein rss an damit man mehr Werbung sieht ?


url:="https://www.deutschlandfunk.de/podcasts.2516.de.html?drpp%3Ahash=displayAllBroadcasts"
whr:= ComObjCreate("WinHttp.WinHttpRequest.5.1")
whr.Open("Get",URL)
whr.Send()
whr.WaitForResponse()
H:= whr.ResponseText
;-------------------
print=0                       ;- for test
if (print=1)
{
f11=%a_scriptdir%\DLF_TEST.txt
ifexist,%f11%
   filedelete,%f11%
Fileappend,%h%,%f11%,utf-8    ;- hier eine Linie mit 81686 characters
h=
exitapp
}
;-------------------
Loop,parse,h,`n,`r
{
x:=a_loopfield
if x contains <div id="content">
  {
  K:=x
  break
  }
}
h:=""
e:=""
stringreplace,k,k,target="_blank">,£,all
;--------------------
print=0                      ;- for test
if (print=1)
{
stringreplace,klm,k,£,£`r`n,all
f12=%a_scriptdir%\DLF2_TEST.txt
ifexist,%f12%
   filedelete,%f12%
Fileappend,%klm%,%f12%,utf-8
klm=
exitapp
}
;-------------------

;-------------------
Loop,parse,K,£
{
x:=a_loopfield
A:="data-url=" . s
B:= s
;c:=xStr(x,,A,B,,,,,0,0)   ;- with A and B
d:=xStr(x,,A,B)            ;- between A and B
e .= d . "`r`n"
}
ifexist,%f1%
  filedelete,%f1%
fileappend,%e%,%f1%
e:=""
k:=""
exitapp


;----------------------------------------------------------------
;- 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)  
}
;----------------------------------------------------------------
EDIT :
@just me
Deine Lösung interessiert mich auch ,
versuche denn dies in einer Listview anzuzeigen ( mehrere url's ) , [Beginn]Titel,Url,datum1,datum2 [Ende]
url1=https://www.blick.ch
url2=https://www.blick.ch/news/
url3=https://www.blick.ch/schweiz/basel/ etc

Ich glaube jede Zeitung sieht anders aus wenn kein RSS angeboten wird , 100'000 Zeichen auf einer Linie , gibt es dafür eine einfachere Lösung um verschiedene Formate auszufiltern ?
EDIT : Ich brauche keine Lösung für BLICK , war eine allgemeine Frage , werde gerne die Lösung für 'effel' anschauen
Last edited by garry on 20 Mar 2021, 15:40, edited 2 times in total.
just me
Posts: 9424
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: imdb datenbank auslesen

20 Mar 2021, 08:13

Hi effel,

bei mir wird's etwas später. Ich melde mich.
just me
Posts: 9424
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: imdb datenbank auslesen

21 Mar 2021, 05:37

Moin effel,

wieder da. Dein Beispiel zeigt auf eine Besonderheit. Was Du da auswerten willst, ist kein HTML, sondern ein per <script> Tag eingebettetes JavaScript Objekt (JSON). Den Text könntest Du natürlich mit Stringfunktionen auslesen. Es gibt aber auch eine 'einfache' HTML-Option.

Ich habe mich aufgrund dieses Beitrags erstmals intensiver mit der Methode HTML.querySelector() beschäftigt. Und ich war überrascht, wie damit der direkte Zugriff auf das HTML vereinfacht wird. Was so alles geht, ist hier recht gut beschrieben: CSS Selector Reference. Man kann mit Tagnamen, Klassennamen, Attributen und Kombinationen daraus selektieren. Bei Attributen kann man zusätzlich die Inhalte auswerten. Ausser HTML.querySelector() gibt es noch die Methode HTML.querySelectorAll(), mit der man mehrere Elemente selektieren kann.

Für Dein Beispiel wäre der passende Selektor Doc.querySelector("script[type='application/ld+json']").innerText. Damit erhältst Du den beschreibenden Text des JSON Objekts. Die Syntax ähnelt verblüffend der von AHK. Objekte werden in geschweifte Klamern {} eingebettet, Arrays in eckige [], Strings sind von Anführungszeichen umgeben "", Schlüssel werden mit einem Doppelpunkt : gekennzeichnet und dasTrennzeichen ist das Komma ,.

Unser Freund @teadrinker hat dankenswerterweise eine Funktion geschrieben, die die Beschreibung der JSON Objekte in AHK Objekte überführt. Damit lässt sich dann mit AHK-Objektsyntax auf die Schlüssel/Wert-Paare zugreifen. Hier folgt ein Beispiel, wie das aussehen könnte. Die eingelesene Datei enthält das HTML der von Dir vorgeschlagenen Seite:

Code: Select all

#NoEnv
SetBatchLines, -1
SetWorkingDir, %A_ScriptDir%
HTML_File := "IMDB_TEst.htm" ; "Aladin.htm"
FileRead, HTML, %HTML_File%
Doc := DocumentFromHTML(HTML)
VarSetCapacity(HTML, 0)

JSON := Doc.querySelector("script[type='application/ld+json']").innerText
AhkObj := JSON2AHK(JSON)
Keys := AhkObj.Count() . ":`n"
For Key, V In AhkObj
   Keys .= "`n" . Key . "   -> " . (IsObject(V) ? "Objekt" : "Wert")
MsgBox, 0, Keys der ersten Ebene, %Keys%
; ------------------------------------------------------------------------------
Actors := ""
For K, V In AhkObj["actor"]
   If (V["@type"] = "Person")
      Actors .= V["name"] . "`n"
Creators := ""
For K, V In AhkObj["creator"]
   If (V["@type"] = "Person")
      Creators .= V["name"] . "`n"
MsgBox, 0, Summary, Actors:`n%Actors%`nCreators:`n%Creators%
ExitApp


; ======================================================================================================================
; https://www.autohotkey.com/boards/viewtopic.php?p=350106#p350106 by Teadrinker, modified by just me
; ======================================================================================================================
DocumentFromHTML(HTML) {
   Local
   Doc := ComObjCreate("htmlfile")
   Doc.write("<meta http-equiv=""X-UA-Compatible"" content=""IE=9"">")
   Doc.write(HTML)
   Return Doc
}
; ======================================================================================================================
; Originally released by teadrinker -> https://www.autohotkey.com/boards/viewtopic.php?p=333543#p333543
; ======================================================================================================================
JSON2AHK(JSON, Recursive := False) {
   Local
   Static Doc := ComObjCreate("htmlfile")
        , __  := Doc.write("<meta http-equiv=""X-UA-Compatible"" content=""IE=9"">")
        , JS  := Doc.parentWindow
   If (!Recursive)
      Obj := JSON2AHK(JS.eval("(" . JSON . ")"), True)
   Else If !IsObject(JSON)
      Obj := JSON
   Else If (JSON.toString() != "[object Object]") {
      Obj := []
      Loop % JSON.length
         Obj.Push(JSON2AHK(JSON[A_Index - 1], True) )
   }
   Else {
      Obj := {}
      Keys := JS.Object.keys(JSON)
      Loop % Keys.length {
         K := Keys[A_Index - 1]
         Obj[K] := JSON2AHK(JSON[K], True)
      }
   }
   Return Obj
}
Ergebnisse:

Code: Select all

---------------------------
Keys der ersten Ebene
---------------------------
16:

@context   -> Wert
@type   -> Wert
actor   -> Objekt
aggregateRating   -> Objekt
contentRating   -> Wert
creator   -> Objekt
datePublished   -> Wert
description   -> Wert
director   -> Objekt
duration   -> Wert
genre   -> Objekt
image   -> Wert
keywords   -> Wert
name   -> Wert
review   -> Objekt
url   -> Wert
---------------------------
OK
---------------------------

---------------------------
Summary
---------------------------
Actors:
James D'Arcy
Roger Morlidge
Gabrielle Anwar
Vincent D'Onofrio

Creators:
Piers Ashworth
Arthur Conan Doyle

---------------------------
OK
---------------------------
garry
Posts: 3740
Joined: 22 Dec 2013, 12:50

Re: imdb datenbank auslesen

21 Mar 2021, 06:50

@just me danke
habe eine Frage wie man 'director' anzeigt , actor und creator stehen im Klammer [ ] , director steht nicht im Klammer

Code: Select all

;- imdb datenbank auslesen 
;- https://www.autohotkey.com/boards/viewtopic.php?p=389068#p389068

#Warn
#NoEnv
HTML_File:= "MyFairLady.htm"
F1=%a_scriptdir%\MyFairLady_htm-extract.txt
ifexist,%f1%
  filedelete,%f1%

SetBatchLines, -1
SetWorkingDir, %A_ScriptDir%
FileRead, HTML, %HTML_File%
Doc      := DocumentFromHTML(HTML)
VarSetCapacity(HTML, 0)
JSON     := Doc.querySelector("script[type='application/ld+json']").innerText
AhkObj   := JSON2AHK(JSON)
Keys     := AhkObj.Count() . ":`n"
For Key, V In AhkObj
   Keys  .= "`n" . Key . "   -> " . (IsObject(V) ? "Objekt" : "Wert")
; ------------------------------------------------------------------------------
Actors   := ""
For K, V In AhkObj["actor"]
   If (V["@type"] = "Person")
      Actors .= V["name"] . "`n"
Creators := ""
For K, V In AhkObj["creator"]
   If (V["@type"] = "Person")
      Creators .= V["name"] . "`n"
director := ""
For K, V In AhkObj["director"]
   If (V["@type"] = "Person")
      Director .= V["name"] . "`n"
;----------------------------------
Fileappend,Keys der ersten Ebene=`r`n %Keys%`r`n---------------`r`nActors=`r`n%Actors%`r`nCreators=`r`n%Creators%`r`nDirector=`r`n%director%`r`n,%f1%,utf-8
;MsgBox, 0, Summary, Actors:`n%Actors%`nCreators:`n%Creators%
ExitApp
; ======================================================================================================================
; https://www.autohotkey.com/boards/viewtopic.php?p=350106#p350106 by Teadrinker, modified by just me
; ======================================================================================================================
DocumentFromHTML(HTML) {
   Local
   Doc := ComObjCreate("htmlfile")
   Doc.write("<meta http-equiv=""X-UA-Compatible"" content=""IE=9"">")
   Doc.write(HTML)
   Return Doc
}
; ======================================================================================================================
; Originally released by teadrinker -> https://www.autohotkey.com/boards/viewtopic.php?p=333543#p333543
; ======================================================================================================================
JSON2AHK(JSON, Recursive := False) {
   Local
   Static Doc := ComObjCreate("htmlfile")
        , __  := Doc.write("<meta http-equiv=""X-UA-Compatible"" content=""IE=9"">")
        , JS  := Doc.parentWindow
   If (!Recursive)
      Obj := JSON2AHK(JS.eval("(" . JSON . ")"), True)
   Else If !IsObject(JSON)
      Obj := JSON
   Else If (JSON.toString() != "[object Object]") {
      Obj := []
      Loop % JSON.length
         Obj.Push(JSON2AHK(JSON[A_Index - 1], True) )
   }
   Else {
      Obj := {}
      Keys := JS.Object.keys(JSON)
      Loop % Keys.length {
         K := Keys[A_Index - 1]
         Obj[K] := JSON2AHK(JSON[K], True)
      }
   }
   Return Obj
}
;=========================================================================================
/*
  "contentRating": "G",
  "actor": [
    {
      "@type": "Person",
      "url": "/name/nm0000030/",
      "name": "Audrey Hepburn"
    },
    {
      "@type": "Person",
      "url": "/name/nm0001322/",
      "name": "Rex Harrison"
    },
    {
      "@type": "Person",
      "url": "/name/nm0391361/",
      "name": "Stanley Holloway"
    },
    {
      "@type": "Person",
      "url": "/name/nm0405035/",
      "name": "Wilfrid Hyde-White"
    }
  ],
;-----------------------------------------  
  "director": {
    "@type": "Person",
    "url": "/name/nm0002030/",
    "name": "George Cukor"
  },
;-----------------------------------------
  "creator": [
    {
      "@type": "Person",
      "url": "/name/nm0503585/",
      "name": "Alan Jay Lerner"
    },
    {
      "@type": "Person",
      "url": "/name/nm0789737/",
      "name": "George Bernard Shaw"
    },
    {
      "@type": "Person",
      "url": "/name/nm0503585/",
      "name": "Alan Jay Lerner"
    },
    {
      "@type": "Organization",
      "url": "/company/co0002663/"
    }
  ],
;----------------------------------------------
  "description": "My Fair Lady is a movie starring Audrey Hepburn, Rex Harrison, and Stanley Holloway. Snobbish phonetics Professor Henry Higgins agrees to a wager that he can make flower girl Eliza Doolittle presentable in high society.",
  "datePublished": "1964-12-01",
*/
just me
Posts: 9424
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: imdb datenbank auslesen

21 Mar 2021, 07:02

@garry:
Unter dem Schlüssel director verbirgt sich (zumindest im Beispiel) nur ein Objekt mit den Schlüsseln @type, url und name. Wenn man darauf vertraut und es so machen will wie bei actor:

Code: Select all

Director := ""
If AhkObj["director", "@type] = "Person"
	Director := AhkObj["director", "name"]
garry
Posts: 3740
Joined: 22 Dec 2013, 12:50

Re: imdb datenbank auslesen

21 Mar 2021, 08:36

@just me , vielen Dank

Code: Select all

Director := ""
If AhkObj["director", "@type"] = "Person"
	Director := AhkObj["director", "name"]
just me
Posts: 9424
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: imdb datenbank auslesen

21 Mar 2021, 08:43

@garry:
Ich nochmal, etwas für's Auge:

Code: Select all

#NoEnv
JSON =
(
{
  "@context": "http://schema.org",
  "@type": "Movie",
  "url": "/title/tt0337593/",
  "name": "Sherlock",
  "image": "https://m.media-amazon.com/images/M/MV5BZDJkNTRjNTYtNTEyYy00M2EwLWE3MGEtNWNiYWNjODdhZTk3XkEyXkFqcGdeQXVyMTk5MjAyMjM@._V1_.jpg",
  "genre": [
    "Action",
    "Adventure",
    "Crime",
    "Drama",
    "Mystery",
    "Thriller"
  ],
  "contentRating": "R",
  "actor": [
    {
      "@type": "Person",
      "url": "/name/nm0195439/",
      "name": "James D\u0027Arcy"
    },
    {
      "@type": "Person",
      "url": "/name/nm0605943/",
      "name": "Roger Morlidge"
    },
    {
      "@type": "Person",
      "url": "/name/nm0000270/",
      "name": "Gabrielle Anwar"
    },
    {
      "@type": "Person",
      "url": "/name/nm0000352/",
      "name": "Vincent D\u0027Onofrio"
    }
  ],
  "director": {
    "@type": "Person",
    "url": "/name/nm0857280/",
    "name": "Graham Theakston"
  },
  "creator": [
    {
      "@type": "Person",
      "url": "/name/nm0039328/",
      "name": "Piers Ashworth"
    },
    {
      "@type": "Person",
      "url": "/name/nm0236279/",
      "name": "Arthur Conan Doyle"
    },
    {
      "@type": "Organization",
      "url": "/company/co0489955/"
    },
    {
      "@type": "Organization",
      "url": "/company/co0073776/"
    },
    {
      "@type": "Organization",
      "url": "/company/co0020879/"
    },
    {
      "@type": "Organization",
      "url": "/company/co0086742/"
    },
    {
      "@type": "Organization",
      "url": "/company/co0086743/"
    },
    {
      "@type": "Organization",
      "url": "/company/co0006634/"
    },
    {
      "@type": "Organization",
      "url": "/company/co0014957/"
    }
  ],
  "description": "Sherlock is a TV movie starring James D\u0027Arcy, Roger Morlidge, and Gabrielle Anwar. Early in his crime-solving career, Sherlock Holmes attempts to prevent Moriarty from cornering the heroin market.",
  "datePublished": "2002-10-25",
  "keywords": "character name as title,serial murder,sherlock holmes character,professor moriarty character,dr. john watson character",
  "aggregateRating": {
    "@type": "AggregateRating",
    "ratingCount": 967,
    "bestRating": "10.0",
    "worstRating": "1.0",
    "ratingValue": "5.9"
  },
  "review": {
    "@type": "Review",
    "itemReviewed": {
      "@type": "CreativeWork",
      "url": "/title/tt0337593/"
    },
    "author": {
      "@type": "Person",
      "name": "RobinSisson"
    },
    "dateCreated": "2004-04-10",
    "inLanguage": "English",
    "name": "Just...bad",
    "reviewBody": "I saw this movie recently with the very greatest of hopes.\n\nI have been a Sherlock Holmes fan for as long as I can remember, so when I saw the box for this film on the shelves at my local video store, I yanked it up without even looking at the synopsis on the back. After watching the movie, I might have enjoyed the synopsis more...a LOT more.\n\n The characters were two-dimensional and under-developed at very best: no depth at all was brought to any one of them, but for the struggling Rebecca Doyle, portrayed by Gabrielle Anwar...and in this setting, finding anything to like about her was a struggle. James D\u0027Arcy never even saw the mark in attempting to bring humanity to the legendary Holmes; he just came off weak and vacillating in D\u0027Arcy\u0027s hands. Vincent D\u0027Onofrio - of whom I am an incredible fan normally, and who is notoriously known as \"the Human Chameleon\" for his most uncanny ability to lose himself in a role - just phoned this performance in, when I\u0027d have loved to have seen a far more layered interpretation of this legendary bad guy. Roger Morlidge does a serviceable job of Dr. Watson, but it\u0027s just not enough.\n\nThe plot was presumptuous of far too much detail relevant to the Holmes legend to introduce such intricacies as the reasoning behind the heroin addiction suffered by he and his brother, without providing much substantive sub-plot to make it plausible...or even make us care.\n\nThe fencing battles between Holmes and Moriarty are well-executed, but only consume a cumulative twenty minutes of the film at the very most.\n\n Writer Piers Ashworth didn\u0027t think outside the box in his creation of this \"new perspective\", he just created a new box and hopped right in. Director Graham Theakston didn\u0027t seem to even attempt to transcend the poor scripting with crafty, smart, or inspiring visuals.\n\nI just didn\u0027t get it."
  },
  "duration": "PT1H40M"
}
)
AHKO := JSON2AHK(JSON)
Gui, Add, TreeView, w1000 r40 vTV
Obj2Tree(AHKO)
Gui, Show, , ObjektTree
Return
ExitApp
GuiClose:
ExitApp
; ======================================================================================================================
Obj2Tree(Obj, Parent := 0) {
   For K, V In Obj {
      If IsObject(V)
         Obj2Tree(V, TV_Add(K, Parent, "Expand"))
      Else
         TV_Add(V, TV_Add(K, Parent, "Expand"))
   }
}
; ======================================================================================================================
; Originally released by teadrinker -> https://www.autohotkey.com/boards/viewtopic.php?p=333543#p333543
; ======================================================================================================================
JSON2AHK(JSON, Recursive := False) {
   Local
   Static Doc := ComObjCreate("htmlfile")
        , __  := Doc.write("<meta http-equiv=""X-UA-Compatible"" content=""IE=9"">")
        , JS  := Doc.parentWindow
   If (!Recursive)
      Obj := JSON2AHK(JS.eval("(" . JSON . ")"), True)
   Else If !IsObject(JSON)
      Obj := JSON
   Else If (JSON.toString() != "[object Object]") {
      Obj := []
      Loop % JSON.length
         Obj.Push(JSON2AHK(JSON[A_Index - 1], True) )
   }
   Else {
      Obj := {}
      Keys := JS.Object.keys(JSON)
      Loop % Keys.length {
         K := Keys[A_Index - 1]
         Obj[K] := JSON2AHK(JSON[K], True)
      }
   }
   Return Obj
}
garry
Posts: 3740
Joined: 22 Dec 2013, 12:50

Re: imdb datenbank auslesen

21 Mar 2021, 09:51

@just me , vielen Dank für's TreeView / Json2Ahk Beispiel und hiermit danke auch für die professioniellen Skripts für ListView
just me
Posts: 9424
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: imdb datenbank auslesen

21 Mar 2021, 10:18

@garry, nichts zu danken. Es war mir ein Vergnügen. Bleib gesund!
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: imdb datenbank auslesen

21 Mar 2021, 12:08

Macht mich schlau - geht es hier nun um die Herausforderung die Datenquelle zu beherrschen (weil man/frau die IMDB nicht via kostenpflichtiger API bemühen möchte)?? :think:

BTW, scheint imdb auch etwas 'picky' wenn’s um den Zugang geht ...
"Robots and Screen Scraping: You may not use data mining, robots, screen scraping, or similar data gathering and extraction tools on this site, except with our express written consent as noted below" :shh: :silent:

Ich frage lediglich interessehalber, weil der von mir vorab gezeigte Ansatz via Open Movie Data Base (omdb) ja ebenfalls die angesprochenen Details im JSON-Format liefert (unter anderem auch die imdbID). Der API-Zugang ist kostenlos. Es gibt 3 Suchoptionen a) per imdbID, b) per titel (ein/erster treffer), c) per titel (alle treffer).

http://www.omdbapi.com
AHK omdb-Abfrage

BTW, wer sich bei RapidAPI registriert (um einen API-key zu erhalten) kann 500 (?) Abfragen pro Tag auch direkt auf der imdb-API (?) vornehmen.
https://rapidapi.com/search/imdb

AHK imdb-Abfrage (via RapidAPI)

Anderweitige Fundstücke:
https://developers.themoviedb.org/3/getting-started/introduction
https://datasets.imdbws.com/
https://developer.imdb.com/documentation/developer.imdb.pdf
just me
Posts: 9424
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: imdb datenbank auslesen

22 Mar 2021, 05:35

Moin @BoBo,

in diesem Beitrag geht es primär um das Auswerten von Informationen, die von der imdb heruntergeladen werden. Ein funktionierendes Grundgerüst existiert, es sollen aber nach Möglichkeit weitere Informationen abgegriffen werden.

Wenn Du Alternativen zur imdb siehst, kann allein effel entscheiden, ob ihm das besser gefällt. Bisher kommt er anscheinend ohne jegliche Registrierung an die Werte.

Return to “Ich brauche Hilfe”

Who is online

Users browsing this forum: No registered users and 35 guests