parsing xml to create categories and video lists in the sample player
#1
I'm not sure if this topic has been covered somewhere else, I did read go through about 50 pages of topics and didn't see anything relevant at all. I hope I am posting this in the correct area, if not please forgive a newbie and kindly direct me where I should go. I will gladly move the post there..

So here is my situation. I have a streaming video web site since 1998, Currently we are streaming "by demand" video using IIS Smooth Streaming and the "24-7 live" streaming channels use HLS (.m3u8) We stream these formats on the website but mostly through Roku with over 30,000 subscribers.. (All 100% free as we have been since we were BBS/usenet hub back in 1992 through today).

Ok thats the background. So since we have most of the videos already indexed for Roku in XML files I figured there must be a "proper" hopefully easy way to parse the same files for use on the Kodi channel we want to develop. The thing is, Python is so dissimilar to brightscript (which I am a layman at but good enough to make roku work well) and classic asp that I am completely lost as to where to begin, (if it hasn't been done already).

So here's the sample xml files...

categories.xml contains

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<categories>

<!-- banner_ad: optional element which displays an at the top level category screen -->
<banner_ad sd_img="http://rokudev.roku.com/rokudev/examples/videoplayer/images/missing.png" hd_img="http://rokudev.roku.com/rokudev/examples/videoplayer/images/missing.png"/>

<category title="Professional Wrestling" description="Sports" sd_img="http://www.tvbydemand.com/roku/images/sports_button-sd.jpg" hd_img="http://www.tvbydemand.com/roku/images/sports_button-hd.jpg">
<categoryLeaf title="Loco Wrestling" description="" feed="http://www.tvbydemand.com/roku/locowrestling.xml"/>
<categoryLeaf title="UIWA WorldWide Wrestling" description="" feed="http://www.tvbydemand.com/roku/UIWA.xml"/>
</category>
<category title="Music" description="Music" sd_img="http://www.tvbydemand.com/roku/images/music_button-sd.jpg" hd_img="http://www.tvbydemand.com/roku/images/music_button-hd.jpg">
<categoryLeaf title="Aim For Grey" description="Aim For Grey" feed="http://www.tvbydemand.com/roku/AimForGrey.xml"/>
<categoryLeaf title="VooDoo Moon" description="VooDoo Moon" feed="http://www.tvbydemand.com/roku/VooDooMoon.xml"/>
</category>
</categories>
</xml>
___________________

each category creates the index for the "categoryleaf" which is basically a subcategory of the main. Each subcategory ("categoryleaf") has another xml file that contains the list of videos to choose from).. so

locowrestling.xml contains

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<feed>
<item sdimg="http://www.tvbydemand.com/images/fnm.jpg" hdimg="http://www.tvbydemand.com/images/fnm.jpg">
<title>Friday Night Madness 06-12-2015</title>
<contentid>1</contentid>
<contenttype>Streaming video</contenttype>
<contentquality>SD</contentquality>
<streamformat>ISM</streamformat>
<media>
<streamquality>SD</streamquality>
<streambitrate>3000</streambitrate>
<streamurl>http://www.tvbydemand.com/media2/iis/fnm/2015-06-12/finished.ism/manifest</streamurl>
</media>
<synopsis>Friday Night Madness 06-12-2015The Last FNM recorded at the Light House.New Season coming in December 2015!!</synopsis>
<genres>Sports</genres>
<runtime>5418</runtime>
<rating>G</rating>
<releasedate>11/23/2015</releasedate>
<director>TVByDemand.com</director>
</item>
<item sdimg="http://www.tvbydemand.com/images/fnm.jpg" hdimg="http://www.tvbydemand.com/images/fnm.jpg">
<title>Friday Night Madness 06-05-2015</title>
<contentid>2</contentid>
<contenttype>Streaming video</contenttype>
<contentquality>SD</contentquality>
<streamformat>ISM</streamformat>
<media>
<streamquality>SD</streamquality>
<streambitrate>3000</streambitrate>
<streamurl>http://www.tvbydemand.com/media2/iis/fnm/2015-05-06/finished.ism/manifest</streamurl>
</media>
<synopsis>the second to last episode of Friday Night Madness Season 3</synopsis>
<genres>Sports</genres>
<runtime>4800</runtime>
<rating>G</rating>
<releasedate>10/13/2015</releasedate>
<director>TVByDemand.com</director>
</item>
</feed>
</xml>

These xml files are created by scripts I wrote about 8 years in classic asp and played by roku in scripts I wrote in brightscript also about 8 years ago. so I'm a bit rusty even in that let alone something so different with python, but I learn very quickly when I know where to start..

Can anyone help me out at all in this? Maybe just a place to start on parsing xml or maybe his has been done already and there is sample code I can dissect and learn from.

Thanx in advance!
Reply
#2
(2017-02-24, 08:01)mitchstein443 Wrote: I'm not sure if this topic has been covered somewhere else, I did read go through about 50 pages of topics and didn't see anything relevant at all. I hope I am posting this in the correct area, if not please forgive a newbie and kindly direct me where I should go. I will gladly move the post there..

*Surprised mode on*
As I've repeatedly said, there seems to be a common misconception among novice addon developers that Python in Kodi has almost nothing common with a known and well-established programming language from python.org, except maybe for its name. Well, it is not true, and Python, as I've said, is a well-established general-purpose programming language that has tools for almost everything, either in its vast Standard Library or among a host of third-party packages. And a simple query in Google "parse xml with python" produces a number of relevant results, including tutorial videos and such.
*Surprised mode off*

I understand that you may be new to Python but I would recommend to learn at least the language basics, because IMO blind copy-pasting someone else's code won't help you much.
Reply
#3
Well, I am working on the basics. and pretty much python seems to be like every other modernized programming language. I've been programming since 1979, I've been running internet servers since before there was a web, placing my phone in a cradle and ordering 10+ dedicated lines to my house for my BBS. I'm just an old time developer in a child's world slowly catching up. But believe me the disciplines, principals and background are well established. It's like a brain surgeon from china trying to operate in an American hospital with out a translator.

Anyway, if I understand your statement, Kodi platform confirms to 100% of the python language, if it can be done in python it can be done on the Kodi platform and all the "best practices" of python transform perfectly to the Kodi environment? I will proceed as if that is a true statement.

I also posted the question because, it is very possible that I am not the first one to stream on both Roku and Kodi platforms, therefore, I will simply be reinventing the wheel or taking the scenic route as opposed to customizing and maybe (or not) improving the way someone else did it already. I share all my code and do everything for free since I was a boy, that is the way the internet was intended to be, a free exchange of ideas and solutions. Not this commercialized for profit crap that is slowly but surely taking it over today.
Reply
#4
BeautifulSoup works well for me when I need to parse .xml or html. I've also used ElementTree on occasion.

As @Roman_V_M suggested, searching google for 'parse xml with python' will return plenty of results. I'd suggest adding 'stackoverflow' to the query, as I've found that site to be an invaluable source of tutorials and information whenever I have coding questions.
Kodi Nexus (20.2) on Dell Optiplex 980 Lubuntu 22.04 | Kodi Matrix on HTPC Lubuntu 20.04 | My Add-ons | Legacy Repo | Matrix Repo
>>>>> Newest MetalChris Addons: Local Now | Redbox | NEWSnet| NHL Radio | Weather Unlocked
Reply
#5
MIT xmltodict is what I use personally but I prefer a dictionary format over xml myself
Reply
#6
So I am doing my python learning. As I thought, python is pretty simple. I am wondering, is kodi based on python 2.x or 3.0? if it is based on 2.x what is the plan for when the rest of the industry converts to 3.x and backwards compatibility is no longer supported? Will kodi change as well? stay on the 2.x platform as long as feasible or will kodi immediately or shortly thereafter change over and make the addon developers redo all thier work?

I am asking this, because when google (android) did this just 3 years ago I stopped making android apps, and many many moons ago when apple forced all of us programmers off the apple II platform to the lisa and then discontinued Lisa and forced us all to Mac I stopped supporting apple.. Just wanna be sure I am not wasting my time learning a dead language and make sure I am learning the proper version.
Reply
#7
May I just enquire please whether you have a copyright licence for everything on your site? Or is it all supposed to be public domain?
If I have helped you or increased your knowledge, click the 'thumbs up' button to give thanks :) (People with less than 20 posts won't see the "thumbs up" button.)
Reply
#8
(2017-02-25, 20:14)mitchstein443 Wrote: So I am doing my python learning. As I thought, python is pretty simple. I am wondering, is kodi based on python 2.x or 3.0? if it is based on 2.x what is the plan for when the rest of the industry converts to 3.x and backwards compatibility is no longer supported? Will kodi change as well? stay on the 2.x platform as long as feasible or will kodi immediately or shortly thereafter change over and make the addon developers redo all thier work?

Currently Kodi is using Python 2.7 on all platforms. There have been talks about moving to Python 3. The problem is huge and 2-fold: First, Python 3 is backward incompatible and the upgrade will break 99% if not all existing addons. And second (most importantly), someone has to do this -- integrate Python 3 into Kodi and re-work Kodi Python API to be compatible with Python 3. This is an immense task with no immediate benefits, so at this point there are no plans to move to Python 3.

BTW, previously I was against such migration, but now I think that ultimately it would be for the best (if it ever happens). Python 3 is better than 2 in many aspects. For example, as a resident of a country with a non-Latin writing system I very much appreciate clear separation between textual and binary data.

Quote:I am asking this, because when google (android) did this just 3 years ago I stopped making android apps, and many many moons ago when apple forced all of us programmers off the apple II platform to the lisa and then discontinued Lisa and forced us all to Mac I stopped supporting apple.. Just wanna be sure I am not wasting my time learning a dead language and make sure I am learning the proper version.

Well, it's not like you are developing a BPM system for a big company, where a mistake in architecture planning may cost you millions. Addons are just hobby projects for Kodi enthusiasts. And Python 2 and 3 are not that different, so it is absolutely possible and not very difficult to write code that is compatible with both 2 and 3. Of course, at this point it is unknown how Kodi Python API will look if it is ever converted to Python 3, but to my knowledge SWIG (the tool that is used to expose Kodi core functionality to Python) has facilities to provide consistent behavior in Python 2 and 3.
Reply
#9
You are 100% right that it is not a major app for major dollars. You are also correct that it is a hobby. However, my hobby is providing free programing to as many viewers as possible. As I said before, I do not want to waste time now learning an entire language only to find out in 3 months the app I poured time into is now broken because the developer decided to upgrade the base system.. The reason I have only settled for developing for the Roku system so far, is because, I developed my channel there over 7 years ago, and have not looked at brightscript since. They've upgraded from the roku 1 to the roku 4 already and it still works.

Anyway, got my answers and will keep an eye on Kodi for future development, in the mean time gonna go write some python 3.0 scripts to play with so I'm ready when Kodi is.

As for the content, all of the by-demand content I either own the rights to soley or have an agreement in place with the rights holder. Most of it I own and TVByDemand produced or Dream Catchers Multimedia produced. There was one other production company we used to partner with but I can not recall the company name, the owner is David Virgillio though. I also own Loco Wrestling and purchased half of Devastation Wresting. They are hobbies as well, created to supply content in the early days of TVByDemand. Now I am partnered with Greater Philadelphia Area Music Promotions for content and Dream Catchers does the production work.
Reply
#10
I am pleased with your last para, as we don't support copyright breach. Thanks for clarifying.

It is important for you to note that any Kodi addon WILL need to be maintained. Kodi's API is always under development, most addons need changes when Kodi goes to a new version. Addons need skinning, which isn't necessarily your responsibility, but skin devs will call on you for help with that. The change from python 2 to 3 may be the least of your worries!

We do welcome new interesting addons for legal content, and there are people who will help. We hope you will carry on.

Just one thing, the videos I have watched so far from your site via a browser seem to have black sidebars both vertically and horizontally. Is this my browser, or problems with your vids?

Cheers, nickr
If I have helped you or increased your knowledge, click the 'thumbs up' button to give thanks :) (People with less than 20 posts won't see the "thumbs up" button.)
Reply
#11
All the videos are encoded by Sorenson Squeeze 9.x using the main concept H264 codec and mostly default settings for IIS Smooth streaming. The live channel is encoded in real time using a dediated windows 10 pro under vmix 18.x beta, using the same codecs. All source files are encoded the same way, they are rtmp from NJ to a server in harrisburg pa and then set off to servers around the world as demand grows (a proprietary load balancing system I developed many moons ago) so it is possible that you could have connected to a server that is having a problem. I run this on a very tight budget out of my pocket some of the older servers which come online during peak periods are upwards of 10-12 years old and could have minor issues.. I'll check logs and what nots and make the auto maintanance is running on them properly and they are diagnosing correctly.
Reply
#12
Oh, 90% of the videos though are encoded at SD and 14:3.. which may explain the black bars on the side.. Only the live channel 1 and very few of the newer videos are encoded at 16:9 HD.. I spend about 25K a year to keep this system running and 90% of that is spent on Bandwidth and drive space..
Reply

Logout Mark Read Team Forum Stats Members Help
parsing xml to create categories and video lists in the sample player0