Advertisement
Guest User

Untitled

a guest
Jul 13th, 2015
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def showMovies(sSearch=''):
  2.     oGui = cGui()
  3.     if sSearch:
  4.         #on redecode la recherhce codé il y a meme pas une seconde par l'addon
  5.         sSearch = urllib2.unquote(sSearch)
  6.        
  7.         query_args = { 'do' : 'search' , 'subaction' : 'search' , 'story' : str(sSearch) , 'x' : '0', 'y' : '0'}
  8.        
  9.         data = urllib.urlencode(query_args)
  10.         headers = {'User-Agent' : 'Mozilla 5.10'}
  11.         url = 'http://www.streamingmy.com/index.php?do=search=' + sSearch
  12.         #url = 'http://streamingmy.com/seriestv/index.php?do=search=' + sSearch
  13.         request = urllib2.Request(url,data,headers)
  14.      
  15.         try:
  16.             reponse = urllib2.urlopen(request)
  17.         except URLError, e:
  18.             print e.read()
  19.             print e.reason
  20.      
  21.         sHtmlContent = reponse.read()
  22.         sPattern = '<div class="img-block border-2">.*?<img src="(.*?)" alt="(.*?)" class="img-poster border-2 shadow-dark7" width="151" height="215" />.+?<a href="(http:.*?)" title'
  23.     else:
  24.         oInputParameterHandler = cInputParameterHandler()
  25.         sUrl = oInputParameterHandler.getValue('siteUrl')
  26.         oRequestHandler = cRequestHandler(sUrl)
  27.         sHtmlContent = oRequestHandler.request()
  28.         #sPattern = '<div class="img-block border-2">.*?<img src="(.*?)" alt="(.*?)".*?<a href="(.*?)" title'
  29.         sPattern = '<div class="img-block border-2">.*?<img src="(.+?)" alt="(.+?)".*?<a href="(.+?)" title'
  30.        
  31.  
  32.     oParser = cParser()
  33.     aResult = oParser.parse(sHtmlContent, sPattern)
  34.    
  35.     if (aResult[0] == True):
  36.         total = len(aResult[1])
  37.         dialog = cConfig().createDialog(SITE_NAME)
  38.         for aEntry in aResult[1]:
  39.             cConfig().updateDialog(dialog, total)
  40.             if dialog.iscanceled():
  41.                 break
  42.            
  43.  
  44.             #sTitle = aEntry[2].decode('latin-1').encode("utf-8")
  45.             #sThumbnail = 'http:'+str(aEntry[2])
  46.             sUrl = str(aEntry[1])
  47.            
  48.             sThumbnail = str(aEntry[0])
  49.             if not 'http://www.streamingmy.com' in sThumbnail:
  50.                   sThumbnail = 'http://www.streamingmy.com' + sThumbnail
  51.             #print sThumbnail
  52.  
  53.             oOutputParameterHandler = cOutputParameterHandler()
  54.             oOutputParameterHandler.addParameter('siteUrl', str(aEntry[2]))
  55.             oOutputParameterHandler.addParameter('sMovieTitle',str(aEntry[1]))
  56.             oOutputParameterHandler.addParameter('sThumbnail', sThumbnail)            
  57.             oGui.addMovie(SITE_IDENTIFIER, 'showHosters', aEntry[1], '', sThumbnail, '', oOutputParameterHandler)
  58.                
  59.         cConfig().finishDialog(dialog)
  60.  
  61.         sNextPage = __checkForNextPage(sHtmlContent)
  62.         print sNextPage
  63.         if (sNextPage != False):
  64.             oOutputParameterHandler = cOutputParameterHandler()
  65.             oOutputParameterHandler.addParameter('siteUrl', sNextPage)
  66.             oGui.addDir(SITE_IDENTIFIER, 'showMovies', '[COLOR teal]Next >>>[/COLOR]', 'next.png', oOutputParameterHandler)
  67.  
  68.         sGotoPage = __checkForGotoPage(sHtmlContent)
  69.         print sGotoPage
  70.         if (sNextPage != False):
  71.             oOutputParameterHandler = cOutputParameterHandler()
  72.             oOutputParameterHandler.addParameter('siteUrl', sGotoPage)
  73.             oGui.addDir(SITE_IDENTIFIER, 'showMovies', '[COLOR orange]Goto Page #[/COLOR]', 'next.png', oOutputParameterHandler)
  74.              
  75.     if not sSearch:
  76.         oGui.setEndOfDirectory()
  77.                
  78. def __checkForNextPage(sHtmlContent):
  79.    
  80.     sPattern = '<div class="nextprev">.+?<a href="([^<>]+?)"><span class="pnext">Suivant<\/span><\/a>'
  81.     oParser = cParser()
  82.     aResult = oParser.parse(sHtmlContent, sPattern)
  83.  
  84.     if (aResult[0] == True):
  85.         return aResult[1][0]
  86.  
  87.     return False
  88.          
  89. def __checkForGotoPage(sHtmlContent):
  90.    
  91.     sPattern = '<div class="nextprev">.+?<a href="([^<>]+?)"><span class="pnext">Suivant<\/span><\/a>'
  92.     oParser = cParser()
  93.     aResult = oParser.parse(sHtmlContent, sPattern)
  94.                  
  95.     if (aResult[0] == True):
  96.         return aResult[1][0]
  97.  
  98.     return False
  99.             if __item_list_:
  100.                 a.add_items(__item_list_)
  101.                 a.end_of_directory()
  102.  
  103.         elif __mode_ == 'list':
  104.             if __params_['content'] == 'search':
  105.                 __item_ = a.search_input()
  106.                 if __item_: __params_['url'] = __search_url_ + __item_
  107.                 else: exit(1)
  108.             elif __params_['content'] == 'goto':
  109.                 __last_item_ = re.search('/page/([0-9]+)/', __params_['url'])
  110.                 if __last_item_: __last_item_ = int(__last_item_.group(1))
  111.                 else: __last_item_ = 10000
  112.                 __item_ = a.page_input(__last_item_)
  113.                 if __item_: __params_['url'] = re.sub('/page/[0-9]+/', '/page/' + str(__item_) + '/', __params_['url'])
  114.                 else: exit(1)
  115.             __html_ = a.get_page(__params_['url'])
  116.             __soup_ = BeautifulSoup(__html_, parseOnlyThese=SoupStrainer('body'))
  117.             __item_list_ = []
  118.             __params_['mode'] = 'play'
  119.             __params_['content'] = 'movies'
  120.             __params_['type'] = 0
  121.             __params_['duration'] = '120'
  122.             __xbmcdict_ = XBMCDict(0).update(__params_)
  123.             for __item_ in __soup_.findAll('div', 'photo-thumb-image'):
  124.                 if not __item_.a.get('href') in __false_positives_:
  125.                     __dict_ = __xbmcdict_.copy()
  126.                     if 'scenes' in __params_['url']:
  127.                         __dict_['duration'] = '45'
  128.                         __dict_['content'] = 'episodes'
  129.                     __dict_['url'] = __item_.a.get('href')
  130.                     __dict_['title'] = __item_.a.get('title').encode('UTF-8')
  131.                     __dict_['tvshowtitle'] = __dict_['title']
  132.                     __dict_['originaltitle'] = __dict_['title']
  133.                     __dict_['cover_url'] = a.image(__item_.img.get('src'))
  134.                     __dict_['thumb_url'] = __dict_['cover_url']
  135.                     __dict_['poster'] = __dict_['cover_url']
  136.                     __dict_['sub_site'] = __site_
  137.                     __dict_['contextmenu_items'] = [Fc().add(__dict_)]
  138.                     __item_list_.extend([__dict_])
  139.             __soup_ = BeautifulSoup(__html_, parseOnlyThese=SoupStrainer('div', 'more_entries'))
  140.             if __soup_:
  141.                 __item_ = __soup_.find('a', 'previouspostslink')
  142.                 if __item_: __item_list_.extend([{'site': __site_, 'mode': 'list', 'url': __item_.get('href'), 'content': __params_['content'],
  143.                                                   'title': a.language(30008), 'cover_url': a.image('previous.png', image),
  144.                                                   'backdrop_url': a.art(), 'type': 3}])
  145.                 __item_ = __soup_.find('a', 'nextpostslink')
  146.                 if __item_: __item_list_.extend([{'site': __site_, 'mode': 'list', 'url': __item_.get('href'), 'content': __params_['content'],
  147.                                                   'title': a.language(30009), 'cover_url': a.image('next.png', image),
  148.                                                   'backdrop_url': a.art(), 'type': 3}])
  149.                 __item_ = __soup_.find('a', 'last')
  150.                 if __item_: __item_list_.extend([{'site': __site_, 'mode': 'list', 'url': __item_.get('href'), 'content': 'goto',
  151.                                                   'title': a.language(30010), 'cover_url': a.image('goto.png', image),
  152.                                                   'backdrop_url': a.art(), 'type': 3}])
  153.             if __item_list_:
  154.                 a.add_items(__item_list_)
  155.                 a.end_of_directory()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement