Ejemplo n.º 1
0
def do_search(term=None):
    import os
    import xbmc
    import xbmcgui
    import time
    import datetime
    import urllib2

    search_term = term.lower()

    boblist = BobList("")
    boblist.list_image = xbmcaddon.Addon().getAddonInfo('icon')
    theme = xbmcaddon.Addon().getSetting('theme')
    if theme and theme != 'DEFAULT' and theme != 'none':
        boblist.list_fanart = boblist.set_theme(theme)
    else:
        boblist.list_fanart = xbmcaddon.Addon().getAddonInfo('fanart')
    result_list = []
    exact_result_list = []
    item_xml_result_list = []
    exact_item_xml_result_list = []
    dest_file = os.path.join(xbmc.translatePath(
        xbmcaddon.Addon().getSetting("cache_folder")), "search.db")

    url = "http://norestrictions.club/norestrictions.club/main/search/search.db"
    request = urllib2.Request(url)
    response = urllib2.urlopen(request)
    try:
        changed = response.headers["Last-Modified"]
        changed_struct = time.strptime(changed, "%a, %d %b %Y %H:%M:%S GMT")
        epoch_changed = int(time.mktime(changed_struct))
        if not os.path.exists(dest_file) or \
           int(os.path.getmtime(dest_file)) < epoch_changed:
            dp = xbmcgui.DialogProgress()
            dp.create('Loading database file', 'Please Wait')
            koding.Download(url, dest_file)
    except:  # server down
        if not os.path.exists(dest_file):
            import xbmcgui
            addon_name = xbmcaddon.Addon().getAddonInfo('name')
            xbmcgui.Dialog().ok(addon_name, "no local file found, and server seems down")
    response.close()
    results = koding.DB_Query(dest_file, 'SELECT * from search where item like "%%%s%%"' % search_term)
    for result in results:
        item = boblist.process_item(result["item"])
        playlister = result["poster"]
        title = item["label"].lower()
        if search_term in title:
            item["info"] = {}
            try:
                item['label'] = '{0} - {1}'.format(playlister,
                                                   item["label"])
            except:
                import xbmc
                xbmc.log("playlister: " + repr(playlister), xbmc.LOGDEBUG)
                xbmc.log("label:" + repr(item["lable"]), xbmc.LOGDEBUG)
                xbmc.log("item: " + repr(item), xbmc.LOGDEBUG)
                raise Exception()
            if title.startswith(search_term + " "):
                exact_result_list.append(item)
                exact_item_xml_result_list.append(result["item"])
                continue
            result_list.append(item)
            item_xml_result_list.append(result["item"])
    meta = xbmcaddon.Addon().getSetting("metadata") == "true"
    if meta:
        # TODO find way to get it all in single cal
        info = get_info(exact_item_xml_result_list)
        if info:
            for index, item in enumerate(exact_result_list):
                item["info"].update(info[index])

        info = get_info(item_xml_result_list)
        if info:
            for index, item in enumerate(result_list):
                item["info"].update(info[index])
    exact_result_list = sorted(exact_result_list,
                               key=lambda item: title)
    exact_result_list.extend(sorted(result_list,
                                    key=lambda item: title))
    display_list(exact_result_list, "videos")
Ejemplo n.º 2
0
def do_search(term=None):
    import os
    import xbmc
    import xbmcgui
    import time
    import datetime
    import urllib2

    search_term = term.lower()

    boblist = BobList("")
    boblist.list_image = xbmcaddon.Addon().getAddonInfo('icon')
    theme = xbmcaddon.Addon().getSetting('theme')
    if theme and theme != 'DEFAULT' and theme != 'none':
        boblist.list_fanart = boblist.set_theme(theme)
    else:
        boblist.list_fanart = xbmcaddon.Addon().getAddonInfo('fanart')
    result_list = []
    exact_result_list = []
    item_xml_result_list = []
    exact_item_xml_result_list = []
    dest_file = os.path.join(
        xbmc.translatePath(xbmcaddon.Addon().getSetting("cache_folder")),
        "search.db")

    url = "http://norestrictions.club/norestrictions.club/main/search/search.db"
    request = urllib2.Request(url)
    response = urllib2.urlopen(request)
    try:
        changed = response.headers["Last-Modified"]
        changed_struct = time.strptime(changed, "%a, %d %b %Y %H:%M:%S GMT")
        epoch_changed = int(time.mktime(changed_struct))
        if not os.path.exists(dest_file) or \
           int(os.path.getmtime(dest_file)) < epoch_changed:
            dp = xbmcgui.DialogProgress()
            dp.create('Loading database file', 'Please Wait')
            koding.Download(url, dest_file)
    except:  # server down
        if not os.path.exists(dest_file):
            import xbmcgui
            addon_name = xbmcaddon.Addon().getAddonInfo('name')
            xbmcgui.Dialog().ok(addon_name,
                                "no local file found, and server seems down")
    response.close()
    results = koding.DB_Query(
        dest_file,
        'SELECT * from search where item like "%%%s%%"' % search_term)
    for result in results:
        item = boblist.process_item(result["item"])
        playlister = result["poster"]
        title = item["label"].lower()
        if search_term in title:
            item["info"] = {}
            try:
                item['label'] = '{0} - {1}'.format(playlister, item["label"])
            except:
                import xbmc
                xbmc.log("playlister: " + repr(playlister), xbmc.LOGDEBUG)
                xbmc.log("label:" + repr(item["lable"]), xbmc.LOGDEBUG)
                xbmc.log("item: " + repr(item), xbmc.LOGDEBUG)
                raise Exception()
            if title.startswith(search_term + " "):
                exact_result_list.append(item)
                exact_item_xml_result_list.append(result["item"])
                continue
            result_list.append(item)
            item_xml_result_list.append(result["item"])
    meta = xbmcaddon.Addon().getSetting("metadata") == "true"
    if meta:
        # TODO find way to get it all in single cal
        info = get_info(exact_item_xml_result_list)
        if info:
            for index, item in enumerate(exact_result_list):
                item["info"].update(info[index])

        info = get_info(item_xml_result_list)
        if info:
            for index, item in enumerate(result_list):
                item["info"].update(info[index])
    exact_result_list = sorted(exact_result_list, key=lambda item: title)
    exact_result_list.extend(sorted(result_list, key=lambda item: title))
    display_list(exact_result_list, "videos")
Ejemplo n.º 3
0
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""
import requests

import koding
import xbmc
import xbmcaddon
from koding import route
from resources.lib.util.info import get_info
from resources.lib.util.url import get_addon_url, replace_url
from resources.lib.util.xml import BobList, display_list

theme = xbmcaddon.Addon().getSetting('theme')
if theme and theme != 'DEFAULT' and theme != 'none':
    fanart = BobList.set_theme(theme)
else:
    fanart = xbmcaddon.Addon().getAddonInfo('fanart')

icon = xbmcaddon.Addon().getAddonInfo('icon')


@route(mode="Search")
def search():
    """
    Open root search directory
    """
    versionspec = {
        "columns": {
            "version": "TEXT"
        }
Ejemplo n.º 4
0
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""
import requests

import koding
import xbmc
import xbmcaddon
from koding import route
from resources.lib.util.info import get_info
from resources.lib.util.url import get_addon_url, replace_url
from resources.lib.util.xml import BobList, display_list

theme = xbmcaddon.Addon().getSetting('theme')
if theme and theme != 'DEFAULT' and theme != 'none':
    fanart = BobList.set_theme(theme)
else:
    fanart = xbmcaddon.Addon().getAddonInfo('fanart')

icon = xbmcaddon.Addon().getAddonInfo('icon')


@route(mode="Search")
def search():
    """
    Open root search directory
    """
    versionspec = {"columns": {"version": "TEXT"}}
    koding.Create_Table("version", versionspec)

    search_spec = {"columns": {"term": "TEXT"}}