AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Sick of iTunes

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
maestrith



Joined: 17 Sep 2005
Posts: 24

PostPosted: Sat Jul 19, 2008 2:46 pm    Post subject: Sick of iTunes Reply with quote

I download a bunch of podcasts and there is one that I love from cnet which is located at http://videopodcasts.cnet.com/ This is a great way to get all of the podcasts because you only need to add 1 url to your rss reader. The problem is that if you use Winamp to manage your i-pod this is frustrating because it will only download the newest podcast. Ever since I switched to Winamp I have been looking for a better rss reader that would automatically download the .mp4, .mp3, .m4v files directly from the xml, but they all required you to click and save each and every one. I wrote this program to help solve my problem. It writes an xml that is used by Free Download Manager to get all of my podcasts. I hope that it is useful to someone.
Code:

#singleinstance, force
pdir = J:\podcast ; rename this to your podcast directory
gui:
gui, add, treeview, vtreeview w600 h600
gui, add, button, gupdate, Update All Casts
gui, add, button, gdownload, Download selected file
gui, add, button, gall x+10, Download All of Selected Podcast
gui, add, button, gsingle x+10, Update selected podcast
gui, add, edit, vedit x10
gui, add, button, x+5 gadd, Add new podcast
gui, add, button, x+5 gimport, Import a list of url's
gui, add, button, x+5 gbobntom, Run split
gui, add, button, x+5 gexit, Exit
gui, show
populate:
GuiControl,-redraw, treeview
tv_delete()
loop, casts\*.ini
{
 fileread, cast, %a_loopfilefullpath%
 sort, cast,R
 stringtrimright, castname, a_loopfilename,4
 a := tv_add(castname)
 loop, parse, cast, `n,`r
 {
  stringsplit, entry, a_loopfield,®
  b := tv_add(entry2,a)
  c := tv_add(entry3,b)
  if entry4 =
  continue
  d := tv_add(entry4,c)
 }
}
GuiControl,+redraw, treeview
return
strip:
fileread, info, download.dnl
stringreplace, info, info, &, %a_space%and%a_space%, all
stringreplace, info, info, <item>, ®, all
needle = Ui)"(http://[^[:space:]]*(m4v|mp4|mp3))"
loop, parse, info, ®
{
 RegExMatch(a_loopfield, "Ui)<description>(.*)</description>" ,description)
 RegExMatch(a_loopfield, "Ui)<pubdate>(.*)</pubdate>" ,pubdate)
 RegExMatch(a_loopfield, "U)<title>(.*)</title>", title)
 RegExMatch(a_loopfield, needle, url)
 gosub, fix
 if a_index = 1
 {
  file := regexreplace(title1,"i)[^a-z0-9[:space:])(]")
  fileread, compare, casts\%file%.ini
  continue
 }
 title1 := regexreplace(title1,"i)[^a-z0-9[:space:]]")
 gosub, date
 description1 := regexreplace(description1,"U)(\t|\n|\r|<.*>|\&..;|\[.*]|\||]\>|)")
 stringleft, description1, description1, 150
 url=
 gosub, %operation%
}
return

f1::
reload
return

fix:
Loop
{
 regexmatch(url1, "`%(..)",ascii)
 StringReplace, url1, url1, `%%ascii1%, % Chr("0x" . ascii1), All
 if errorlevel <> 0
 break
}
return

date:
d = 1
loop, parse, pubdate, %a_space%
{
 if a_loopfield =
 continue
 p%d% = %a_loopfield%
 d += 1
}
loop, 12
{
 month = %a_index%
 if StrLen(month)=1
 month = 0%month%
 formattime, out, 2008%month%01, MMM
 if out = %p3%
 {
  if a_index < 10
  p3 = 0%a_index%
  else
  p3 = %a_index%
 }
}
if StrLen(p2) =1
p2 = 0%p2%
date = %p4%%p3%%p2%
return
add:
gui, submit, nohide
iniwrite, %edit%, urlz.ulz, %file%, 1
urldownloadtofile,  %edit%, download.dnl
operation = newcast
gosub, strip
gosub, populate
return

newcast:
if compare not contains %date%®%title1%®%url1%®%description1%
{
 fileappend, %date%®%title1%®%url1%®%description1%`n, casts\%file%.ini
}
return
import:
FileSelectFile,file,,,Please select a file to open, *.txt
fileread, file, %file%
loop, parse, file, `n, `n
{
 urldownloadtofile, %a_loopfield%, download.dnl
 operation = newcast
 gosub, strip
 ifnotexist, %pdir%\%file%\folder.jpg
 gosub, picture
 iniwrite, %a_loopfield%, urlz.ulz, %file%, 1
 splashtexton,,,%file%
}
splashtextoff
goto populate
return
return
update:
filedelete, download.xml
fileappend, <FDM_Downloads_Info_List>`n, download.xml
loop,
{
 tv_gettext(name,TV_GetNext(next))
 splashtexton,,,%name%
 next :=TV_GetNext(next)
 if name =
 break
 iniread, Out, urlz.ulz, %name%, 1
 urldownloadtofile, %out%, download.dnl
 operation = update1
 gosub, strip
}
fileappend, </FDM_Downloads_Info_List>, download.xml
splashtextoff
fileread, download, download.xml
if download not contains <url>
{
 msgbox Nothing to download
 stringleft, now, a_now, 8 
 IniWrite, %now%, lastscan.in, lastscan, lastscan
 return
}
stringleft, now, a_now, 8 
IniWrite, %now%, lastscan.in, lastscan, lastscan
fdm:
run, %a_programfiles%\Free Download Manager\fdm.exe
detecthiddenwindows, on
winwait, Free Download Manager
winactivate, Free Download Manager
send, !fii{enter}
winwait, Open
controlsettext, Edit1, %a_scriptdir%\download.xml, Open
send, {enter}
return

update1:
fileread, compare, casts\%file%.ini
RegExMatch(compare, title1 ,found)
if found =
{
 fileappend, %date%®%title1%®%url1%®%description1%`n, casts\%file%.ini
 fileappend, <download>`n<url>%url1%</url>`n<group>Video\%name%</group>`n</download>`n,    download.xml
}
return
picture:
filecreatedir, %pdir%\%file%\
ifnotexist, %pdir%\%file%\folder.jpg
{
 RegExMatch(info, "Ui)http://[^[:space:]]*(jpg|png)", found)
 urldownloadtofile, %found%, %pdir%\%file%\folder.jpg
 }
return
exit:
exitapp
return
single:
filedelete, download.xml
fileappend, <FDM_Downloads_Info_List>`n, download.xml
tv_gettext(name, TV_GetSelection())
iniread, Out, urlz.ulz, %name%, 1
urldownloadtofile, %out%, download.dnl
operation = update1
gosub, strip
fileappend, </FDM_Downloads_Info_List>, download.xml
fileread, download, download.xml
if download not contains <url>
{
 msgbox Nothing to download
 stringleft, now, a_now, 8 
 IniWrite, %now%, lastscan.in, lastscan, lastscan
 return
}
gosub, fdm
return
all:
filedelete, all.xml
fileappend, <FDM_Downloads_Info_List>`n, all.xml
tv_gettext(name, tv_getselection())
parent := tv_getchild(TV_GetSelection())
master := tv_getselection()
loop,
{
 if a_index > 1
 parent:=tv_getnext(parent)
 check:=tv_getparent(parent)
 if master <> %check%
 break
 file:=tv_getchild(parent)
 tv_gettext(url, file)
 fileappend, <download>`n<url>%url%</url>`n<group>Video\%name%</group>`n</download>`n,all.xml
}
fileappend, </FDM_Downloads_Info_List>, all.xml
total =
run, %a_programfiles%\Free Download Manager\fdm.exe
detecthiddenwindows, on
winwait, Free Download Manager
winactivate, Free Download Manager
send, !fii{enter}
winwait, Open
controlsettext, Edit1, %a_scriptdir%\all.xml, Open
send, {enter}
return
return
 
bobntom:
run, J:\podcast\The BOB and TOM VIP Podcast\delete.ahk
return
download:
file := tv_gettext(url, tv_getselection())
if url not contains http://
{
 msgbox please select a url
 return
}
parent:=tv_getparent(file)
cast:=tv_getparent(parent)
tv_gettext(pcast, cast)
filedelete, download.xml
fileappend, <FDM_Downloads_Info_List>`n, download.xml
fileappend, <download>`n<url>%url%</url>`n<group>Video\%pcast%</group>`n</download>`n,    download.xml
fileappend, </FDM_Downloads_Info_List>, download.xml
gosub, fdm
return
Back to top
View user's profile Send private message
maestrith



Joined: 17 Sep 2005
Posts: 24

PostPosted: Tue Jul 29, 2008 7:33 pm    Post subject: Update to the code Reply with quote

As I was going back through the code, I found a change that I needed to make. Here it is.
Code:

#singleinstance, force
pdir = J:\podcast
gui:
gui, add, treeview, vtreeview w600 h600
gui, add, button, gupdate, Update All Casts
gui, add, button, gdownload, Download selected file
gui, add, button, gall x+10, Download All of Selected Podcast
gui, add, button, gsingle x+10, Update selected podcast
gui, add, edit, vedit x10
gui, add, button, x+5 gadd, Add new podcast
gui, add, button, x+5 gimport, Import a list of url's
gui, add, button, x+5 gbobntom, Run Delete
gui, add, button, x+5 gexit, Exit
gui, show
populate:
GuiControl,-redraw, treeview
tv_delete()
loop, casts\*.ini
{
 fileread, cast, %a_loopfilefullpath%
 sort, cast,R
 stringtrimright, castname, a_loopfilename,4
 a := tv_add(castname)
 loop, parse, cast, `n,`r
 {
  stringsplit, entry, a_loopfield,®
  b := tv_add(entry2,a)
  c := tv_add(entry3,b)
  if entry4 =
  continue
  d := tv_add(entry4,c)
 }
}
GuiControl,+redraw, treeview
return
strip:
fileread, info, download.dnl
stringreplace, info, info, &amp;, %a_space%and%a_space%, all
stringreplace, info, info, <item>, ®, all
needle = Ui)"(http://[^[:space:]]*(m4v|mp4|mp3))"
loop, parse, info, ®
{
 RegExMatch(a_loopfield, "Ui)<description>(.*)</description>" ,description)
 RegExMatch(a_loopfield, "Ui)<pubdate>(.*)</pubdate>" ,pubdate)
 RegExMatch(a_loopfield, "U)<title>(.*)</title>", title)
 RegExMatch(a_loopfield, needle, url)
 gosub, fix
 if a_index = 1
 {
  file := regexreplace(title1,"i)[^a-z0-9[:space:])(]")
  fileread, compare, casts\%file%.ini
  continue
 }
 title1 := regexreplace(title1,"i)[^a-z0-9[:space:]]")
 gosub, date
 description1 := regexreplace(description1,"U)(\t|\n|\r|<.*>|\&..;|\[.*]|\||]\>|)")
 stringleft, description1, description1, 150
 url=
 gosub, %operation%
}
return

f1::
reload
return

fix:
Loop
{
 regexmatch(url1, "`%(..)",ascii)
 StringReplace, url1, url1, `%%ascii1%, % Chr("0x" . ascii1), All
 if errorlevel <> 0
 break
}
return

date:
d = 1
loop, parse, pubdate, %a_space%
{
 if a_loopfield =
 continue
 p%d% = %a_loopfield%
 d += 1
}
loop, 12
{
 month = %a_index%
 if StrLen(month)=1
 month = 0%month%
 formattime, out, 2008%month%01, MMM
 if out = %p3%
 {
  if a_index < 10
  p3 = 0%a_index%
  else
  p3 = %a_index%
 }
}
if StrLen(p2) =1
p2 = 0%p2%
date = %p4%%p3%%p2%
return
add:
gui, submit, nohide
iniwrite, %edit%, urlz.ulz, %file%, 1
urldownloadtofile,  %edit%, download.dnl
operation = newcast
gosub, strip
gosub, populate
return

newcast:
if compare not contains %date%®%title1%®%url1%®%description1%
{
 fileappend, %date%®%title1%®%url1%®%description1%`n, casts\%file%.ini
}
return
import:
FileSelectFile,file,,,Please select a file to open, *.txt
fileread, file, %file%
loop, parse, file, `n, `n
{
 urldownloadtofile, %a_loopfield%, download.dnl
 operation = newcast
 gosub, strip
 ifnotexist, %pdir%\%file%\folder.jpg
 gosub, picture
 iniwrite, %a_loopfield%, urlz.ulz, %file%, 1
 splashtexton,,,%file%
}
splashtextoff
goto populate
return
return
update:
filedelete, download.xml
fileappend, <FDM_Downloads_Info_List>`n, download.xml
loop,
{
 tv_gettext(name,TV_GetNext(next))
 splashtexton,,,%name%
 next :=TV_GetNext(next)
 if name =
 break
 iniread, Out, urlz.ulz, %name%, 1
 urldownloadtofile, %out%, download.dnl
 operation = update1
 gosub, strip
}
fileappend, </FDM_Downloads_Info_List>, download.xml
splashtextoff
fileread, download, download.xml
if download not contains <url>
{
 msgbox Nothing to download
 stringleft, now, a_now, 8 
 IniWrite, %now%, lastscan.in, lastscan, lastscan
 return
}
stringleft, now, a_now, 8 
IniWrite, %now%, lastscan.in, lastscan, lastscan
fdm:
run, %a_programfiles%\Free Download Manager\fdm.exe
detecthiddenwindows, on
winwait, Free Download Manager
winactivate, Free Download Manager
send, !fii{enter}
winwait, Open
controlsettext, Edit1, %a_scriptdir%\download.xml, Open
send, {enter}
return

update1:
iniread, out, lastscan.in, lastscan, lastscan
splitpath, url1, filex
fileread, compare, casts\%file%.ini
RegExMatch(compare, filex ,found)
if found =
{
 if out <= %date%
 {
  fileappend, %date%®%title1%®%url1%®%description1%`n, casts\%file%.ini
  fileappend, <download>`n<url>%url1%</url>`n<group>Video\%name%</group>`n</download>`n,    download.xml
 }
}

picture:
filecreatedir, %pdir%\%file%\
ifnotexist, %pdir%\%file%\folder.jpg
{
 RegExMatch(info, "Ui)http://[^[:space:]]*(jpg|png)", found)
 urldownloadtofile, %found%, %pdir%\%file%\folder.jpg
 }
return
exit:
exitapp
return
single:
filedelete, download.xml
fileappend, <FDM_Downloads_Info_List>`n, download.xml
tv_gettext(name, TV_GetSelection())
iniread, Out, urlz.ulz, %name%, 1
urldownloadtofile, %out%, download.dnl
operation = update1
gosub, strip
fileappend, </FDM_Downloads_Info_List>, download.xml
fileread, download, download.xml
if download not contains <url>
{
 msgbox Nothing to download
 stringleft, now, a_now, 8 
 IniWrite, %now%, lastscan.in, lastscan, lastscan
 return
}
gosub, fdm
return
f2::
fileread, casts, already.ini
detecthiddenwindows, on
winrestore, Free Download Manager
winactivate, Free Download Manager
 mousegetpos, rx, ry
loop, %pdir%\*.*,2
{
 if casts contains %a_loopfilename%
 continue
 fileappend, %a_loopfilename%`n, already.ini
 mouseclick, right, %rx%, %ry%
 sleep, 500
 ImageSearch, x, y, 0, 0, 800, 600, create.bmp
 mouseclick, left, %x%, %y%
 winwait, Create new group
 controlsettext, Edit1, %a_loopfilename%, Create new group
 controlsettext, Edit2, %a_loopfilefullpath%, Create new group
 sleep, 100
 send, {enter}
 sleep, 100
}
return
all:
filedelete, all.xml
fileappend, <FDM_Downloads_Info_List>`n, all.xml
tv_gettext(name, tv_getselection())
parent := tv_getchild(TV_GetSelection())
master := tv_getselection()
loop,
{
 if a_index > 1
 parent:=tv_getnext(parent)
 check:=tv_getparent(parent)
 if master <> %check%
 break
 file:=tv_getchild(parent)
 tv_gettext(url, file)
 fileappend, <download>`n<url>%url%</url>`n<group>Video\%name%</group>`n</download>`n,all.xml
}
fileappend, </FDM_Downloads_Info_List>, all.xml
total =
run, %a_programfiles%\Free Download Manager\fdm.exe
detecthiddenwindows, on
winwait, Free Download Manager
winactivate, Free Download Manager
send, !fii{enter}
winwait, Open
controlsettext, Edit1, %a_scriptdir%\all.xml, Open
send, {enter}
return
return
 
bobntom:
run, J:\podcast\The BOB and TOM VIP Podcast\delete.ahk, J:\podcast\The BOB and TOM VIP Podcast
return
download:
file := tv_gettext(url, tv_getselection())
if url not contains http://
{
 msgbox please select a url
 return
}
parent:=tv_getparent(file)
cast:=tv_getparent(parent)
tv_gettext(pcast, cast)
filedelete, download.xml
fileappend, <FDM_Downloads_Info_List>`n, download.xml
fileappend, <download>`n<url>%url%</url>`n<group>Video\%pcast%</group>`n</download>`n,    download.xml
fileappend, </FDM_Downloads_Info_List>, download.xml
gosub, fdm
return

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group