guillermo (owner)

Revisions

gist: 38330 Download_button fork
public
Description:
klubbersfm.comunidadspaceofsound.net/
Public Clone URL: git://gist.github.com/38330.git
Embed All Files: show embed
klubbers fm radio podcast #
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/usr/local/bin/ruby
# This is the software to extract klubbers fm radio podcast.
#
# You can access the klubbers fm podcast in:
# http://klubbersfm.comunidadspaceofsound.net/
#
 
require 'rubygems'
require 'sinatra'
require 'hpricot'
require 'open-uri'
require 'rack/cache'
 
use Rack::Cache,
  :verbose => true,
  :metastore => "file:/tmp/klubbersfm/cache/meta",
  :entitystore => "file:/tmp/klubbersfm/cache/body"
 
 
File.open('/tmp/klubbersfm.pid','w'){|f| f.write $$}
 
Sinatra::Application.default_options.merge!(
  :port => 7777,
  :address => '127.0.0.1'
)
 
get '/' do
  haml :index
end
 
get '/index.rss' do
  response["Cache-Control"] = "max-age=86400, public"
  builder :podcast
end
 
use_in_file_templates!
#end
 
__END__
 
@@ index
!!!
%html
%script{:src => 'itunes.js'}
<title>Podcast no oficial de klubbersfm</title>
:plain
<link rel="stylesheet" href="http://www.blueprintcss.org/blueprint/screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="http://www.blueprintcss.org/blueprint/print.css" type="text/css" media="print">
<!--[if lt IE 8]><link rel="stylesheet" href="http://www.blueprintcss.org/blueprint/ie.css" type="text/css" media="screen, projection"><![endif]-->
 
%body
.container
.span-24
%h1 Podcast de Klubbers FM
%p Este es el podcast no oficial de klubbers FM
.span-6
%h2 Usar este podcast
%p Para usar este podcast inserta el siguiente enlace a tu programa de podcasts preferido
%ul
%li
%a{:href => 'http://feeds.feedburner.com/klubbers'} "http://feeds.feedburner.com/klubbers"
.span-6
%h2 Motivaciones
%p Debido a que el player de la web nunca me ha funcionado y que no tiene podcast oficial, realice este sencillo podcast que busca en la web de klubbers por novedades.
%p El programa son apenas unas 70 lineas, con licencia BSD, y se puede descargar desde http://gist.github.com/38330
.span-6
%h2 Itunes
%p Subscribete a este podcast en <a href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=328171626"><img src="http://ax.phobos.apple.com.edgesuite.net/images/badgeitunes61x15dark.gif" alt="iTunes" /></a>
.span-6.last
%h2 Author
%p Guillermo Alvarez < guillermo @ cientifico.net >
@@ podcast
doc = Hpricot(open('http://www.klubbers.com/player.php'))
 
last_pub = Time.local(2000)
 
reg = /player\.php\?dia\=(\d*)\&mes\=(\d*)\&anio\=(\d*)/
 
episodes = (doc/"option").map do |e|
begin
# Get title
title = e.inner_html.split("@").first
# Get date
value = e.attributes["value"]
day, month, year = value.match(reg).to_a[1..-1].map{|d| d.to_i}
# Get mp3 url
date = "%.2d_%.2d_%.2d" % [day,month,year]
url ="http://www.klubbers.com/radio/radio_#{date}/wimpy.php?action=getstartupdirlist"
puts "Getting #{url}"
body = open(url).read
mp3 = body.match(/=([^|]*)/).to_a[1]
# Generate pubDate
pubdate = Time.local(year,month,day)
last_pub = pubdate if pubdate > last_pub
[ mp3, title, pubdate.rfc822]
rescue => e
require 'ruby-debug'
debugger
puts 'touche'
end
end
 
xml.instruct!
xml.rss :version => '2' do |rss|
rss.channel do |chan|
chan.title "Klubbers FM Radio"
chan.description "Klubbers FM Radio Podcast\nPodcast no oficial del programa de radio Klubbers FM, emitido por Loca FM (EspaƱa)"
chan.link "http://klubbersfm.comunidadspaceofsound.net"
chan.languge "es-es"
chan.lastBuildDate Time.now.to_s
chan.pubDate last_pub.rfc822
episodes.each do |episode|
chan.item do |i|
i.title episode[1]
i.link episode[0]
i.description episode[1]
i.enclosure :url => episode[0] , :type => 'audio/mpeg'
i.category "Podcasts"
i.pubDate episode[2]
end
end
end