Some loop

Hello there…

Working on a tiny application that searches youtube for infomation, but im a bit stuck


set searchUrl to "http://www.youtube.com/results?search_query=comedy+fightclub"

try
	set searchResult to do shell script "curl  " & "" & searchUrl & " | grep -i \"i.ytimg.com\""
end try

set video_Title to parseCurlData(searchResult, "title=\"", "\" alt")
set video_Url to parseCurlData(searchResult, "<img src=\"http://i.ytimg.com/vi/", "/default.jpg\" class=\"vimg120\" title=\"")
set video_Poster to "http://i.ytimg.com/vi/" & video_Url & "/default.jpg"
display dialog video_Title & " " & video_Url & " " & video_Poster

to parseCurlData(SearchText, startText, endText)
	set tid to AppleScript's text item delimiters
	set AppleScript's text item delimiters to startText
	set endItems to text of text item -1 of SearchText
	set AppleScript's text item delimiters to endText
	set beginningToEnd to text of text item 1 of endItems
	set AppleScript's text item delimiters to tid
	return beginningToEnd
end parseCurlData

all this is working fine, but im only getting the last line of info, i need to put it all i a list or something,
i need infomation from ALL the lines, pt the dialog only shows the last line, and i just dont know how
to get this to list the all…

any help would be great…

something like this?



set searchUrl to "http://www.youtube.com/results?search_query=comedy+fightclub"

try
	set searchResult to paragraphs of (do shell script "curl  " & "" & searchUrl & " | grep -i \"i.ytimg.com\" | cut -d '\"' -f 2,6 | tr '\"' \\\\r")
end try

set videoData to {}
set {tid, text item delimiters} to {text item delimiters, "/"}
repeat with i from 1 to (count searchResult) by 2
	set end of videoData to item (i + 1) of searchResult & space & text item -2 of item i of searchResult & space & item i of searchResult
end repeat
set text item delimiters to return
set videoData to videoData as text
set text item delimiters to tid
display dialog videoData


Stefank This is great, and works almost as i want it to, but i need to split up the data.

this is one of the lines
<img src="http://i.ytimg.com/vi/L-yYWSlW6h8/default.jpg\" class="vimg120" title="Comedy Fight Club På Gøglerskole - Asmus Brandt" alt="video">"

and the data i need is

movieNumber = L-yYWSlW6h8
movieTitle = Comedy Fight Club På Gøglerskole - Asmus Brandt

the path to image is no problem to set as long as i have “movieNumber” defined,

the movieNumber is to be used later in the script, so i need to split up the data…