m3u files optie, op verzoek van sven
This commit is contained in:
parent
fc1783c585
commit
8a9360e70d
1 changed files with 14 additions and 1 deletions
|
|
@ -33,6 +33,8 @@
|
|||
"rename" => [ /_(\d\d\d\d)(\d\d)/, '\2\1' ],
|
||||
# directory to put symlinks to the new files
|
||||
"linkdir" => '/Users/ward/ipod_sync/[books]/Distorted View',
|
||||
# option to write an m3u file after fetching the mp3s
|
||||
"m3u" => '/Users/ward/dv.m3u',
|
||||
},
|
||||
"tagesschau" => {
|
||||
"rss" => 'http://www.tagesschau.de/export/podcast',
|
||||
|
|
@ -91,23 +93,34 @@ def getenclosure(podcast, enclosure)
|
|||
if @podcasts[podcast]["linkdir"]
|
||||
File.symlink("#{@podcasts[podcast]["savedir"]}/#{filename}", "#{@podcasts[podcast]["linkdir"]}/#{filename}")
|
||||
end
|
||||
return "#{@podcasts[podcast]["savedir"]}/#{filename}"
|
||||
rescue Timeout::Error, Errno::EHOSTUNREACH, Errno::ECONNREFUSED
|
||||
puts " error fetching, skipping"
|
||||
end
|
||||
else
|
||||
return "#{@podcasts[podcast]["savedir"]}/#{filename}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for podcast in @podcasts.keys.sort
|
||||
files = Array.new
|
||||
puts podcast
|
||||
res = fetch(@podcasts[podcast]["rss"])
|
||||
@filelist = {}
|
||||
|
||||
xmldoc = REXML::Document.new(res.body)
|
||||
xmldoc.elements.each("rss/channel/*/enclosure") {|enclosure|
|
||||
getenclosure(podcast, enclosure)
|
||||
files.push getenclosure(podcast, enclosure)
|
||||
}
|
||||
if @podcasts[podcast]["delete"]
|
||||
deleteold(podcast)
|
||||
end
|
||||
if @podcasts[podcast]["m3u"]
|
||||
File.open(@podcasts[podcast]["m3u"], "w"){|f|
|
||||
files.each{|file|
|
||||
f.puts file
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue