With python you can get things really short.. BUT.. IMO it's not always good practicewhat the hell, this info would of helped alot in the beginning
did not know i can do this saved an extra line
Code:for url,thumb,name in re.findall('<a rel="nofollow" class="teaser group" href="(.+?)"><div class=".+?"><img id=".+?" class="fit_img" src="(.+?)" alt="(.+?)">',link): print name
i did this so far, and i know jason was trying to tell me there is a faster way but did not understand
Code:r = re.compile('<a rel="nofollow" class="teaser group" href="(.+?)"><div class=".+?"><img id=".+?" class="fit_img" src="(.+?)" alt="(.+?)">').findall(link) for url,thumb,name in r: print name
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
How can I help you all? What exactly is needed? I am, of course, happy to help.Wireshark ----
Rtmp needs covering also.
Library integration and creating strm files.
Umouch is needed as he ENJOYS PHP and creating sites.......
from t0mm0.common.addon import Addon
addon = Addon('plugin.video.myaddon', sys.argv)
#
# Instead of doing this:
#
def get_params():
param=[]
paramstring=sys.argv[2]
if len(paramstring)>=2:
params=sys.argv[2]
cleanedparams=params.replace('?','')
if (params[len(params)-1]=='/'):
params=params[0:len(params)-2]
pairsofparams=cleanedparams.split('&')
param={}
for i in range(len(pairsofparams)):
splitparams={}
splitparams=pairsofparams[i].split('=')
if (len(splitparams))==2:
param[splitparams[0]]=splitparams[1]
return param
params=get_params()
mode=''
try:
mode=int(params["mode"])
except:
pass
#
# You can do this
#
mode = int(addon.queries.get('mode', ''))
### So you got rid of the get_params function and the try catch block to get value of mode with one line.
#
# Instead of doing this:
#
liz=xbmcgui.ListItem(label = name,iconImage="",thumbnailImage = image)
liz.setProperty('fanart_image', os.path.join(art,'xbmcback.png'))
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=sys.argv[0]+"?url=%s&mode=%s&name=%s"%(url,mode,name),isFolder=False,listitem=liz)
#
# You could do this
#
addon.add_directory({'mode': mode, 'url': url, 'name' : name}, {'title' : name }, img=image, fanart=os.path.join(art,'xbmcback.png'))
### Three lines of code used to add an item get replaced with one line.
I dont agree. t0mm0's code is doing the same thing that you would directly write in your addon to add a directory (or do any other stuff). I am not sure how one extra function call or a couple of extra checks is going to slow it down. Kindly elaborate.On my addons i'm trying use less t0mm0s and others modules. You'll get a faster addon. Trust me.
I'm with you ray, practical working examples will let me understand/fly better
You can do a git pull of your favorite addon and start getting your hands dirty...Did anything ever come of this tutorial? I'm guessing not?
Does anyone know of any good video plugin tutorials? I'd love to get to grips with making plugins, but I'm more of a 'hands-on' type of learner, where I need to be doing it to learn, rather than just reading. At the moment, I've done a lot of reading, but not put anything to practice just yet as I'm still unsure on the basic make up of an addon.
I know I can do this, and I have tried, but sometimes it's not as clear for a total novice as it is for those with a little more experience. Sometimes there's too much code, you need to start basic. Start with playing one stream/video, then how to make categories/menus, then scrapping sites, etc.You can do a git pull of your favorite addon and start getting your hands dirty...
I did a little bit of google research a few weeks back as had decided my ultimate goal is to produce an add on, but experienced a similar problem looking for tutorials. I have PM'd you a few links, some may be of use unless you have already found and explored - have not really had the time myself (my biggest enemy).I know I can do this, and I have tried, but sometimes it's not as clear for a total novice as it is for those with a little more experience. Sometimes there's too much code, you need to start basic. Start with playing one stream/video, then how to make categories/menus, then scrapping sites, etc.
Don't get me wrong, the plugin I have in mind, I have a similar Addon downloaded that I am trying to figure out how it works, but it can be extremely overwhelming in regards to the fact I see certain lines of code and I have no idea what that does. Why is it there?
I'm not bashing anyone, and I understand I need to just keep on reading to learn, but there is a sever lack of practical options around with learning python for XBMC, and the practical that are there don't seem to be total beginner friendly.
It's the biggest draw back to trying to learn, in my opinion. There are plenty of great things to read, but the lack of practical tasks to attempt means, at least for me, that I am unable to put to the test what I have read, in a way that I know will work. I like to think of it as when we did science experiments at school; you read how to do it, you read why you would do it, you read what the outcome(s) are, and then you follow a step by step guide while you do it practically, then you have that step by step guide taken away and have to do it yourself...I did a little bit of google research a few weeks back as had decided my ultimate goal is to produce an add on, but experienced a similar problem looking for tutorials. I have PM'd you a few links, some may be of use unless you have already found and explored - have not really had the time myself (my biggest enemy).
The .org documents are a mess, in my opinion. They reference it being for 'beginners' but fail to go through certain steps and just assume that the reader already knows them. That's not beginner friendly, in my opinion.The easiest way is to just bite the bullet and give it a go. Yes there are few actual guides on how to produce an addon. But if you look at some simple ones and I think highway has an addon tutorial example in his repo, you should get a good idea on how it all works.
There are loads of python guides on the internet and various youtube videos showing the basics of python. Once you've got those mastered you can start looking at the various python modules for xbmc.
Python is the easy bit trust me. It's the poor documentation from .org which is the beast.
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
T | News MPA Doesn’t Want Kenya to Simply Copy the DMCA, It Should Do Better | Underground News | 0 | |
T | News “Legal Options Are a Better Way to Beat Piracy Than Enforcement” | Underground News | 0 | |
E | Flixtor Promises to Return More Resilient and Better than Ever | Underground News | 0 |