View Full Version : TV Guide screenlet - Work in progress - Need help
James
August 24th, 2007, 01:33 PM
Hi,
Please be aware that this screenlet is in early development and is not near day to day usage.
I am wanting to put together a screenlet that can display tv listings information, mainly the what is on now and what is on next for each channel. I've managed to create a simple screenlet which uses an XMLTV class I created.
The reason I need some help is because I am hopeless when it comes to making it look nice. I also don't know the screenlet framework very well for things like; the best way to display images or text, and how to handle the options correctly.
The basic code to use the XMLTV class is
self.tvGuide = Xmltv(self.xmltvFilePath)
self.tvGuide.DoLoad()
self.tvGuide.UpdateNowShows() #this updates the now show for each channel. Call this irregularly as it parses XML.
self.tvGuide.UpdateNextShows() #this updates the next show for each channel. Call this irregularly as it parses XML.
#This can be called in the draw function as it is just reading very small amounts of data and won't slow down processing
for channel in self.tvGuide.channels:
print "Now: " + channel.nowShow.title
print "Next: " + channel.nextShow.title
If anybody would like to help I have attached to this post (if it works) my python code so far. This includes, the XMLTV class, and the WhatsOnTVScreenlet. The first time the screenlet is run it will look for a file called "listing.xml" in the local directory of the screenlet. If it doesn't load a file it will still display a blank screenlet and you can set the file path in the properties (though beware the code seems to want to run everytime you type a letter in the filepath option box).
I've also attached a screenshot showing what I have got so far.
If you make any improvements or find any bugs can you reply to this thread. Hopefully we can get a nice looking screenlet out of this.
Thanks,
James.
James
August 26th, 2007, 01:25 PM
Hi,
I have created an updated version of this screenlet. This version is still in development but is a usable copy. I have attached a copy of the packaged version for easy installation. (still need a good icon for the package)
Features:
Select the XMLTV file in the properties dialog
Specify how many channels to display (1 to 6)
Themeable
Channel logos are displayed if you put them in the logos folder;
- logos must be PNG
- logos must be 60x60 pixels
- logo name must be the channel id .png (the channel id comes from the xmltv file)
Using the right click menu you can;
- Reload the xmltv file
- enable/disable channels to be displayed
- move channels up or down the list
Let me know if you have any problems with this new version.
After picking the XMLTV file in the properties dialog for the first time make sure you right click the screenlet and choose Refresh Data.
http://img208.imageshack.us/img208/5728/whatsontvscreenshotey9.th.jpg (http://img208.imageshack.us/my.php?image=whatsontvscreenshotey9.jpg)
Screenlet Package (http://www.mediafire.com/?bjvmuzrt2jv)
badabing
August 26th, 2007, 01:26 PM
looks excellent. could we perhaps have times as well, saying how long left until the next programme etc
nomego
August 26th, 2007, 04:47 PM
It would be great if you can choose country as well ;)
plun
August 26th, 2007, 07:47 PM
Thanks James...:)
This one was "tricky..... I followed this guide about xmltv
http://ubuntuforums.org/showthread.php?t=370534&highlight=xmltv
OnTV applet works but your Screenlets cannot read the xmlfile
plun@dunder:~$ python -u /usr/local/share/screenlets/WhatsOnTV/WhatsOnTVScreenlet.py
CachingBackend: Loading instances from cache
CachingBackend: Loading <WhatsOnTV1>
Creating new entry for WhatsOnTVScreenlet in /tmp/screenlets/screenlets.running
Loading instances in: /home/plun/.config/Screenlets/WhatsOnTV/default/
File: WhatsOnTV1.ini
Creating new instance:
UPDATING SHAPE
theme.conf found! Loading option-overrides.
theme.conf loaded:
Name: None
Author: None
Version: None
Info: None
UPDATING SHAPE
Set options in WhatsOnTVScreenlet
theme.conf found! Loading option-overrides.
theme.conf loaded:
Name: None
Author: None
Version: None
Info: None
UPDATING SHAPE
Started WhatsOnTV Screenlet
Loading XMLTV file - /home/plun/.xmltv/tv_grab_se_swedb.conf
DoLoad: Loading /home/plun/.xmltv/tv_grab_se_swedb.conf
DoLoad: An error occurred while trying to load the XMLTV file
Restored instances from session 'default' ...
CachingBackend: Saving <#WhatsOnTV1> :) ...
OK
None
Removing entry for WhatsOnTVScreenlet from global tempfile /tmp/screenlets/screenlets.running
James
August 26th, 2007, 10:33 PM
plun,
you have to point to the actual xml file that is generate by tv_grab_se. The file you pointed to is just a config file.
If you look around there should be a listing.xml file somewhere. Point to that.
Nomego,
The screenlet doesn't actually grab the xmltv file. You need to get it yourself using one of the tv_grab_xx programs which are available on the internet. (where xx is your country code). You just point the screenlet to the xmltv file and it reads it.
plun
August 26th, 2007, 11:38 PM
plun,
you have to point to the actual xml file that is generate by tv_grab_se. The file you pointed to is just a config file.
If you look around there should be a listing.xml file somewhere. Point to that.
Thanks... yup I found the file within .xlmtv
But "Data Unavailable" , OnTV applet works...
The xml file is huge..... 4MB
tv_grab_se_swedb --output /home/plun/.xmltv/tv_grab_se_swedb.xml
Loading XMLTV file - /home/plun/.xmltv/tv_grab_se_swedb.xml
DoLoad: Loading /home/plun/.xmltv/tv_grab_se_swedb.xml
DoLoad: An error occurred while trying to load the XMLTV file
CachingBackend: Saving <#WhatsOnTV1> :) ...
OK
SVT1
CachingBackend: Saving <#WhatsOnTV1> :) ...
fldc
August 27th, 2007, 01:11 AM
Pretty much the same thing here, also using tv_grab_se_swedb to generate the data :)
James
August 27th, 2007, 03:22 AM
I'm not at home at the moment so i can't check anything.
Could you upload a copy of your xml file somewhere so I can take a look at it and find the problem. If the file is too big to upload can you just upload a small section of the file. To check your data I just need some of the Channel elements, and some of the Programme elements. You can get these by opening the xml file in gedit.
It could be that the file is too large and I need to change to code to handle it.
plun
August 27th, 2007, 08:22 AM
Okidok... I made a new smaller with only 5 channels
http://paste.ubuntu-nl.org/35214/
:)
James
August 27th, 2007, 08:54 AM
Ok this version should work. There was a bug reading in the start and stop times.
http://www.mediafire.com/?2mmdfzn9g44
plun
August 27th, 2007, 09:37 AM
Ok this version should work. There was a bug reading in the start and stop times.
Yup... it does :)
Some findings... default size for an icon is 100x100
<display-name lang="sv">Kanal 5</display-name>
<icon src="http://xmltv.tvsajten.com/chanlogos/kanal5.se.png" />
I knows its easy to scale down with Gimp....but I am lazy...:p
Maybe you can take code from OnTV ?
http://johan.svedberg.com/projects/coding/ontv/
Everything to make it possible to remove gnomes panels and use AWN and Screenlets instead........:o:D
James
August 27th, 2007, 11:54 AM
I have created an updated version that automatically resizes the logo image no matter what the size it is.
Maybe in a future version it will automatically download the logo if it exists online, but that involves writing threads. I think it is probably best to find as many bugs as possible before adding complex features.
http://www.mediafire.com/?byxpd3mwmy4
plun
August 27th, 2007, 04:27 PM
OK.... your screenlets works... :)
http://pix.nofrag.com/6/6/d/4d59ac8b5a00ae5993101a6ae8666t.jpg (http://pix.nofrag.com/6/6/d/4d59ac8b5a00ae5993101a6ae8666.html)
James
September 2nd, 2007, 04:18 AM
Hi all,
I have created a new version of this screenlet. This version seems pretty stable and should be ok for people to use. There have been a number of bugs fixed and I have added the following features.
An icon for the screenlet
A new theme which has a more transparent background image.
The start time is displayed for each show insead of the words "Now" and "Next"
Channel icons are automatically resized to fit in the space
Icons can be downloaded from the Internet if the xml file has a valid URL. The url must point to a .png file for the time being. To download the missing icons use the right click menu option. Note: This feature does not use threads so the Screenlet will become unresponsive until the file is downloaded, but this should be ok as most icons are very small in size.
You can show more than 6 channels at a time (currently up to 20)
http://img470.imageshack.us/img470/5016/whatsontvscreenshotzl9.th.jpg (http://img470.imageshack.us/my.php?image=whatsontvscreenshotzl9.jpg)
Package: http://www.mediafire.com/download.php?6xl1zd1gzcr
If anyone has any feature requests or knows of a better way to display the information in the screenlet, let me know in this thread. If there arn't any major problems I will add this screenlet to the www.screenlets.org web site.
James.
TheShadowZero
September 2nd, 2007, 07:21 AM
is there anyway to get the xmltv program and requirements for non ubuntu users? to install from source i have to make install in every directory for the 10+ required modules and then make xmltv itself
James
September 2nd, 2007, 08:02 AM
is there anyway to get the xmltv program and requirements for non ubuntu users? to install from source i have to make install in every directory for the 10+ required modules and then make xmltv itself
What do you mean by the xmltv program and requirements?
Do you mean the tv_grab_xx program which actually creates the xml file?
TheShadowZero
September 2nd, 2007, 08:15 AM
i mean this:http://xmltv.org/wiki/
the sourceforge link on the page has two packages, a reqs and an xmltv
you need to install the requirements to install the xmltv
or am i completely in the wrong place
James
September 2nd, 2007, 08:31 AM
I've never installed xmltv that way.
I have installed the xmltv package before but only by using the Ubuntu repositories. It handled all the requirements and set it all up for me. So i'm not sure how you would do it if you aren't using Ubuntu.
Is there a way you can apt-get from the Ubuntu repositories even if you aren't using Ubuntu ? I haven't been using Linux for very long so i'm not too sure. Maybe someone else can help.
James.
plun
September 2nd, 2007, 11:54 AM
Thanks James...!
Some findings.
- Themes are "invisible" if you choose > properties > tab themes
- xmltv, grab, list , update ...... ?
http://ubuntuforums.org/showthread.php?t=370534&highlight=xmltv
(this howto must be working for all dists after install)
So maybe everyone must setup a cronjob or its "build in" with your Screenlet ?
EDIT some terminal output errors
plun@dunder:~/awn-curves$ screenlets-manager
DAEMON FOUND!
WhatsOnTV
Launch WhatsOnTV
Launching Screenlet from: /usr/local/share/screenlets/WhatsOnTV/WhatsOnTVScreenlet.py
Logging output goes to: $HOME/.config/Screenlets/WhatsOnTVScreenlet.log
REGISTER screenlet: WhatsOnTVScreenlet
Quit WhatsOnTV
UNREGISTER screenlet: WhatsOnTVScreenlet
Launch WhatsOnTV
Launching Screenlet from: /usr/local/share/screenlets/WhatsOnTV/WhatsOnTVScreenlet.py
Logging output goes to: $HOME/.config/Screenlets/WhatsOnTVScreenlet.log
REGISTER screenlet: WhatsOnTVScreenlet
(WhatsOnTVScreenlet.py:28235): libgnomevfs-CRITICAL **: gnome_vfs_get_uri_from_local_path: assertion `g_path_is_absolute (local_full_path)' failed
Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/screenlets/options.py", line 881, in __render_cell
'</span></small>\n<i><small>by '+str(attrib[3])+'</small></i>'
TypeError: cannot concatenate 'str' and 'NoneType' objects
Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/screenlets/options.py", line 881, in __render_cell
'</span></small>\n<i><small>by '+str(attrib[3])+'</small></i>'
TypeError: cannot concatenate 'str' and 'NoneType' objects
Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/screenlets/options.py", line 881, in __render_cell
'</span></small>\n<i><small>by '+str(attrib[3])+'</small></i>'
TypeError: cannot concatenate 'str' and 'NoneType' objects
Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/screenlets/options.py", line 881, in __render_cell
'</span></small>\n<i><small>by '+str(attrib[3])+'</small></i>'
TypeError: cannot concatenate 'str' and 'NoneType' objects
Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/screenlets/options.py", line 881, in __render_cell
'</span></small>\n<i><small>by '+str(attrib[3])+'</small></i>'
TypeError: cannot concatenate 'str' and 'NoneType' objects
Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/screenlets/options.py", line 881, in __render_cell
'</span></small>\n<i><small>by '+str(attrib[3])+'</small></i>'
TypeError: cannot concatenate 'str' and 'NoneType' objects
Gtk-Message: (for origin information, set GTK_DEBUG): failed to retrieve property `GtkComboBox::appears-as-list' of type `gboolean' from rc file value "((GString*) 0x877eb80)" of type `GString'
UNREGISTER screenlet: WhatsOnTVScreenlet
Launch WhatsOnTV
Launching Screenlet from: /usr/local/share/screenlets/WhatsOnTV/WhatsOnTVScreenlet.py
Logging output goes to: $HOME/.config/Screenlets/WhatsOnTVScreenlet.log
REGISTER screenlet: WhatsOnTVScreenlet
Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/screenlets/options.py", line 881, in __render_cell
'</span></small>\n<i><small>by '+str(attrib[3])+'</small></i>'
TypeError: cannot concatenate 'str' and 'NoneType' objects
Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/screenlets/options.py", line 881, in __render_cell
'</span></small>\n<i><small>by '+str(attrib[3])+'</small></i>'
TypeError: cannot concatenate 'str' and 'NoneType' objects
Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/screenlets/options.py", line 881, in __render_cell
'</span></small>\n<i><small>by '+str(attrib[3])+'</small></i>'
TypeError: cannot concatenate 'str' and 'NoneType' objects
Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/screenlets/options.py", line 881, in __render_cell
maluze
September 2nd, 2007, 05:29 PM
I got the same terminal output when I tried to add the XMLTV file...
The Screenlet apparently can't read the XMLTV file??
badabing
September 2nd, 2007, 09:22 PM
loving this one. have missed having tv schelude on desktop since i had samurize in xp years ago. i would request the possibility of changing fonts and set how long between the xmltv data is reloaded.
and i dont know how tooltips work in screenlets but it would be nice if a more torough program description coudl apepar in a tooltip when mouse over. i know this data is in the xmltv file
TheShadowZero
September 3rd, 2007, 01:29 AM
james i may be able to get it from the repositiories but they would still be .debs and fedora uses .rpms
but thanks anyway...
James
September 3rd, 2007, 10:45 AM
Hi,
The config data for the themes was in the wrong format, and that is what was producing a lot of those terminal errors, and was why the themes weren't listed in the properties windows.
I have fixed it up and attached a new version of the screenlet.
http://www.mediafire.com/?bgrdw1vg4lj
Maluze, if you still can't load the xml file please paste your terminal log and i will try and debug it.
James
plun
September 3rd, 2007, 12:14 PM
I have fixed it up and attached a new version of the screenlet.
http://www.mediafire.com/?bgrdw1vg4lj
James
Congrats James ! A working screenlet...:D
The challenge remains about howto handle xlmtv, grab and sort.
Somehow a manual must be included or "built in".
:)
James
September 3rd, 2007, 12:55 PM
On my machine i have a cron job setup to automatically look after the grabbing of the data and sorting it. That is because i use the same generated xml file in many places like; OnTV applet, my web scheduler program to record my shows, and the screenlet.
I'm not sure if it is a good idea for the screenlet to look after running the grab automatically when there are stable ways to do this using something like cron.
I could always add a right click option to perform the grab manually based on a command line setup in the options. Although i think it would be best to stay away from this because i am sure it will just cause major hassles with things like; the grab program causing the screenlet to crash, or the grab being run too often etc.
If anyone has a good idea for how to handle it I will try and implement it.
In the next version i will add the features mentioned by badabing about customizing the font, and setting how often the xmltv file should be reloaded.
maluze
September 3rd, 2007, 02:55 PM
Okay, I got it to work, kind of...
I got the xml file. but when i tried to sort it, I got this error:
justin@justin-desktop:~$ tv_sort --output=.listings.xml .listings.xml
cannot parse date '20070903004000 (-0400)' at /usr/bin/tv_sort line 525
justin@justin-desktop:~$
and the TV listings are out of order: it says, for example, (9:40) NBC News Today at 5:00 (PM); where does it get "9:40" from???
and how do i get the TV logos? the "download channel logos" doesn't work...
there needs to be something easier than this XMLTV stuff...
plun
September 3rd, 2007, 04:46 PM
Okay, I got it to work, kind of...
I got the xml file. but when i tried to sort it, I got this error:
justin@justin-desktop:~$ tv_sort --output=.listings.xml .listings.xml
cannot parse date '20070903004000 (-0400)' at /usr/bin/tv_sort line 525
justin@justin-desktop:~$
and the TV listings are out of order: it says, for example, (9:40) NBC News Today at 5:00 (PM); where does it get "9:40" from???
and how do i get the TV logos? the "download channel logos" doesn't work...
there needs to be something easier than this XMLTV stuff...
This is the challenge and its really difficult to make this screenlet to handle
this without manual commands.
We take this URL again
http://ubuntuforums.org/showthread.php?t=370534&highlight=xmltv
I first took every channel for my country, giant file....:p
I then took out 5 channels with
sudo tv_grab_na_dd --configure (sudo tv_grab_se_swedb --configure for me)
After this manual work it would be nice if this screenlet handles the cronjob
#! /bin/sh
tv_grab_na_dd --output=/home/(user)/.listings.xml
tv_sort --output=/home/(user)/.listings.xml /home/(user)/.listings.xml
So test a configure again with a few channels.
:)
James
September 3rd, 2007, 10:36 PM
Just so you know the screenlet should sort the data by itself as it reads in the xml file so you shouldn't need to do a sort.
Maluze, could you zip up a copy of your xml file and put it online somewhere so i can get a copy of it and check what is going wrong. I'm not at home at the moment so i will check later.
maluze
September 4th, 2007, 03:13 AM
^ sure thing! I uploaded it to megaupload, here is the link:
http://www.megaupload.com/?d=M2661K1U
James
September 4th, 2007, 10:08 AM
maluze,
Your xml file is not in the valid xmltv format. The start date "20070903004000 (-0400)" should not have brackets around the time offset. That is why the tv_sort program is not working.
At the moment my screenlet does not handle time offsets so im not sure how this should be handled.
From the listing.xml file you put online can open it and look for the program "How I Met Your Mother". The start time for it in the xml file is 20070904004000 (-0400). The screenlet will say that this show starts at:
40 minutes past midnight on 4th September 2007
Is this correct, or what time does it actually start?
James.
maluze
September 4th, 2007, 03:47 PM
first off, TV programs almost always start at the beginning of the hour (:00), or half hour (:30)
I have no idea when It actually starts, according to a TV schedule it starts around 8:00 pm.
I simply used the XMLTV listings explained in the Ubuntu how-to link, set it to Eastern Daylight Time (-0400), and it pretty much did the rest...
fabs
September 8th, 2007, 06:21 PM
i made some logos for my tv stations (germany) and called them ARD.png for example.
they are 60x60 and in the logos folder, but they are not shown.
what could be the problem?
fabs
September 8th, 2007, 07:12 PM
i got it.
after having a look at the xml-file i found the right channel-ids.
maybe it would be usefull if the right channel-id would appear in the channels menu of the screenlet.
ricsi-pontaz
May 16th, 2008, 03:11 PM
Very good screenlet, gratulations!
But this is a stopped project?
davidw89
August 9th, 2008, 03:40 PM
what's the latest version.
why no read me on how to set it up?
It looks like you got it working with Australian channels. Mind sending me the xmltv file? Or help me set it up as i have no idea..
aantn
August 17th, 2008, 02:16 PM
Argh, I'm not sure what the status is either.
If the source files specify an appropriate license, we should be able to move this into extras and to fix it up.
/me resists ranting on the need to keep all applets on bzr
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.