XBMC Community Forum  

Go Back   XBMC Community Forum > Development > Plugin/Script (Python) Development

Plugin/Script (Python) Development Developers forum for XBMC Python Plugins/Scripts. Scripters/coders only!
Not for posting feature requests, bugs, or end-user support requests!

Reply
 
Thread Tools Search this Thread Display Modes
Old 2004-04-01, 08:04   #1
nlemoz
Junior Member
 
Join Date: Apr 2004
Posts: 11
nlemoz is on a distinguished road
Default

i think that for the tv guide requests to have any hope of succeeding, the ty guide script needs to be implmented in two parts.

one part is a reusable tv guide display which can be used for all tv guides with language etc. this module will allow the user to select which tv guide they want, time, date, channel lists etc.

the other module will be a script which grabs the appropriate tv guide from somewhere. this part needs to be replacable for different areas, and should be easily implemented so that we can get the maximum amount of people implmenting it for their part of the world. possibly it would consist of just a couple of functions that will take a date and time (span?) and retrieve all shows for that time. their might be an info method that would return information on the channels covered and the number of channels
eg
tvgrabinfo->region = "gotham city"
tvgrabinfo->type = "free to air"
tvgrabinfo->number = 7

the grabber would return xml with all shows it can get and the time span covered. caching would be nice in the main module.

any thoughts from anyone?
nlemoz is offline   Reply With Quote
Old 2004-04-01, 14:29   #2
dop
Junior Member
 
Join Date: Mar 2004
Posts: 7
dop is on a distinguished road
Default

nlemoz,

i'm currently working on tv guide script that works like this:

the first is a daemon written in perl that resides on a linux/windows server, and reads in the xmltv file twice a day. in this way the xmltv file can be acquired as is normal on linux (using whatever script what is available via xmltv.org in a crontab.)

the second part is a python plugin frontend for XBMC, which connects to the server and gets all its data from the perl daemon, already nicely parsed.

it's almost finished, tvguide works ok, currently testing the recording stuff (you can put items in a recording queue, and the perl deamon will run mencoder at the appropriate time with the apprioprate channel etc.).

this will not help for people who don't have a server. maybe someone could run the perl deamon on a public internet server for specific languages/regions for xbox's to connect to via internet (don't know how fast this would be though..) (and disabling the recording option ofcourse .

when i think the script is tested ok, and releasable , i'll post i link to the stuff here.

dop
dop is offline   Reply With Quote
Old 2004-04-01, 15:19   #3
alx5962
Senior Member
 
Join Date: Jan 2004
Posts: 174
alx5962 is on a distinguished road
Default

i started a tv guide in python using the listing.xml used in xbmp tv guide.
but i decided to stop it so i may share my work later for people who want to continue it
alx5962 is offline   Reply With Quote
Old 2004-04-01, 16:58   #4
nlemoz
Junior Member
 
Join Date: Apr 2004
Posts: 11
nlemoz is on a distinguished road
Default

for some reason i must have turned reply notification off, so i didn't see your replies until now.

both of these projects sound very interesting. between the last time i checked this forum and now, i made a python script that grabs a tv listing for my area (australia) and prints out xml data to a (windows text) console. i haven't worked out how to make it a module so it could be called from a front-end because this is my first day with python (although i have adequate experience with other languages).

i noticed that there is already a perl based xmltv grabber for my area, but i wanted one in python for the xbox so i built it. still needs a bit of error checking and doco, and of course an xbox front end, but we'll see.

i would be very interested to see what you guys have so far.
maybe you could add an option to run a local (python) xmltv grabber and/or read in a local xml file.
nlemoz is offline   Reply With Quote
Old 2004-04-01, 18:50   #5
nlemoz
Junior Member
 
Join Date: Apr 2004
Posts: 11
nlemoz is on a distinguished road
Default

here's my script for yahoo tv. it still needs some work, for instance:
details grabbing
caching
more error checking
could make the extraction more robust
make it more xmltv like

noticed before that tabs don't work that well in this bb... had to replace them with spaces. it prints out an xml version of
yahoo tv aus
for the current time and date.
should not take too much work to adapt it to other yahoo regions (eg us etc)

Quote:
# project : tv guide
import urllib
import string
from datetime import date,timedelta
import time

# request the page
def geturl(serveradr,pagepath):
* * import urllib
* * opener = urllib.fancyurlopener({})
* * doc = opener.open('http://' + serveradr + pagepath)
* * data = doc.read() *# read file
* * doc.close()
* * return data


#extract program data to list of lists
def extractdata(in_string, start_chan_desc, end_chan_desc):
* * #separate channels and drop the top part
* * channels=in_string.split('venueresults.html')
* * channels.pop(0)

* * tv_data = []
* *
* * for i in channels:
* * * * *try:
* * * * * * * # get channel names
* * * * * * * start_index = string.index(i,start_chan_desc)+len(start_chan_des c)
* * * * * * * end_index = string.index(i,end_chan_desc,start_index)
* * * * * * * current_chan = i[start_index:end_index]
* * * * *except:
* * * * * * * continue
* * * * *
* * * * *start_pos = end_index
* * * * *while (1):
* * * * * * * try:
* * * * * * * * * *prog_data = []
* * * * * * * * * *
* * * * * * * * * *#find time
* * * * * * * * * *start_pos = string.index(i,':',start_pos)-2
* * * * * * * * * *end_pos = string.index(i,'<br>',start_pos)
* * * * * * * * * *prog_hour = i[start_pos:start_pos+2].strip().zfill(2)
* * * * * * * * * *prog_min = i[start_pos+3:start_pos+5].strip()
* * * * * * * * * *if i[start_pos+5:start_pos+7] == "pm":
* * * * * * * * * * * * prog_hour = str(string.atoi(prog_hour)+12)
* * * * * * * * * *
* * * * * * * * * *#find name
* * * * * * * * * *start_pos = string.index(i,'event.html',end_pos)++len('event.h tml')
* * * * * * * * * *start_pos = string.index(i,'\">',start_pos)++len('\">')
* * * * * * * * * *end_pos = string.index(i,'</a>',start_pos)
* * * * * * * * * *program = i[start_pos:end_pos]
* * * * * * * * * *start_pos = end_pos
* * * * * * * * * *
* * * * * * * * * *
* * * * * * * * * *prog_data.append(current_chan)
* * * * * * * * * *prog_data.append(prog_hour+prog_min)
* * * * * * * * * *prog_data.append(program)
* * * * * * * * * *
* * * * * * * * * *tv_data.append(prog_data)

* * * * * * * except:
* * * * * * * * * *break
* * return tv_data #return slice

#handle the returned stuff and generate a new page
def get_guide(tv_date, tv_time):
* *
* * # get guide info
* * serveradr='au.tv.yahoo.com'
* * region = '94'
* * pagepath='/results.html/results.html?rg='+region+'&vn=&dt=' + str(tv_date.year) + '-' + str(tv_date.month) + '-' *+ str(tv_date.day) + '&ts=' + tv_time
* * #print 'http://'+serveradr+pagepath
* * rawdata=geturl(serveradr, pagepath)
* *
* * # process data
* * start_chan_desc = 'target=_parent>'
* * end_chan_desc = '</a>'
* * v=extractdata(rawdata, start_chan_desc, end_chan_desc)
* *
* * # return result and extract programs
* * xmldata = "<tv>\n"

* * for i in v:
* * * * *xmldata += '\t<programme channel='+ str(i[0]) + ' start=\"' + str(tv_date.year) + str(tv_date.month).zfill(2)
* * * * *xmldata += str(tv_date.day).zfill(2) + i[1]+ ' aest\">\n'
* * * * *xmldata += '\t\t<title>'+i[2]+'</title>\n'
* * * * *xmldata += '\t</programme>\n'
* * * * *
* * xmldata += "</tv>"
* * return xmldata
* *
def main():
* * now_date = date.today()
* * now_time = time.localtime()
* * output = get_guide(now_date, str(now_time[3]).zfill(2))
* * print output
* *
#call main function
main()
nlemoz is offline   Reply With Quote
Old 2004-04-03, 05:42   #6
nlemoz
Junior Member
 
Join Date: Apr 2004
Posts: 11
nlemoz is on a distinguished road
Default

have written the almost all of the backend, now porting to the xbox (from windows) and writing the gui.

i have a couple of questions:

sys.argv[0] doesn't seem to be defined??
if it isn't, how else can i find dircetory that script was launched from?

import xml.parsers.expat fails with "no module named pyexpat", do i need to manually add, update from cvs, use a different parser or what?
nlemoz is offline   Reply With Quote
Old 2004-04-03, 06:20   #7
nlemoz
Junior Member
 
Join Date: Apr 2004
Posts: 11
nlemoz is on a distinguished road
Default

found that post by darkie that says he has implemnted pyexpat and added it to cvs.
the post was in feb, but the last python.rar was in jan
must be that anon cvs update issue he was talking about.
nlemoz is offline   Reply With Quote
Old 2004-04-03, 07:33   #8
madtw
Senior Member
 
Join Date: Mar 2004
Posts: 174
madtw is on a distinguished road
Default

nlemoz: i tried to use the xml parsers that python normally supports without much luck as well when i started work on my scripts. i ended up writing a quick and dirty parser class using some regular expressions. you're welcome to use it if it will save you some time... you can grab it from the python/lib dir in the archive in this directory. it is called simplexml.py and it has some documentation at the top of the file (run pydoc on it).
madtw is offline   Reply With Quote
Old 2004-04-04, 00:04   #9
darkie
Team-XBMC Developer
 
Join Date: Sep 2003
Posts: 530
darkie is on a distinguished road
Default

Quote:
found that post by darkie that says he has implemnted pyexpat and added it to cvs.
the post was in feb, but the last python.rar was in jan
must be that anon cvs update issue he was talking about.
pyexpat is not added to python.rar but hard coded into the xbmc source code. so you need to build xbmc yourself from cvs
__________________
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


darkie is offline   Reply With Quote
Old 2004-04-06, 09:14   #10
nlemoz
Junior Member
 
Join Date: Apr 2004
Posts: 11
nlemoz is on a distinguished road
Default

a little status update.
i have almost finished an alpha of the tv guide.
it now works reasonably well (imho)

things to do:
allow reordering of channels in display
vertical spacing of shows by time/duration

to make this whole thing work, i will need to build more listing grabbers. here is a smal spec for a grabber:

requirements:
can have any name ending in grabber.py

must have a function getinfo() that returns a list with a grabber description and channel names

eg
def getinfo():
return [["aus fta renmark"],["abc","win","sbs"]]

must have a function
getguide(tv_date, tv_time, sel_channels)

which takes a python date(tv_date), an integer indicating the hout in 24 hour format, and a list of strings (taht have been returned from getinfo() ) indicating channels that should be grabbed for this date and time.

it must return a text string consisting of xml as follows:

<programme channel="win" start="200404060400">
<title>"justice league"</title>
</programme>
<programme channel="win" start="200404060430">
<title>"good morning america"</title>
</programme>
<programme channel="sbs" start="200404061250">
<title>"pol pot and the khmer rouge"</title>
</programme>

where numbers like 200404061250 indicate date and time of the program <span style='color:red'>in gmt</span>. this is very close to the mythtv format, so i am hoping it would be easy to adapt current grabbers.

i have avoided specifying that the duration of the show should be in the returned text, as this makes writing the grabber a lot easier. i have also left off the description category, as most grabbers that get all descriptions cause far too many hits on the target website. i may put in an optional field that can be returned that might be used by the guide to get the grabber to retrieve details for one show, but it would be optional.

anyway, what do people think, will anybody be interested in coding these for their own region?
nlemoz is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Python Development Tools and modules/libraries for XBMC Scripters (outdated) Alexpoet Plugin/Script (Python) Development 10 2006-10-03 15:05
Python Development Documentations (outdated) alx5962 Plugin/Script (Python) Development 18 2006-06-19 21:53
Python Interpreter Development "Python Inside" darkie Plugin/Script (Python) Development 42 2005-09-19 09:07
Dashboard development for .com or possible python CaVleX Plugin/Script (Python) Help and Support 0 2005-05-06 18:27
Python Scripts Development Blackbelt Plugin/Script (Python) Development 106 2004-04-09 16:12


All times are GMT +2. The time now is 21:12.


Protected by Akismet, We recommend WordPress blogs
Copyright © 2008, XBMC Project