def bookmarks(): """ Login to display ex.ua bookmarks :return: None """ successful_login = False listing = [] if not loader.is_logged_in(): username = plugin.addon.getSetting('username') password = webloader.decode(plugin.addon.getSetting('password')) captcha = loader.check_captcha() login_dialog = login_window.LoginWindow(username, password, captcha['captcha_file']) if not login_dialog.login_cancelled: successful_login = loader.login(login_dialog.username, login_dialog.password, captcha_text=login_dialog.captcha_text, captcha_id=captcha['captcha_id']) if successful_login: plugin.addon.setSetting('username', login_dialog.username) if plugin.addon.getSetting('save_pass') == 'true': plugin.addon.setSetting('password', webloader.encode(login_dialog.password)) else: plugin.addon.setSetting('password', '') else: xbmcgui.Dialog().ok(u'Ошибка входа!', u'Проверьте логин и пароль, а затем повторите попытку.') del login_dialog __log__('bookmarks; is_logged_in', loader.is_logged_in()) __log__('bookmarks; successful_login', successful_login) if loader.is_logged_in() or successful_login: listing += views.list_videos(plugin, exua_parser.get_videos('/buffer', loader)) __log__('bookmarks; listing', listing) return listing
def search_category(path=''): """ Perform search in an ex.ua category or via Google.com. """ listing = [] keyboard = xbmc.Keyboard('', u'Поисковый запрос') keyboard.doModal() search_text = keyboard.getText() if search_text and keyboard.isConfirmed(): if path: search_path = '/search?s={0}&original_id={1}'.format(urllib.quote_plus(search_text), SEARCH_CATEGORIES[path]) else: if plugin.addon.getSetting('use_google') == 'false': search_path = '/search?s={0}'.format(urllib.quote_plus(search_text)) else: search_path = 'http://www.google.com.ua/search?q=site%3Aex.ua+{0}'.format(urllib.quote_plus(search_text)) __log__('search_category; search_path', search_path) if plugin.addon.getSetting('cache_pages') == 'true': videos = get_videos(search_path, page=0, pages=plugin.addon.getSetting('itemcount')) else: videos = exua_parser.get_videos(search_path, page=0, pages=plugin.addon.getSetting('itemcount')) listing = views.list_videos(plugin, videos, search_path) if listing and plugin.addon.getSetting('savesearch') == 'true': storage['search_history'].insert(0, {'text': search_text, 'query': search_path}) if len(storage['search_history']) > int(plugin.addon.getSetting('historylength')): storage['search_history'].pop(-1) elif not listing: xbmcgui.Dialog().ok(u'Ничего не найдено!', u'Уточните поисковый запрос и повторите попытку.') __log__('search_category; listing', listing) return listing
def video_articles(path, page_No='0'): """ Show video articles. """ __log__('video_articles; path', path) page = int(page_No) pages = plugin.addon.getSetting('itemcount') if plugin.addon.getSetting('cache_pages') == 'true': videos = get_videos(path, page, pages) else: videos = exua_parser.get_videos(path, page=page, pages=pages) listing = views.list_videos(plugin, videos, path, page) __log__('video_articles; listing', listing) return plugin.finish(listing, view_mode=50)
def video_articles(path, page_No='0'): """ Show video articles. """ __log__('video_articles; path', path) page = int(page_No) pages = get_items_per_page() if plugin.addon.getSetting('cache_pages') == 'true': videos = get_videos(path, page, pages) else: videos = exua_parser.get_videos(path, page=page, pages=pages) listing = list_videos(videos, path, page) # if page_No != '0': # listing.insert(0, {'label': u'<< Главная', # 'path': plugin.url_for('categories'), # 'thumbnail': os.path.join(icons, 'home.png')}) __log__('video_articles; listing', listing) return plugin.finish(listing, view_mode=50)
def get_videos(path, page, pages): return exua_parser.get_videos(path, page=page, pages=pages)