-
Notifications
You must be signed in to change notification settings - Fork 1
/
banshee-podcast-opml.rb
executable file
·55 lines (47 loc) · 1.19 KB
/
banshee-podcast-opml.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env ruby
#
# Script to generate OPML of podcasts from Banshee
#
# Thanks to
# http://blog.slashpoundbang.com/post/3385815540/how-to-generate-an-opml-file-with-ruby
#
# Public domain.
require 'rubygems'
require 'builder'
require 'sqlite3'
USER = ''
EMAIL = ''
DB_FILE = "#{ENV['HOME']}/.config/banshee-1/banshee.db"
class Podcast
attr_reader :title, :description, :url
def initialize title, description, url
@title = title
@description = description
@url = url
end
end
podcasts = []
db = SQLite3::Database.new(DB_FILE)
db.execute 'select * from PodcastSyndications' do |row|
podcasts << Podcast.new(row[5], row[6], row[7])
end
xml = Builder::XmlMarkup.new(:target => STDOUT)
xml.instruct!
xml.opml(:version => 1.1) do
xml.head do
xml.title 'Podcasts'
xml.dateCreated Time.new.httpdate
xml.dateModified Time.now.httpdate
xml.ownerName USER
xml.ownerEmail EMAIL
end
xml.body do
podcasts.each do |podcast|
title = podcast.title
xml.outline(:type => 'rss', :version => 'RSS',
:description => podcast.description,
:title => title, :text => title,
:xmlUrl => podcast.url)
end
end
end