Hi!
Ich bin neu in diesem Forum, und hab gleich eine Frage:
Ich schreibe gerade für mich privat ein Youtube client.
Dafür habe ich mir aus dem Internet ein paar UDF's besorgt. Bei ein paar funktioniert das mit objekten, aber dort kenn ich mich nicht sonderlich aus, da ich noch kein tutorial dazu gefunden habe.
Nun zu meinem problem:
Hier erst einmal die Programm-Codes.
Vor ab, der unten genannter Fehler tritt auch auf wenn ich das aus der orginal datei nähmlich:
youtubeAPI.au3
include, und es tritt auch auf wenn die Funktionen am ende des Skriptes stehen.
Hier also der Code von youtube client.au3:
Spoiler anzeigen
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <IE.au3>
#include "YouTubeAPI.au3"
#include <INet.au3>
Global $oCollection
Func _Youtube_Read($iID)
$sSource = _INetGetSource('http://youtube.com/watch?v='&$iID)
[/autoit] [autoit][/autoit] [autoit]Return $sSource
[/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit] [autoit][/autoit] [autoit]Func _Youtube_Create($iX, $iY, $iWidth=$YT_DEFAULTWIDTH, $iHeight=$YT_DEFAULTHEIGHT)
[/autoit] [autoit][/autoit] [autoit]Local $aReturn[2]
[/autoit] [autoit][/autoit] [autoit]$oIE = _IECreateEmbedded()
$hObj = GUICtrlCreateObj($oIE, $iX, $iY, $iWidth, $iHeight)
_IENavigate ($oIE, "about:blank", 0)
_IEDocWriteHTML($oIE, '<body bgcolor="Black"></body>')
$aReturn[0] = $oIE
$aReturn[1] = $hObj
Return $aReturn
[/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit] [autoit][/autoit] [autoit]Func _Youtube_Load($aPlayerControl, $sPlayer, $iAutoPlay=True)
[/autoit] [autoit][/autoit] [autoit]If $iAutoPlay Then
$sURL = _Youtube_GetPlayerLink($sPlayer)
Else
$sURL = _Youtube_GetEmbedLink($sPlayer)
EndIf
_IENavigate ($aPlayerControl[0], $sURL, 0)
[/autoit] [autoit][/autoit] [autoit]Return 1
[/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit] [autoit][/autoit] [autoit]Func _Youtube_Stop($aPlayerControl)
[/autoit] [autoit][/autoit] [autoit]_IENavigate ($aPlayerControl[0], "about:blank", 0)
_IEDocWriteHTML($aPlayerControl[0], '<body bgcolor="Black"></body>')
EndFunc
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Func YouTube_GetTitle($hVideo)
Return $hVideo.Eval("video.entry.media$group.media$title.$t")
EndFunc
$oIE = _IECreateEmbedded()
$formMain = GUICreate("YouTube Client", 418, 466, 192, 164)
$oFlash = ObjCreate("ShockwaveFlash.ShockwaveFlash.11")
$objPlayer = GUICtrlCreateObj($oFlash, 8, 40, 489, 393)
$inpWord = GUICtrlCreateInput("test", 8, 8, 321, 21)
GUICtrlSetState($inpWord, $GUI_FOCUS) ; Der Fokus ist auf diesem Element
$btnSearch = GUICtrlCreateButton("Suche", 330, 7, 81, 23)
$lswResults = GUICtrlCreateListView("Titel | Länge", 8, 32, 401, 393)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 320)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 60)
$btnPlay = GUICtrlCreateButton("Wiedergabe", 8, 432, 401, 25)
Dim $aItems[200]
Dim $aVID[20]
GUISetState(@SW_SHOW)
[/autoit] [autoit][/autoit] [autoit]While True
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $btnSearch
For $i = 0 To 19
GUICtrlDelete($aItems[$i])
Next
$oCollection = YouTube_SearchVideos(GUICtrlRead($inpWord), 20, 1, $YT_BY_VIEWS, $YT_LANG_GERMAN)
For $i = 0 To YouTube_GetVideosCount($oCollection) - 1
YouTube_SelectIndex($oCollection, $i)
$aItems[$i] = GUICtrlCreateListViewItem(StringReplace(YouTube_GetTitle($oCollection), "|", "") & "|" & ToMinutes(YouTube_GetDuration($oCollection)), $lswResults)
$aVID[$i] = YouTube_GetVID($oCollection) ;
Next
Case $btnPlay
For $i = 0 To 199
If GUICtrlRead($lswResults) = $aItems[$i] Then ExitLoop
Next
$vidio_title = YouTube_GetTitle($oCollection)
$form_player = GUICreate($vidio_title, 600, 600, 100, 200)
YouTube_SelectIndex($oCollection, $i) ; Wählt das aktive Objekt in der Sammlung
$vidio_id = YouTube_GetVID($oCollection)
$a_youtubeplayer = _Youtube_Create(120, 220)
GUISetState(@SW_SHOW)
$vidio_load_process = _Youtube_Load($a_youtubeplayer, $youtube_source)
GUICtrlSetState($a_youtubeplayer, $GUI_FOCUS) ; Der Fokus ist auf diesem Button
While True
$nMsg1 = GUIGetMsg()
Switch $nMsg1
Case $GUI_EVENT_CLOSE
_Youtube_Stop($a_youtubeplayer)
GUIDelete()
EndSwitch
WEnd
EndSwitch
WEnd
Das ist der Code von dem Client.
Hier jetzt der Code von YoutubeAPI.au3:
Spoiler anzeigen
; #INCLUDE# ====================================================================================================================
; Name ..........: YouTubeAPI
; Author ........: PunisherAxe
; Version .......: 1.2
; ===============================================================================================================================
Global Const $YT_BY_RELEVANCE = "relevance"
Global Const $YT_BY_VIEWS = "viewCount"
Global Const $YT_BY_PUBLISHED = "published"
Global Const $YT_BY_RATING = "rating"
Global Const $YT_TIME_HOUR = "hour"
Global Const $YT_TIME_TODAY = "today"
Global Const $YT_TIME_WEEK = "this_week"
Global Const $YT_TIME_MONTH = "this_month"
Global Const $YT_TIME_YEAR = "year"
Global Const $YT_TIME_ALL = "time_all"
Global Const $YT_LANG_POLISH = "pl"
Global Const $YT_LANG_ENGLISH = "en"
Global Const $YT_LANG_GERMAN = "de"
Global Const $YT_DURATION_SHORT = "short"
Global Const $YT_DURATION_MEDIUM = "medium"
Global Const $YT_DURATION_LONG = "long"
Global Const $YT_CAPTION_TRUE = True
Global Const $YT_CAPTION_FALSE = False
Global Const $YT_HD_TRUE = True
Global Const $YT_HD_FALSE = False
Func YouTube_GetVIDFromURL($sWatch)
Local $aResults = StringRegExp($sWatch, "(|\?|&)v=([\w|\-]+)", 3)
If Not IsArray($aResults) Then Return SetError(1, 0, 0)
Return $aResults[1]
EndFunc ;==>YouTube_GetVIDFromURL
Func YouTube_GetVideo($sVID)
Local $sResults, $sURL, $oVideo, $oHTTP
$sURL = "http://gdata.youtube.com/feeds/api/videos/" & $sVID & "?v=2&alt=json"
$oVideo = ObjCreate("ScriptControl")
$oVideo.language = "JScript"
$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("GET", $sURL)
;$oHTTP.SetRequestHeader("Content-Type", "application/json; charset=utf-8")
$oHTTP.Send()
$oHTTP.WaitForResponse()
$sResults = $oHTTP.ResponseText
$oVideo.Eval("var video = (" & $sResults & ");")
If StringLeft($sResults, 6) == "<error" Then Return SetError(1, 0, 0)
Return $oVideo
EndFunc ;==>YouTube_GetVideo
Func YouTube_SearchVideos($sQuestion, $iMaxResults = 10, $iStartIndex = 1, $sOrderBy = $YT_BY_RELEVANCE, $sLang = "", $sCategory = "", $sAuthor = "", $sDuration = "", $sTime = "", $bHD = "", $bCaption = "")
Local $sResults, $sURL, $oVideo, $oHTTP
If $sLang <> "" Then $sLang = "&lr=" & $sLang
If $sCategory <> "" Then $sCategory = "&category=" & $sCategory
If $sAuthor <> "" Then $sAuthor = "&author=" & $sAuthor
If $sDuration <> "" Then $sDuration = "&duration=" & $sDuration
If $sTime <> "" Then $sTime = "&time=" & $sTime
If $bHD <> "" Then
If $bHD = True Then
$bHD = "&hd=true"
Else
$bHD = "&hd=false"
EndIf
EndIf
If $bCaption <> "" Then
If $bCaption = True Then
$bCaption = "&caption"
Else
$bCaption = ""
EndIf
EndIf
$sURL = "https://gdata.youtube.com/feeds/api/videos?q=" & $sQuestion & "&orderby=" & $sOrderBy & "&start-index=" & $iStartIndex & "&max-results=" & $iMaxResults & $bHD & $sDuration & $sAuthor & $sCategory & $sTime & "&v=2&alt=json"
$oVideo = ObjCreate("ScriptControl")
$oVideo.language = "JScript"
$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("GET", $sURL)
$oHTTP.Send()
$oHTTP.WaitForResponse()
$sResults = $oHTTP.ResponseText
$oVideo.Eval("var collection = (" & $sResults & ");")
If StringLeft($sResults, 6) == "<error" Then Return SetError(1, 0, 0)
Return $oVideo
EndFunc ;==>YouTube_SearchVideos
Func YouTube_SelectIndex(ByRef $oCollection, $iIndex = 0)
$oCollection.Eval('var video = {"entry" : collection.feed.entry[' & $iIndex & ']};')
EndFunc ;==>YouTube_SelectIndex
Func YouTube_GetVideosCount($oCollection)
Return $oCollection.Eval("collection.feed.entry.length")
EndFunc ;==>YouTube_GetVideosCount
Func YouTube_GetLikes($hVideo)
Return $hVideo.Eval("video.entry.yt$rating.numLikes")
EndFunc ;==>YouTube_GetLikes
Func YouTube_GetDislikes($hVideo)
Return $hVideo.Eval("video.entry.yt$rating.numDislikes")
EndFunc ;==>YouTube_GetDislikes
Func YouTube_GetViews($hVideo)
Return $hVideo.Eval("video.entry.yt$statistics.viewCount")
EndFunc ;==>YouTube_GetViews
Func YouTube_GetRaters($hVideo)
Return $hVideo.Eval("video.entry.gd$rating.numRaters")
EndFunc ;==>YouTube_GetRaters
Func YouTube_GetAverageRating($hVideo)
Return $hVideo.Eval("video.entry.gd$rating.average")
EndFunc ;==>YouTube_GetAverageRating
Func YouTube_GetMaxRating($hVideo)
Return $hVideo.Eval("video.entry.gd$rating.max")
EndFunc ;==>YouTube_GetMaxRating
Func YouTube_GetMinRating($hVideo)
Return $hVideo.Eval("video.entry.gd$rating.min")
EndFunc ;==>YouTube_GetMinRating
Func YouTube_GetCategory($hVideo, $iIndex = 0)
Return $hVideo.Eval("video.entry.media$group.media$category[" & $iIndex & "].$t")
EndFunc ;==>YouTube_GetCategory
Func YouTube_GetDuration($hVideo)
Return $hVideo.Eval("video.entry.media$group.yt$duration.seconds")
EndFunc ;==>YouTube_GetDuration
Func YouTube_GetUploaded($hVideo)
Return StringReplace(StringTrimRight($hVideo.Eval("video.entry.media$group.yt$uploaded.$t"), 5), "T", " ")
EndFunc ;==>YouTube_GetUploaded
Func YouTube_GetPublished($hVideo)
Return StringReplace(StringTrimRight($hVideo.Eval("video.entry.published.$t"), 5), "T", " ")
EndFunc ;==>YouTube_GetPublished
Func YouTube_GetUpdated($hVideo)
Return StringReplace(StringTrimRight($hVideo.Eval("video.entry.updated.$t"), 5), "T", " ")
EndFunc ;==>YouTube_GetUpdated
Func YouTube_GetUploaderID($hVideo)
Return $hVideo.Eval("video.entry.media$group.yt$uploaderId.$t")
EndFunc ;==>YouTube_GetUploaderID
Func YouTube_GetAspectRatio($hVideo)
Return $hVideo.Eval("video.entry.media$group.yt$aspectRatio.$t")
EndFunc ;==>YouTube_GetAspectRatio
Func YouTube_GetDescription($hVideo)
Return $hVideo.Eval("video.entry.media$group.media$description.$t")
EndFunc ;==>YouTube_GetDescription
Func YouTube_GetAuthorName($hVideo, $iIndex = 0)
Return $hVideo.Eval("video.entry.author[" & $iIndex & "].name.$t")
EndFunc ;==>YouTube_GetAuthorName
Func YouTube_GetAuthorURI($hVideo, $iIndex = 0)
Return $hVideo.Eval("video.entry.author[" & $iIndex & "].uri.$t")
EndFunc ;==>YouTube_GetAuthorURI
Func YouTube_GetAuthorID($hVideo, $iIndex = 0)
Return $hVideo.Eval("video.entry.author[" & $iIndex & "].yt$userId.$t")
EndFunc ;==>YouTube_GetAuthorID
Func YouTube_GetThumbDefault($hVideo)
Return YouTube_GetThumbByName($hVideo, "default")
EndFunc ;==>YouTube_GetThumbDefault
Func YouTube_GetThumbMQDefault($hVideo)
Return YouTube_GetThumbByName($hVideo, "mqdefault")
EndFunc ;==>YouTube_GetThumbMQDefault
Func YouTube_GetThumbHQDefault($hVideo)
Return YouTube_GetThumbByName($hVideo, "hqdefault")
EndFunc ;==>YouTube_GetThumbHQDefault
Func YouTube_GetThumbSDDefault($hVideo)
Return YouTube_GetThumbByName($hVideo, "sddefault")
EndFunc ;==>YouTube_GetThumbSDDefault
Func YouTube_GetThumbStart($hVideo)
Return YouTube_GetThumbByName($hVideo, "start")
EndFunc ;==>YouTube_GetThumbStart
Func YouTube_GetThumbMiddle($hVideo)
Return YouTube_GetThumbByName($hVideo, "middle")
EndFunc ;==>YouTube_GetThumbMiddle
Func YouTube_GetThumbEnd($hVideo)
Return YouTube_GetThumbByName($hVideo, "end")
EndFunc ;==>YouTube_GetThumbEnd
Func YouTube_GetThumbByName($hVideo, $sName)
Local $iLength = $hVideo.Eval("video.entry.media$group.media$thumbnail.length") - 1
For $i = 0 To $iLength
$sYtName = $hVideo.Eval("video.entry.media$group.media$thumbnail[" & $i & "].yt$name")
If $sYtName = $sName Then ExitLoop
Next
If $i > $iLength Then Return SetError(1, 0, 0)
Return $hVideo.Eval("video.entry.media$group.media$thumbnail[" & $i & "].url")
EndFunc ;==>YouTube_GetThumbByName
Func YouTube_GetContentFlash($hVideo)
Return YouTube_GetContentByIndex($hVideo, 0)
EndFunc ;==>YouTube_GetContentFlash
Func YouTube_GetContentRTSP1($hVideo)
Return YouTube_GetContentByIndex($hVideo, 1)
EndFunc ;==>YouTube_GetContentRTSP1
Func YouTube_GetContentRTSP6($hVideo)
Return YouTube_GetContentByIndex($hVideo, 2)
EndFunc ;==>YouTube_GetContentRTSP6
Func YouTube_GetContentByIndex($hVideo, $iIndex)
Return $hVideo.Eval("video.entry.media$group.media$content[" & $iIndex & "].url")
EndFunc ;==>YouTube_GetContentByIndex
Func YouTube_GetCommentCount($hVideo)
Return $hVideo.Eval("video.entry.gd$comments.gd$feedLink.countHint")
EndFunc ;==>YouTube_GetCommentCount
Func YouTube_GetVID($hVideo)
Return $hVideo.Eval("video.entry.media$group.yt$videoid.$t")
EndFunc ;==>YouTube_GetVID
Und zuletzt der Code von Youtube.au3:
Spoiler anzeigen
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.2.13.3 (beta)
Author: myName
Script Function:
Template AutoIt script.
#ce ----------------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit]; Script Start - Add your code below here
[/autoit] [autoit][/autoit] [autoit]#cs
[/autoit] [autoit][/autoit] [autoit]Functions:
[/autoit] [autoit][/autoit] [autoit]_Youtube_Read($iID)
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]_Youtube_GetID($sPlayer)
_Youtube_GetTitle($sPlayer)
_Youtube_GetDescription($sPlayer)
_Youtube_GetKeywords($sPlayer)
_Youtube_GetEmbedLink($sPlayer)
_Youtube_GetPlayerLink($sPlayer)
_Youtube_GetPlayerSwf($sPlayer)
_Youtube_Create($iX, $iY, $iWidth=$YT_DEFAULTWIDTH, $iHeight=$YT_DEFAULTHEIGHT)
_Youtube_Load($aPlayerControl, $sPlayer, $iAutoPlay=True)
_Youtube_Stop($aPlayerControl)
#CE
[/autoit] [autoit][/autoit] [autoit]#include-once
#include <INet.au3>
#include <IE.au3>
Global Const $YT_DEFAULTWIDTH = 425
Global Const $YT_DEFAULTHEIGHT = 344
; Downloads the source of the Youtube page
; $iID = Video ID (example: "sNzEQ8hG1zA")
Func _Youtube_Read($iID)
$sSource = _INetGetSource('http://youtube.com/watch?v='&$iID)
Return $sSource
EndFunc
; Creates a embedded IE control for playing Youtube movies
; $iX, $iY, $iWidth, $iHeight = Coordinates of the control
Func _Youtube_Create($iX, $iY, $iWidth=$YT_DEFAULTWIDTH, $iHeight=$YT_DEFAULTHEIGHT)
Local $aReturn[2]
$oIE = _IECreateEmbedded()
$hObj = GUICtrlCreateObj($oIE, $iX, $iY, $iWidth, $iHeight)
_IENavigate ($oIE, "about:blank", 0)
_IEDocWriteHTML($oIE, '<body bgcolor="Black"></body>')
$aReturn[0] = $oIE
$aReturn[1] = $hObj
Return $aReturn
EndFunc
; Loads a movie into a player control.
; $aPlayerControl = A player control (return value of _Youtube_Create)
; $sPlayer = A movie (return value of _Youtube_Read)
; [$iAutoPlay] = Automaticly starts playing the movie if True.
Func _Youtube_Load($aPlayerControl, $sPlayer, $iAutoPlay=True)
If $iAutoPlay Then
$sURL = _Youtube_GetPlayerLink($sPlayer)
Else
$sURL = _Youtube_GetEmbedLink($sPlayer)
EndIf
_IENavigate ($aPlayerControl[0], $sURL, 0)
Return 1
EndFunc
; Stops playing a movie
; $aPlayerControl = Player control (return value of _Youtube_Create)
Func _Youtube_Stop($aPlayerControl)
_IENavigate ($aPlayerControl[0], "about:blank", 0)
_IEDocWriteHTML($aPlayerControl[0], '<body bgcolor="Black"></body>')
EndFunc
Func _Youtube_GetKeywords($sPlayer)
$sSource = $sPlayer
$iPlayerLinkStart = StringInStr($sSource,'<meta name="keywords" content=')
If Not $iPlayerLinkStart Then Return ""
$sBeforePlayerLink = StringLeft($sSource,$iPlayerLinkStart+StringLen('<meta name="keywords" content=')-1)
If Not $sBeforePlayerLink Then Return ""
$aSplit = StringSplit($sBeforePlayerLink,@CRLF)
$iPlayerLinkLine = $aSplit[0]
If Not $iPlayerLinkLine Then Return ""
$aSourceSplit = StringSplit($sSource,@CRLF)
If $iPlayerLinkLine > $aSourceSplit[0] Then Return ""
$sPlayerLinkLine = $aSourceSplit[$iPlayerLinkLine]
$iPlayerLinkStart = StringInStr($sPlayerLinkLine,'<meta name="keywords" content=')
$sAfterPlayerLink = StringTrimLeft($sPlayerLinkLine,$iPlayerLinkStart+StringLen('<meta name="keywords" content=')-1)
$sAfterPlayerLink = StringTrimRight($sAfterPlayerLink,2)
$sAfterPlayerLink = StringTrimLeft($sAfterPlayerLink,1)
Return $sAfterPlayerLink
EndFunc
Func _Youtube_GetEmbedLink($sPlayer)
$sSource = $sPlayer
$iPlayerLinkStart = StringInStr($sSource,"var embedUrl = ")
If Not $iPlayerLinkStart Then Return ""
$sBeforePlayerLink = StringLeft($sSource,$iPlayerLinkStart+StringLen("var embedUrl = ")-1)
If Not $sBeforePlayerLink Then Return ""
$aSplit = StringSplit($sBeforePlayerLink,@CRLF)
$iPlayerLinkLine = $aSplit[0]
If Not $iPlayerLinkLine Then Return ""
$aSourceSplit = StringSplit($sSource,@CRLF)
If $iPlayerLinkLine > $aSourceSplit[0] Then Return ""
$sPlayerLinkLine = $aSourceSplit[$iPlayerLinkLine]
$iPlayerLinkStart = StringInStr($sPlayerLinkLine,"var embedUrl = ")
$sAfterPlayerLink = StringTrimLeft($sPlayerLinkLine,$iPlayerLinkStart+StringLen("var embedUrl = ")-1)
$sAfterPlayerLink = StringReplace($sAfterPlayerLink,";","")
$sAfterPlayerLink = StringReplace($sAfterPlayerLink,"'","")
Return $sAfterPlayerLink
EndFunc
Func _Youtube_GetID($sPlayer)
$sSource = $sPlayer
$iPlayerLinkStart = StringInStr($sSource,"var pageVideoId = ")
If Not $iPlayerLinkStart Then Return ""
$sBeforePlayerLink = StringLeft($sSource,$iPlayerLinkStart+StringLen("var pageVideoId = ")-1)
If Not $sBeforePlayerLink Then Return ""
$aSplit = StringSplit($sBeforePlayerLink,@CRLF)
$iPlayerLinkLine = $aSplit[0]
If Not $iPlayerLinkLine Then Return ""
$aSourceSplit = StringSplit($sSource,@CRLF)
If $iPlayerLinkLine > $aSourceSplit[0] Then Return ""
$sPlayerLinkLine = $aSourceSplit[$iPlayerLinkLine]
$iPlayerLinkStart = StringInStr($sPlayerLinkLine,"var pageVideoId = ")
$sAfterPlayerLink = StringTrimLeft($sPlayerLinkLine,$iPlayerLinkStart+StringLen("var pageVideoId = ")-1)
$sAfterPlayerLink = StringReplace($sAfterPlayerLink,";","")
$sAfterPlayerLink = StringReplace($sAfterPlayerLink,"'","")
Return $sAfterPlayerLink
EndFunc
Func _Youtube_GetDescription($sPlayer)
$sSource = $sPlayer
$iPlayerLinkStart = StringInStr($sSource,'<meta name="description" content=')
If Not $iPlayerLinkStart Then Return ""
$sBeforePlayerLink = StringLeft($sSource,$iPlayerLinkStart+StringLen('<meta name="description" content=')-1)
If Not $sBeforePlayerLink Then Return ""
$aSplit = StringSplit($sBeforePlayerLink,@CRLF)
$iPlayerLinkLine = $aSplit[0]
If Not $iPlayerLinkLine Then Return ""
$aSourceSplit = StringSplit($sSource,@CRLF)
If $iPlayerLinkLine > $aSourceSplit[0] Then Return ""
$sPlayerLinkLine = $aSourceSplit[$iPlayerLinkLine]
$iPlayerLinkStart = StringInStr($sPlayerLinkLine,'<meta name="description" content=')
$sAfterPlayerLink = StringTrimLeft($sPlayerLinkLine,$iPlayerLinkStart+StringLen('<meta name="description" content=')-1)
$sAfterPlayerLink = StringTrimRight($sAfterPlayerLink,2)
$sAfterPlayerLink = StringTrimLeft($sAfterPlayerLink,1)
Return $sAfterPlayerLink
EndFunc
Func _Youtube_GetTitle($sPlayer)
$sSource = $sPlayer
$iPlayerLinkStart = StringInStr($sSource,'<meta name="title" content=')
If Not $iPlayerLinkStart Then Return ""
$sBeforePlayerLink = StringLeft($sSource,$iPlayerLinkStart+StringLen('<meta name="title" content=')-1)
If Not $sBeforePlayerLink Then Return ""
$aSplit = StringSplit($sBeforePlayerLink,@CRLF)
$iPlayerLinkLine = $aSplit[0]
If Not $iPlayerLinkLine Then Return ""
$aSourceSplit = StringSplit($sSource,@CRLF)
If $iPlayerLinkLine > $aSourceSplit[0] Then Return ""
$sPlayerLinkLine = $aSourceSplit[$iPlayerLinkLine]
$iPlayerLinkStart = StringInStr($sPlayerLinkLine,'<meta name="title" content=')
$sAfterPlayerLink = StringTrimLeft($sPlayerLinkLine,$iPlayerLinkStart+StringLen('<meta name="title" content=')-1)
$sAfterPlayerLink = StringTrimRight($sAfterPlayerLink,2)
$sAfterPlayerLink = StringTrimLeft($sAfterPlayerLink,1)
Return $sAfterPlayerLink
EndFunc
Func _Youtube_GetPlayerLink($sPlayer)
$sSWF = _Youtube_GetPlayerSwf($sPlayer)
If Not $sSWF Then Return ""
$sSource = $sPlayer
$iPlayerLinkStart = StringInStr($sSource,"var swfArgs = {")
If Not $iPlayerLinkStart Then Return ""
$sBeforePlayerLink = StringLeft($sSource,$iPlayerLinkStart+StringLen("var swfArgs = {")-1)
If Not $sBeforePlayerLink Then Return ""
$aSplit = StringSplit($sBeforePlayerLink,@CRLF)
$iPlayerLinkLine = $aSplit[0]
If Not $iPlayerLinkLine Then Return ""
$aSourceSplit = StringSplit($sSource,@CRLF)
If $iPlayerLinkLine > $aSourceSplit[0] Then Return ""
$sPlayerLinkLine = $aSourceSplit[$iPlayerLinkLine]
$iPlayerLinkStart = StringInStr($sPlayerLinkLine,"var swfArgs = {")
$sAfterPlayerLink = StringTrimLeft($sPlayerLinkLine,$iPlayerLinkStart+StringLen("var swfArgs = {")-1)
$sAfterPlayerLink = StringReplace($sAfterPlayerLink,"};","")
$sAfterPlayerLink = StringReplace($sAfterPlayerLink,'"',"")
$sAfterPlayerLink = StringReplace($sAfterPlayerLink,": ","=")
$sAfterPlayerLink = StringReplace($sAfterPlayerLink,", ","&")
;$sAfterPlayerLink = StringReplace($sAfterPlayerLink,"null","0")
Return $sSWF&"?"&$sAfterPlayerLink
EndFunc
Func _Youtube_GetPlayerSwf($sPlayer)
$sSource = $sPlayer
$iPlayerLinkStart = StringInStr($sSource,"var swfUrl = ")
If Not $iPlayerLinkStart Then Return ""
$sBeforePlayerLink = StringLeft($sSource,$iPlayerLinkStart+StringLen("var swfUrl = canPlayV9Swf() ? ")-1)
If Not $sBeforePlayerLink Then Return ""
$aSplit = StringSplit($sBeforePlayerLink,@CRLF)
$iPlayerLinkLine = $aSplit[0]
If Not $iPlayerLinkLine Then Return ""
$aSourceSplit = StringSplit($sSource,@CRLF)
If $iPlayerLinkLine > $aSourceSplit[0] Then Return ""
$sPlayerLinkLine = $aSourceSplit[$iPlayerLinkLine]
$iPlayerLinkStart = StringInStr($sPlayerLinkLine,"var swfUrl = ")
$sAfterPlayerLink = StringTrimLeft($sPlayerLinkLine,$iPlayerLinkStart+StringLen("var swfUrl = canPlayV9Swf() ? ")-1)
$sAfterPlayerLink = StringReplace($sAfterPlayerLink,"'","")
$aSplit = StringSplit($sAfterPlayerLink," ")
Return $aSplit[1]
EndFunc
(Die Dateien YoutubeAPI.au3 und Youtube.au3 liegen noch im Anhang).
Wenn man jetzt youtube client.au3 startet und auf Suchen klickt kommt folgendes:
Line 55
(File "X:\Programmierung\Projekte\AutoIt\Youtube client\Youtube client.au3"):
Func YouTube_GetTitle($hVideo)
Func YouTube_GetTitle($hVideo)^
ERROR: Unknown function name.
Ich verstehe das nicht, warum
"ERROR: Unknown function name."
Das ist mir rätselhaft, da doch genau dort die Funktion definiert wird.
Wahrscheinlich ist die lösung sehr leicht, aber ich suche schon eine ganze weile nach dem problem.
Kann mir hier jemand weiter helfen und mir auch vllt. ein tutorial nennen zur OOp mit autoit?
Nur das keine unklarheiten entstehen:
YoutubeAPI.au3
ist aus einem polnischen forum und ich hab mich sehr an dem beispiel orentiert, was mit geliefert wurde.
Die anderen Funktionen sind aus
Youtube.au3, die hab ich glaub ich aus diesem Forum.
Falls mir jemand weiter helfen kann, währe das sehr schön.
Ich habe Scite und Autoit in der aktuellsten stabielen version und windows xp noch auf meinem rechner.
(32 bit)
Vielen dank in vorraus.
Lg. Chris.
p.s. sorry für die formatierung, bei mir wird das ein bisschen merkwürdig angezeigt.