Kodi Community Forum
[RELEASE] PseudoTV Addon: Virtual EPG and TV Channel Surfing Script - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: Add-on Support (https://forum.kodi.tv/forumdisplay.php?fid=27)
+---- Forum: Program Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=151)
+----- Forum: PseudoTV / PseudoTV Live (https://forum.kodi.tv/forumdisplay.php?fid=231)
+----- Thread: [RELEASE] PseudoTV Addon: Virtual EPG and TV Channel Surfing Script (/showthread.php?tid=90738)



- jtucker1972 - 2011-02-17

zepfan Wrote:Night does in some view types.

Here's the answer:

Whenever you go to TV Shows in XBMC it makes a SQL query to get the tvshows data. The studio information resides in the tvshow table so it is available in the returned data to be displayed in the Night skin when you are viewing TV Shows. Here is the SQL that gets executed by XBMC to pull the tvshows for the tvshow window.

GetTvShowsByWhere query:
Code:
SELECT tvshow.*,path.strPath AS strPath,counts.totalcount AS totalCount,counts.watchedcount AS watchedCount,counts.totalcount=counts.watchedcount AS watched FROM tvshow JOIN tvshowlinkpath ON tvshow.idShow=tvshowlinkpath.idShow JOIN path ON path.idpath=tvshowlinkpath.idPath LEFT OUTER join (    SELECT tvshow.idShow AS idShow,count(1) AS totalcount,count(files.playCount) AS watchedcount FROM tvshow     JOIN tvshowlinkepisode ON tvshow.idShow=tvshowlinkepisode.idShow     JOIN episode ON episode.idEpisode=tvshowlinkepisode.idEpisode     JOIN files ON files.idFile=episode.idFile     GROUP BY tvshow.idShow) counts ON tvshow.idShow=counts.idShow

The next queries retrieve the seasons data for the tvshow selected.

GetStackedTvShowList query:
Code:
select idShow from tvshow where c00 like (select c00 from tvshow where idShow=67) order by idShow

TV studio data is stored in tvshow.c14 field. Based on the sql query below, this data is returned for the season view so it could be shown on this skin window.

GetSeasonsNav query:
Code:
select episode.c12,path.strPath,tvshow.c00,tvshow.c08,tvshow.c14,tvshow.c13,count(1),count(files.playCount) from episode join tvshowlinkepisode on tvshowlinkepisode.idEpisode=episode.idEpisode join tvshow on tvshow.idShow=tvshowlinkepisode.idShow join files on files.idFile=episode.idFile  join tvshowlinkpath on tvshowlinkpath.idShow = tvshow.idShow join path on path.idPath = tvshowlinkpath.idPath where tvshow.idShow = 67  group by episode.c12

Next query run gets whether the tv show has an associated movie linked to it. No tv studio available from this query.

GetMoviesByWhere query:
Code:
select * from movieview join movielinktvshow on movielinktvshow.idMovie=movieview.idMovie where movielinktvshow.idShow = 67

Next query doesn't return studio data.

GetStackedTvShowList query:
Code:
select idShow from tvshow where c00 like (select c00 from tvshow where idShow=67) order by idShow

Finally, we get to episodes query. The episodeview does return the studio data as strStudio so it is available to be displayed in the tv episode window of a skin.

GetEpisodesByWhere query:
Code:
select * from episodeview where idShow = 67 and (c12=1 or (c12=0 and (c15=0 or c15=1)))

So at this point we can see where a skin has access to the data via the standard video tvshow windows.

Now let's look at how XBMC queries the data when using playlists.

TVShow playlist filter by studio = cbs executes the following SQL. Since we already know studio data is stored in tvshow table, it would be available, but tvshow playlists don't return episodes to watch, just a list of the tv shows.

GetTvShowsByWhere query:
Code:
SELECT tvshow.*,path.strPath AS strPath,counts.totalcount AS totalCount,counts.watchedcount AS watchedCount,counts.totalcount=counts.watchedcount AS watched FROM tvshow JOIN tvshowlinkpath ON tvshow.idShow=tvshowlinkpath.idShow JOIN path ON path.idpath=tvshowlinkpath.idPath LEFT OUTER join (    SELECT tvshow.idShow AS idShow,count(1) AS totalcount,count(files.playCount) AS watchedcount FROM tvshow     JOIN tvshowlinkepisode ON tvshow.idShow=tvshowlinkepisode.idShow     JOIN episode ON episode.idEpisode=tvshowlinkepisode.idEpisode     JOIN files ON files.idFile=episode.idFile     GROUP BY tvshow.idShow) counts ON tvshow.idShow=counts.idShow WHERE ('1')

So next lets look at what is returned for an episode playlist and how XBMC queries the database for it.

Episode playlist filter by genre = comedy limit 50. This playlist queries the episodeview which also contains the studio data in the strStudio field returned. Looks good right?

GetEpisodesByWhere query:
Code:
select * from episodeview WHERE (idShow in (select idShow from genrelinktvshow join genre on genre.idGenre=genrelinktvshow.idGenre where genre.strGenre LIKE 'Comedy')) ORDER BY RANDOM() LIMIT 50


Let's try to create a playlist to query for cbs as the studio. The data is in episodesview so it could be queried against to return episodes where strStudio=cbs

Here is the playlist xml.

Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<smartplaylist type="episodes">
    <name>test</name>
    <match>all</match>
    <rule field="studio" operator="is">cbs</rule>
    <limit>50</limit>
    <order direction="ascending">random</order>
</smartplaylist>

which executes the following sql in XBMC

Code:
GetEpisodesByWhere query: select * from episodeview WHERE ('1') ORDER BY RANDOM() LIMIT 50

See what happened? The XBMC code does not know how to handle rule field=studio so it just creates a random episode playlist. This would be the same as not passing a rule at all.

This is why we cannot create a playlist by studio so we could have a CBS channel, HBO channel, etc.

I know this was long but hopefully it can put to rest what the capabilities are for playlists and how XBMC converts them to SQL database queries.


thanks - ryan03rr - 2011-02-17

just a note incase there any space cadets out there like me...

when converting from winblows... to *nix
make sure you respect "C"hannel_1 vs "c"hannel_1

just a hint since i spent a hour confused ....

btw theres a missspelling in the pluginin when scanning i say "chanbles"

awsome plugin thanks again....


- zepfan - 2011-02-17

jtucker1972 Wrote:See what happened? The XBMC code does not know how to handle rule field=studio so it just creates a random episode playlist. This would be the same as not passing a rule at all.

This is why we cannot create a playlist by studio so we could have a CBS channel, HBO channel, etc.

I know this was long but hopefully it can put to rest what the capabilities are for playlists and how XBMC converts them to SQL database queries.

Ahh. Oh well, worth a try.

ryan03rr Wrote:just a note incase there any space cadets out there like me...

when converting from winblows... to *nix
make sure you respect "C"hannel_1 vs "c"hannel_1

just a hint since i spent a hour confused ....

btw theres a missspelling in the pluginin when scanning i say "chanbles"

awsome plugin thanks again....

Yea, jason and I had some issues with that. Nix is case sensitive.


- Jason102 - 2011-02-18

Ok, so an update. This duration issue has really been bugging me. XBMC doesn't give a developer a way to set or get a duration that isn't already known without playing it, and that wasn't so much of an option. So I took the slightly ridiculous route. I've spent the last few days reading video file format specs. I then wrote routines that will open the video files, read the durations, and use those. Currently, I only support 3 file formats: AVI, MKV, and MP4/M4V. My library is 99% composed of these types, so I figured that was good enough for the moment. I've tested the routines on most of my files and nearly everything retrieved a proper duration. The file that didn't work (a random MKV) didn't get any duration, so it shouldn't screw up anything.

The code will use the XBMC duration if it's there, or it will attempt to determine the duration directly from the file itself if it isn't. The code is in stable-pre if anyone wants to try it out. It's not as well tested as it should be (as is true with so much of my work) but it is performing well for me. Try it out, report any bugs. If things go well, it'll be in there with the release this weekend!


- mwkurt - 2011-02-18

Jason,

Is this new code embedded in PseudoTV or is it something that we have to download separately? Is there a special link we need as I don't see anything in your last post?

Thanks,
Mark


- Jason102 - 2011-02-18

It's embedded...just more python that I wrote to do it.


- branlr - 2011-02-18

Damn, you are sick Jason.

All hail the greatest addon ever!

For some reason, though, the new stable-pre version is failing for me (win 7 x64). I'll keep playing with it, though.

@mwkurt--check out the link to the repository on the first post in the thread, and change the branch to stable-pre.


- Sranshaft - 2011-02-18

Got a bit bored while working on a Confluence skin so I decided to whip up one for Jezz_X's SLik skin.

Image

Image

Download from here and place the skin.slik folder into your %appdata%\XBMC\addons\script.pseudotv\resources\skins folder.

Jason102 Wrote:Ok, so an update. This duration issue has really been bugging me. XBMC doesn't give a developer a way to set or get a duration that isn't already known without playing it, and that wasn't so much of an option. So I took the slightly ridiculous route. I've spent the last few days reading video file format specs. I then wrote routines that will open the video files, read the durations, and use those. Currently, I only support 3 file formats: AVI, MKV, and MP4/M4V. My library is 99% composed of these types, so I figured that was good enough for the moment. I've tested the routines on most of my files and nearly everything retrieved a proper duration. The file that didn't work (a random MKV) didn't get any duration, so it shouldn't screw up anything.

The code will use the XBMC duration if it's there, or it will attempt to determine the duration directly from the file itself if it isn't. The code is in stable-pre if anyone wants to try it out. It's not as well tested as it should be (as is true with so much of my work) but it is performing well for me. Try it out, report any bugs. If things go well, it'll be in there with the release this weekend!

Good lord man, going above and beyond! Laugh I'll give it a thorough testing and see if I can break it.

@Jason: I'll have the Confluence skin ready for you tomorrow. I ran into two things that'll need your fix. [STRIKE]As you can see in the screenshot above, the time / date labels aren't inheriting the textcolor setting in the skin for some reason.[/STRIKE]

I also needed to add in a font="font11" into the EPG code where the listing buttons are created. This should help displaying videos with longer names.


- Jason102 - 2011-02-18

@Sranshaft: the skin, of course, looks excellent. I worry about changing the font of the buttons in the EPG, though. I want to make sure that the skin looks good on a TV and as it is my wife can't really read the text on our bedroom TV. Smaller may not help with readability.

@branlr: Still not working? Is it failing while starting up, or while bringing up the EPG? If you can get a debug log, that'd be great.


- tungmeister - 2011-02-18

Sranshaft Wrote:Got a bit bored while working on a Confluence skin so I decided to whip up one for Jezz_X's SLik skin.

How about giving fusion some love? :p


- Sranshaft - 2011-02-18

tungmeister Wrote:How about giving fusion some love? :p

I'll look into it as soon as I get through some of the other ones. Cool


- zepfan - 2011-02-19

Sranshaft Wrote:I'll look into it as soon as I get through some of the other ones. Cool
Which ones do you have planned? Can we use one's with different skins? Example slik with alaska?


- Sranshaft - 2011-02-19

zepfan Wrote:Which ones do you have planned? Can we use one's with different skins? Example slik with alaska?

You can but I wouldn't recommend it. The font sizes vary depending on the skin and because of that, the text will not look as planned. Also, the skins can have images that depend on the skin they were created for. This is particularly the case in the SLik skin where the majority of the images displayed come directly from the SLik's skin folder and not from PseudoTV.

As for which skins I have planned...I'm currently finishing up one for Confluence. After that, I'm not sure. It'd be ideal if the skin's designer created a skin for PseudoTV as they have a better idea of what they want to see.

At the moment though, I'm working on skinning the addon ForumBrowser for reFocus and a few other skins so it may be a while before I can get back to doing some for Alaska, etc.


- zepfan - 2011-02-19

Sranshaft Wrote:You can but I wouldn't recommend it. The font sizes vary depending on the skin and because of that, the text will not look as planned. Also, the skins can have images that depend on the skin they were created for. This is particularly the case in the SLik skin where the majority of the images displayed come directly from the SLik's skin folder and not from PseudoTV.

As for which skins I have planned...I'm currently finishing up one for Confluence. After that, I'm not sure. It'd be ideal if the skin's designer created a skin for PseudoTV as they have a better idea of what they want to see.

At the moment though, I'm working on skinning the addon ForumBrowser for reFocus and a few other skins so it may be a while before I can get back to doing some for Alaska, etc.
I see. Thanks for the response, and all your work!


- jtucker1972 - 2011-02-19

@Jason102, unbelievable what you are doing. I am going to download your latest version and do some testing with it.