Página 1 de 1
Resource for learning
Publicado: 15 May 2016, 14:29
por KodiFilms2
Hello,
Can you suggest good resources for learning Python and Kodi addons development?
Thanks
Re: Resource for learning
Publicado: 15 May 2016, 15:18
por SeiTaN
Hello,
If you want to learn Python, I suggest:
- Youtube tutorials (I am learning python with videos in my mother language) to get concepts.
- A good IDE with inspection code can help to improve and avoid common errors, I use pyCharm.
- The Hitchhiker’s Guide to Python!
http://docs.python-guide.org/en/latest/, tips and advices to code python """in the correct way"""(pythonic).
- Python main site
https://www.python.org/
Kodi, you should check official wiki or forum and dive in internet, the problem with Kodi that I had many times,it's the documentation is missing or outdated.
Good luck, and enjoy python
P.D: Kodi uses python 2.x, so considerate it for your development.
Re: Resource for learning
Publicado: 15 May 2016, 22:04
por KodiFilms2
Thanks! I want to know the best resource for Kodi development, is this can help me?
Re: Resource for learning
Publicado: 16 May 2016, 00:14
por robalo
Hola.
KodiFilms2 escribió:is this can help me?
Yes, quite.
You can assert to give you the courage to create a script to test the connector nowvideo.py with the format "nowvideo.to/video/<id>" (not premium links, only free).
Something like this:
Código: Seleccionar todo
# -*- coding: utf-8 -*-
#------------------------------------------------------------
# pelisalacarta - XBMC Plugin
# Conector para nowvideo
# http://blog.tvalacarta.info/plugin-xbmc/pelisalacarta/
#------------------------------------------------------------
import re
from core import scrapertools
from core import logger
def get_video_url(page_url, premium=False, user="", password="", video_password="" ):
logger.info("[nowvideo.py] get_video_url(page_url='%s')" % page_url)
data = scrapertools.cache_page( page_url )
stepkey = scrapertools.get_match(data,'name="stepkey" value="([^"]+)"')
data = scrapertools.cache_page( page_url, post='stepkey='+stepkey+'&submit=submit' )
flashvar_filekey = scrapertools.get_match(data,'flashvars.filekey=([^;]+);')
filekey = scrapertools.get_match(data,'var '+flashvar_filekey+'="([^"]+)"')
## API
video_id = scrapertools.get_match(page_url,"/([a-z0-9]+)$")
url = 'http://www.nowvideo.to/api/player.api.php?key=%s&file=%s' % (filekey, video_id)
data = scrapertools.cache_page(url)
if "The file is being converted" in data:
return [[" - [B][COLOR red]SIN VÍDEO[/COLOR][/B] - [COLOR pink]El fichero está en proceso[/COLOR]", ""]]
if "The video is being transfered" in data:
return [[" - [B][COLOR red]SIN VÍDEO[/COLOR][/B] - [COLOR pink]El vídeo está siendo transferido[/COLOR]", ""]]
if "no longer exists" in data:
return [[" - [B][COLOR red]SIN VÍDEO[/COLOR][/B] - [COLOR pink]El fichero ha sido borrado[/COLOR]", ""]]
media_url = re.sub(r"^url=", "", data.replace("flv&","flv?"))
return [[scrapertools.get_filename_from_url(media_url)[-4:] + " [nowvideo]", media_url]]
def find_videos(data):
encontrados = set()
devuelve = []
patronvideos = 'nowvideo.../video/([a-z0-9]+)'
logger.info("[nowvideo.py] find_videos #" + patronvideos + "#")
matches = re.compile(patronvideos,re.DOTALL).findall(data)
for match in matches:
titulo = "[nowvideo]"
url = "http://www.nowvideo.to/video/" + match
if url not in encontrados:
logger.info(" url=" + url)
devuelve.append( [ titulo , url , 'nowvideo' ] )
encontrados.add(url)
else:
logger.info(" url duplicada=" + url)
return devuelve
The py files, in addon SoD, are also a good manual or guide to follow.
Re: Resource for learning
Publicado: 16 May 2016, 11:06
por KodiFilms2
Thanks Robalo!

Re: Resource for learning
Publicado: 16 May 2016, 12:21
por robalo
You're welcome
If you testeas with false urls, the script forces you to use some method of debugging.
Personally I prefer not to turn on verbose log, too much information. Instead insert lines to detect the cause that stops the script ('print "....."' or 'import xbmc + xbmc.log (".....")' if I'm with kodi-jarvis)
It is important to know where the script stops and why.
Now you have two tasks, learn python and methods of debugging for kodi + addon.

Re: Resource for learning
Publicado: 02 Jun 2016, 09:13
por SeiTaN
I just found this tutorial and it's really good for newbies
http://learnpythonthehardway.org/book/