]> git.nbdom.net Git - plugin.video.news.nbdom.net.git/commitdiff
default.py
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 17 Apr 2019 12:47:03 +0000 (13:47 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 17 Apr 2019 12:47:03 +0000 (13:47 +0100)
default.py

index b250f7de855d105016c1e4f14a8ae81a4177d0d8..8d7d1972d61a5aa5b30aefd63f2cb51dd322a62f 100755 (executable)
@@ -4,16 +4,23 @@
 #
 
 import sys
-import xbmcgui
-import xbmcplugin
 import urllib,urllib2,re
+#from BeautifulSoup import BeautifulSoup
+from io import StringIO, BytesIO
+from lxml.html import parse
+#from lxml.html import document_fromstring
+from lxml import etree
+#from HTMLParser import HTMLParser
 
-def getUrl(url):
+def getUrl(url,exp=''):
        req = urllib2.Request(url)
        req.add_header('User-Agent', 'Kodi')
        response = urllib2.urlopen(req)
        content = response.read()
        response.close()
+       if exp != '':
+               match = re.compile(exp,re.DOTALL).findall(content)
+               return match
        return content
 
 def getParams():
@@ -53,12 +60,34 @@ def addDir(name,url,mode,iconimage,description):
   ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=True)
   return ok
 
+def getVideos(url):
+       content = getUrl(url)
+       #tree = etree.HTML(content)
+       #return tree.cssselect('article')
+
+       #tree = parse(url).getroot()
+       #return tree
+       parser = etree.HTMLParser()
+       content = etree.tostring(content, encoding='unicode')
+       html = StringIO(content)
+       #tree = etree.parse(StringIO(content), parser)
+       #print tree
+       #tree.get('article')
+       #soup = BeautifulSoup(content)
+       #return soup.body.find('article', attrs={'class' : 'news-item'})
+       videos = []
+       #for item in content:
+
 #
 # Main
 #
 if True:
+       content = getVideos('https://news.nbdom.net/')
+       #print content
        sys.exit(0)
 
+import xbmcgui
+import xbmcplugin
 addon_handle = int(sys.argv[1])
 
 xbmcplugin.setContent(addon_handle, 'movies')