Kodi Community Forum
HOW-TO build plugins for XBMC with python - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: General Support (https://forum.kodi.tv/forumdisplay.php?fid=111)
+---- Forum: OS independent / Other (https://forum.kodi.tv/forumdisplay.php?fid=228)
+---- Thread: HOW-TO build plugins for XBMC with python (/showthread.php?tid=41695)



HOW-TO build plugins for XBMC with python - Voinage - 2008-12-07

See wiki => http://wiki.xbmc.org/?title=HOW-TO_write_plugins_for_XBMC
or download http://voinage-xbmc-plugins.googlecode.com/files/Plugin-tutorial.rar

Additional plugin examples to start you off is in my signature below Wink


- Rookie - 2009-01-08

Hello Voinage.Thanks for the tut.I have a question though.Would it be easier starting out fixing a old pugin to get used to the layout or just go for a new one?


match results - GoldStar - 2009-02-07

Thank you Voinage for writing this tutorial. Nod I am getting match result that need filtering. There are Chinese links in the results which I think might cause the script not to work. Here is my test.py
Quote:import urllib2,urllib,re

url='http://www.joost.com/epg/us/film/more/o/text/'

req = urllib2.Request(url)
req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
response = urllib2.urlopen(req)
link=response.read()
response.close()
match=re.compile('<li><a href="(.+?)">(.+?)</a></li>').findall(link)
print match

here is the dump
Quote:[('/people/', 'People'), ('/groups/', 'Groups'), ('/epg/music/', 'Music'), ('/epg/film/', 'Film'), ('/072jrok/t/Air-Force-One', 'Air Force One'), ('/0450055/t/Alliance-Atlantis-Sci-Fi-Films', 'Alliance Atlantis Sci-Fi Films'), ('/37niein/t/Anime-Network', 'Anime Network'), ('/33g808r/t/Article-19-Films', 'Article 19 Films'), ('/34d7wqd/t/Behind-the-Scenes', 'Behind the Scenes'), ('/024jcie/t/Best-of-Joost-Comedy-Shorts', 'Best of Joost: Comedy Shorts'), ('/024eiih/t/Best-of-Joost-Short-Films', 'Best of Joost: Short Films'), ('/032004g/t/Best-of-National-Geographic-Channel', 'Best of National Geographic Channel'), ('/093owsr/t/Beyond-the-Trailer', 'Beyond the Trailer'), ('/05971bk/t/The-Bollywood-Channel', 'The Bollywood Channel'), ('/36ikr40/t/Brooklyn-Lobster-(Tribeca-Film)', 'Brooklyn Lobster (Tribeca Film)'), ('/3128r26/t/Caldecott-HD', 'Caldecott HD'), ('/32z8rho/t/Call2Action-Network', 'Call2Action Network'), ('/37rhuye/t/Cinetic', 'Cinetic'), ('/05900gl/t/The-Classic-Western-Channel', 'The Classic Western Channel'), ('/072pd22/t/Cops-and-Robbersons', 'Cops and Robbersons'), ('/272irg7/t/Cult', 'Cult'), ('/059012r/t/The-Cult-Action-Channel', 'The Cult Action Channel'), ('/110001m/t/Elo-Cinema-Latino', 'Elo Cinema Latino'), ('/0120011/t/Explora-Channel', 'Explora Channel'), ('/072jroj/t/The-Fifth-Element', 'The Fifth Element'), ('/264000r/t/Film24', 'Film24'), ('/264efni/t/Film24-Bitesize', 'Film24 Bitesize'), ('/37rpndb/t/Free-Zone', 'Free Zone'), ('/035b7qv/t/From-Here-to-Awesome', 'From Here to Awesome'), ('/241000u/t/Future-Shorts', 'Future Shorts'), ('/36ikr58/t/Game-6-(Tribeca-Film)', 'Game 6 (Tribeca Film)'), ('/072jror/t/Gattaca', 'Gattaca'), ('/072jrot/t/Ghostbusters', 'Ghostbusters'), ('/072kqip/t/Go', 'Go'), ('/0070022/t/Godzilla', 'Godzilla'), ('/05900se/t/Golden-Comedy-Movies', 'Golden Comedy Movies'), ('/05900sf/t/Golden-Drama-Movies', 'Golden Drama Movies'), ('/035b7sc/t/Heretic', 'Heretic'), ('/072pd24/t/Higher-Learning', 'Higher Learning'), ('/059kr33/t/His-Girl-Friday', 'His Girl Friday'), ('/059oemq/t/Hollywood-Trailer-Channel', 'Hollywood Trailer Channel'), ('/37rkrq9/t/Hoop-Dreams', 'Hoop Dreams'), ('/05900gk/t/The-Horror-Cult-Films-Channel', 'The Horror Cult Films Channel'), ('/33z7tjp/t/Indie-Film', 'Indie Film'), ('/0350018/t/Indieflix-Docs-That-Rock', 'Indieflix: Docs That Rock'), ('/035001p/t/Indieflix-Indies-On-The-Edge', 'Indieflix: Indies On The Edge'), ('/035000q/t/IndieFlix-Shorts', 'IndieFlix Shorts'), ('/093005q/t/Indy-Mogul', 'Indy Mogul'), ('/03600cn/t/Indy-500-Films', 'Indy 500 Films'), ('/272irg9/t/Insight', 'Insight'), ("/37rnezh/t/Jazz-On-A-Summer's-Day", "Jazz On A Summer's Day"), ('/024jljb/t/Joost-Films-Dysfunctional-Families', 'Joost Films: Dysfunctional Families'), ('/024q8vc/t/Joost-Presents-Strange-Love-Stories', 'Joost Presents: Strange Love Stories'), ('/072jrov/t/Jumanji', 'Jumanji'), ('/072jroi/t/The-Karate-Kid', 'The Karate Kid'), ('/072mvbw/t/The-Karate-Kid-Marathon', 'The Karate Kid Marathon'), ('/072jron/t/The-Karate-Kid-Part-II', 'The Karate Kid Part II'), ('/072jroo/t/The-Karate-Kid-Part-III', 'The Karate Kid Part III'), ('/180000s/t/The-Kung-Fu-Films-Channel', 'The Kung Fu Films Channel'), ('/072kqiv/t/A-League-of-their-Own', 'A League of their Own'), ("/072n2st/t/Look-Who's-Talking", "Look Who's Talking"), ('/2570001/t/Looking-Glass-Television', 'Looking Glass Television'), ('/072jrox/t/Men-in-Black', 'Men in Black'), ('/33ka8r2/t/Minute-Planet', 'Minute Planet'), ('/1580044/t/Movieola-The-Short-Film-Channel', 'Movieola: The Short Film Channel'), ('/072n2sx/t/Muppets-From-Space', 'Muppets From Space'), ('/032004f/t/National-Geographic-Animals-%26-Nature', 'National Geographic Animals & Nature'), ('/0325p9k/t/National-Geographic-Green-Channel', 'National Geographic Green Channel'), ('/032004h/t/National-Geographic-History-%26-Exploration', 'National Geographic History & Exploration'), ('/032004i/t/National-Geographic-People-%26-Places', 'National Geographic People & Places'), ('/032004j/t/National-Geographic-Wild', 'National Geographic Wild'), ('/33b8q69/t/Notasuch-Films', 'Notasuch Films'), ('/249i7g3/t/Paranormal-TV', 'Paranormal TV'), ('/272irgb/t/Planet', 'Planet'), ('/287002d/t/Pop-Arts-TV', 'Pop Arts TV'), ('/072g2mn/t/Popcorn-Flicks', 'Popcorn Flicks'), ('/33h8tpn/t/Portable-Film-Festival', 'Portable Film Festival'), ('/072jroq/t/The-Professional', 'The Professional'), ('/072pd25/t/Quicksilver', 'Quicksilver'), ('/1590001/t/Raindance-TV', 'Raindance TV'), ('/1599g48/t/Raindance-TV-Shorts', 'Raindance TV Shorts'), ('/34xotn0/t/Rajshri-com-Short-Films', 'Rajshri.com - Short Films'), ('/33n7o5d/t/Rare-Exports', 'Rare Exports'), ('/1800001/t/The-Really-Terrible-Film-Channel', 'The Really Terrible Film Channel'), ('/072jrom/t/Rudy', 'Rudy'), ('/33f7o4w/t/Shock-Docs', 'Shock Docs'), ('/0590006/t/The-Silent-Movies-Channel', 'The Silent Movies Channel'), ('/37rkrqb/t/Slacker', 'Slacker'), ("/072n2sw/t/St-Elmo's-Fire", "St. Elmo's Fire"), ('/072pd26/t/Starman', 'Starman'), ('/072jroh/t/Starship-Troopers', 'Starship Troopers'), ('/059kr3x/t/The-Stranger', 'The Stranger'), ('/158008q/t/Tokyo-Pulp', 'Tokyo Pulp'), ('/072pd23/t/Toy-Soldiers', 'Toy Soldiers'), ('/36ihgc9/t/Tribeca-Film', 'Tribeca Film'), ('/2630001/t/Troma-Entertainment', 'Troma Entertainment'), ('/2270001/t/VFS-Animation-%26-Visual-Effects', 'VFS - Animation & Visual Effects'), ('/2270002/t/VFS-Drama-%26-Documentary', 'VFS - Drama & Documentary'), ("/044po2i/t/Wallace-%26-Gromit's-Cracking-Contraptions", "Wallace & Gromit's Cracking Contraptions"), ('/072n2su/t/Wolf', 'Wolf'), ('/0597o5m/t/The-World-Of-Westerns', 'The World Of Westerns'), ('/33l83n6/t/XPLR', 'XPLR'), ('/127001w/t/Zone-Horror', 'Zone Horror'), ('/38oj16r/t/%e4%b8%8d%e8%83%bd%e5%a4%b1%e5%8e%bb%e4%bd%a0', '\xe4\xb8\x8d\xe8\x83\xbd\xe5\xa4\xb1\xe5\x8e\xbb\xe4\xbd\xa0'), ('/371m2lp/t/%e5%8d%83%e9%be%99%e7%bd%91%ef%bc%8dFLASH', '\xe5\x8d\x83\xe9\xbe\x99\xe7\xbd\x91\xef\xbc\x8dFLASH'), ('/371m2nc/t/%e5%8d%83%e9%be%99%e7%bd%91%e5%84%bf%e6%ad%8c%e7%b3%bb%e5%88%97', '\xe5\x8d\x83\xe9\xbe\x99\xe7\xbd\x91\xe5\x84\xbf\xe6\xad\x8c\xe7\xb3\xbb\xe5\x88\x97'), ('/371m2ld/t/%e5%96%9c%e6%b4%8b%e6%b4%8b%e4%b8%8e%e7%81%b0%e5%a4%aa%e7%8b%bc', '\xe5\x96\x9c\xe6\xb4\x8b\xe6\xb4\x8b\xe4\xb8\x8e\xe7\x81\xb0\xe5\xa4\xaa\xe7\x8b\xbc'), ('/334l2g1/t/%e5%a8%b1%e4%b9%90%e7%9f%ad%e7%89%87%e9%9b%86%e9%94%a6I', '\xe5\xa8\xb1\xe4\xb9\x90\xe7\x9f\xad\xe7\x89\x87\xe9\x9b\x86\xe9\x94\xa6I'), ('/371m2kh/t/%e5%b0%8f%e4%b8%91%e7%89%9b', '\xe5\xb0\x8f\xe4\xb8\x91\xe7\x89\x9b'), ('/371m2gk/t/%e5%b0%8f%e6%a8%b1%e6%a1%83', '\xe5\xb0\x8f\xe6\xa8\xb1\xe6\xa1\x83'), ('/371m2jl/t/%e5%b0%8f%e7%a0%b4%e5%ad%a9%e5%8d%a1%e9%80%9a%e7%b3%bb%e5%88%97', '\xe5\xb0\x8f\xe7\xa0\xb4\xe5\xad\xa9\xe5\x8d\xa1\xe9\x80\x9a\xe7\xb3\xbb\xe5\x88\x97'), ('/371m2ih/t/%e5%b0%8f%e7%a0%b4%e5%ad%a9%e8%b4%ba%e5%8d%a1%e7%b3%bb%e5%88%97', '\xe5\xb0\x8f\xe7\xa0\xb4\xe5\xad\xa9\xe8\xb4\xba\xe5\x8d\xa1\xe7\xb3\xbb\xe5\x88\x97'), ('/371m31a/t/%e6%90%9e%e7%ac%91%e4%b8%80%e6%97%8f', '\xe6\x90\x9e\xe7\xac\x91\xe4\xb8\x80\xe6\x97\x8f'), ('/371m31v/t/%e6%9d%ad%e5%b7%9e%e5%b0%8f%e5%a5%87%e5%85%b5', '\xe6\x9d\xad\xe5\xb7\x9e\xe5\xb0\x8f\xe5\xa5\x87\xe5\x85\xb5'), ('/371a8tx/t/%e6%a2%a6%e5%b9%bb%e5%8a%a8%e7%94%bb%e4%b9%8b%e9%bb%91%e9%bb%91%e7%8c%aa', '\xe6\xa2\xa6\xe5\xb9\xbb\xe5\x8a\xa8\xe7\x94\xbb\xe4\xb9\x8b\xe9\xbb\x91\xe9\xbb\x91\xe7\x8c\xaa'), ('/371m30t/t/%e6%bc%94%e4%b9%89%e4%b8%89%e5%9b%bd', '\xe6\xbc\x94\xe4\xb9\x89\xe4\xb8\x89\xe5\x9b\xbd'), ('/371m2bp/t/%e7%ac%ac%e4%b8%83%e5%b1%8a%e5%ad%a6%e9%99%a2%e5%a5%96', '\xe7\xac\xac\xe4\xb8\x83\xe5\xb1\x8a\xe5\xad\xa6\xe9\x99\xa2\xe5\xa5\x96'), ('/371m2sb/t/%e7%ac%ac%e4%b8%89%e5%b1%8a%e5%ad%a6%e9%99%a2%e5%a5%96', '\xe7\xac\xac\xe4\xb8\x89\xe5\xb1\x8a\xe5\xad\xa6\xe9\x99\xa2\xe5\xa5\x96'), ('/371m2wk/t/%e7%ac%ac%e4%ba%94%e5%b1%8a%e5%ad%a6%e9%99%a2%e5%a5%96', '\xe7\xac\xac\xe4\xba\x94\xe5\xb1\x8a\xe5\xad\xa6\xe9\x99\xa2\xe5\xa5\x96'), ('/371m2o1/t/%e7%ac%ac%e5%9b%9b%e5%b1%8a%e5%ad%a6%e9%99%a2%e5%a5%96', '\xe7\xac\xac\xe5\x9b\x9b\xe5\xb1\x8a\xe5\xad\xa6\xe9\x99\xa2\xe5\xa5\x96'), ('/371m2h0/t/%e9%bb%91%e7%9a%ae%e6%96%87%e5%8c%96', '\xe9\xbb\x91\xe7\x9a\xae\xe6\x96\x87\xe5\x8c\x96'), ('/about/" title="', 'About us'), ('/contact/" title="', 'Contact'), ('/jobs/" title="', 'Jobs'), ('http://blog.joost.com/" title="', 'Joost Blog'), ('http://press.joost.com/" title="', 'Press releases'), ('/iphone/" title="', 'Joost iPhone App'), ('/feeds/" title="', 'Data Feeds'), ('/share/logos/" title="', 'Blog Badges &amp; Logo'), ('/share/wallpapers/" title="', 'Desktop Wallpapers'), ('/support/faq/" title="', 'FAQ'), ('/support/" title="', 'Support'), ('/sitemap/" title="', 'Sitemap')]

I also used a script I looked at the TV Shack plugin and found it gave good results for the page its intended for but not mine. I am thinking maybe there is a way to adapt that script to work the site I am trying to match.
Does anyone know how to use
Quote:clean4=re.sub
command?
This is what is used in the TV shack plugin to remove stuff I am wondering how to apply it to my script.
Here is a link to my progress as it happens I put it here