costalat

vdr epg into text output

Sep 8th, 2011
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.05 KB | None | 0 0
  1. ## imports epg data from vdr and prepares an output that can be used i.e with conky
  2.  
  3. import sys
  4. import urllib
  5.  
  6. def download_url(channel_num):
  7.     url = 'http://127.0.0.1:8008/schedule.html?channel=%s' % (channel_num)
  8.     texto = urllib.urlopen(url).read()
  9.     texto = texto.decode('windows-1252')
  10.     index = texto.find('<td class="topaligned "><div class="withmargin nowrap"')
  11.     h1 = index+55
  12.     index = texto[h1:].find('><span class="title">')
  13.     pi1 = h1 + index + 21
  14.     index = texto[pi1:].find('</span><br')
  15.     pf1 = pi1 + index
  16.     index = texto[pf1:].find('<td class="topaligned "><div class="withmargin nowrap"')
  17.     h2 = pf1+index+55
  18.     index = texto[h2:].find('><span class="title">')
  19.     pi2 = h2 + index + 21
  20.     index = texto[pi2:].find('</span><br')
  21.     pf2 = pi2 + index
  22.     print texto[h1:h1+19]+'   '+texto[pi1:pf1]+'\n'+texto[h2:h2+19]+'   '+texto[pi2:pf2]+'\n'+'\n'
  23.  
  24. if __name__ == '__main__':    
  25.     if len(sys.argv) == 2:
  26.     param = str(sys.argv[1]).strip()
  27.     download_url(param)
  28.     else:
  29.     print 'No channel specified.'
Advertisement
Add Comment
Please, Sign In to add comment