Guest User

yourfreetube.py

a guest
Mar 9th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.35 KB | None | 0 0
  1. '''
  2.    Ultimate Whitecream
  3.    Copyright (C) 2015 Whitecream
  4.  
  5.    This program is free software: you can redistribute it and/or modify
  6.    it under the terms of the GNU General Public License as published by
  7.    the Free Software Foundation, either version 3 of the License, or
  8.    (at your option) any later version.
  9.  
  10.    This program is distributed in the hope that it will be useful,
  11.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.    GNU General Public License for more details.
  14.  
  15.    You should have received a copy of the GNU General Public License
  16.    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  17. '''
  18.  
  19. import re
  20.  
  21. import xbmcplugin
  22. from resources.lib import utils
  23. progress = utils.progress
  24.  
  25.  
  26. @utils.url_dispatcher.register('190')
  27. def YFTMain():
  28.     utils.addDir('[COLOR hotpink]Categories[/COLOR]','https://www.yourfreetube.net/',193,'','')
  29.     utils.addDir('[COLOR hotpink]Search[/COLOR]','http://www.yourfreetube.net/search.php?keywords=',194,'','')
  30.     #YFTList('https://www.yourfreetube.net/new-videos/')
  31.     YFTList('https://www.yourfreetube.net/')
  32.     xbmcplugin.endOfDirectory(utils.addon_handle)
  33.  
  34.  
  35. @utils.url_dispatcher.register('191', ['url'])
  36. def YFTList(url):
  37.     try:
  38.         listhtml = utils.getHtml(url)
  39.     except:
  40.        
  41.         return None
  42.     #match0= re.compile('blog-items blog-items-control site__row grid(.+?)site__col main-sidebar main-sidebar-control', re.DOTALL).findall(listhtml)[0]
  43.     #match = re.compile('data-post-id=.+?href="(.+?)" title="(.+?)".+?src="(.+?)"', re.DOTALL | re.IGNORECASE).findall(match0)
  44.     match0= re.compile('pm-grid">.+?<\/ul>', re.DOTALL).findall(listhtml)[0]
  45.     match = re.compile('href="(.+?)".+?src="(.+?)" alt="(.+?)".+?pm-video-attr-desc">(.+?)<\/p>', re.DOTALL | re.IGNORECASE).findall(match0)
  46.     for videopage, img, name, desc in match:
  47.         name = utils.cleantext(name)
  48.         desc = utils.cleantext(desc)
  49.         utils.addDownLink(name, videopage, 192, img, desc)
  50.     try:
  51.         nextp=re.compile('\s+href="([^"]+)">&raquo;', re.DOTALL | re.IGNORECASE).findall(match0)[0]
  52.         if not 'http' in nextp:
  53.             nextp = "http://www.yourfreetube.net/" + nextp
  54.         utils.addDir('Next Page', nextp, 191,'')
  55.     except: pass
  56.     xbmcplugin.endOfDirectory(utils.addon_handle)
  57.  
  58.  
  59. @utils.url_dispatcher.register('194', ['url'], ['keyword'])
  60. def YFTSearch(url, keyword=None):
  61.     searchUrl = url
  62.     if not keyword:
  63.         utils.searchDir(url, 194)
  64.     else:
  65.         title = keyword.replace(' ','+')
  66.         searchUrl = searchUrl + title
  67.         print "Searching URL: " + searchUrl
  68.         YFTList(searchUrl)
  69.  
  70.  
  71. @utils.url_dispatcher.register('193', ['url'])
  72. def YFTCat(url):
  73.     cathtml = utils.getHtml(url, '')
  74.  
  75.     #match = re.compile('<ul class="pm-browse-ul-subcats">(.*?)</ul>', re.DOTALL | re.IGNORECASE).findall(cathtml)
  76.     match1 = re.compile('-category menu-item.*?<a href="([^"]+)">(.+?)</a>', re.DOTALL | re.IGNORECASE).findall(cathtml)
  77.     for catpage, name in match1:
  78.         utils.addDir(name, catpage, 191, '')
  79.     xbmcplugin.endOfDirectory(utils.addon_handle)
  80.  
  81.  
  82. @utils.url_dispatcher.register('192', ['url', 'name'], ['download'])
  83. def YFTPlayvid(url, name, download=None):
  84.     utils.PLAYVIDEO(url, name, download, '''src=\s*["']([^'"]+)''')
Add Comment
Please, Sign In to add comment