01-31-2008, 08:50 AM
Another quickie one...
Make sure you download the new excel attached !
Changes to make:
1. maxRows - Same as before
2. Suffix1 & Suffix2
3. semi_auto - 1=4 results, 0=1 result
function E_Main
function E_GetUrls
Make sure you download the new excel attached !
Changes to make:
1. maxRows - Same as before
2. Suffix1 & Suffix2
3. semi_auto - 1=4 results, 0=1 result
function E_Main
int semi_auto = 0
str suffix1 = "how to play"
str suffix2 = "music video"
run "$Desktop$\list.xls" "" "Open" "" 3|0x100; err
mes("Do not click/type anywhere on the Excel while macro is running !" "Warning" "!a")
int maxRows = 2 ;;181
str title artist url
str temp
str intresp result_url result_url2 result_url3 result_url4
Excel.Workbook x._getfile("$desktop$\list.xls")
Excel.Application a=x.Application
a.Visible=TRUE; err
ExcelSheet es.ws = x.Worksheets.Item(1)
int i
for(i 2 maxRows+1)
,es.GetCell(title 1 i)
,es.GetCell(artist 2 i)
,if (suffix1)
,,es.SetCell("Connecting..." 3 i)
,,_s = E_GetUrls(semi_auto title artist suffix1)
,,es.SetCell(_s 3 i)
,if (suffix2)
,,es.SetCell("Connecting..." 4 i)
,,_s = E_GetUrls(semi_auto title artist suffix2)
,,es.SetCell(_s 4 i)
es.Save
mes-("All links have been downloaded !" "Done" "ia")
function E_GetUrls
function~ semi_auto $title $artist $suf1 [$suf2]
if(!suf2)
,suf2 = ""
,
str url_pre = "http://www.youtube.com/results?search_query="
str url.format("%s%s %s %s %s" url_pre title artist suf1 suf2)
IntGetFile url _s
str intresp = _s
,
_i = find(intresp "a href=''/watch" 0 1)
str temp = _s.get(_s _i-1)
,
;GET URL
if (!semi_auto)
,_i = find(temp ">" 0 1)
,str result_url.get(temp 9 _i-10)
,result_url - "http://www.youtube.com"
,_s.format("%s" result_url)
else
,_i = find(temp ">" 0 1)
,result_url.get(temp 9 _i-10)
,result_url - "http://www.youtube.com"
,
,_i = find(temp "a href=''/watch" _i 1); _i = find(temp "a href=''/watch" _i+10 1); _i = find(temp "a href=''/watch" _i+10 1)
,temp.get(temp _i+8); _i = find(temp ">" 0 1)
,str result_url2.get(temp 0 _i-1)
,result_url2 - "http://www.youtube.com"
,_i = find(temp "a href=''/watch" _i 1); _i = find(temp "a href=''/watch" _i+10 1); _i = find(temp "a href=''/watch" _i+10 1)
,temp.get(temp _i+8); _i = find(temp ">" 0 1)
,str result_url3.get(temp 0 _i-1)
,result_url3 - "http://www.youtube.com"
,_i = find(temp "a href=''/watch" _i 1); _i = find(temp "a href=''/watch" _i+10 1); _i = find(temp "a href=''/watch" _i+10 1)
,temp.get(temp _i+8); _i = find(temp ">" 0 1)
,str result_url4.get(temp 0 _i-1)
,result_url4 - "http://www.youtube.com"
,_s.format("%s %s %s %s" result_url result_url2 result_url3 result_url4)
ret _s
IBM Mainframe Expert who Plays with QM a LOT !