def acestreams(name, iconimage, chid):
	print("Call acestreams with name: " + str(name)  + " chid = " + str(chid))

	if settings.getSetting('addon_history') == "true":
		try: add_to_history(name, chid, iconimage)
		except: pass

	if not chid.startswith("acestream://"):
		chid = "acestream://" + chid

	plexusURI = 'plugin://program.plexus/?url={CHURL}&mode=1&name={CHNAME}'.format(
				CHURL  = urllib.quote(chid, safe = ''),
				CHNAME = urllib.quote(name, safe = ''))
	torrentinURI = 'plugin://plugin.video.torrentin/?uri={CHURL}&mode=1&name={CHNAME}'.format(
				CHURL  = urllib.quote(chid, safe = ''),
				CHNAME = urllib.quote(name, safe = ''))

	if iconimage:
		plexusURI += "&iconimage={CHICON}".format(CHICON = urllib.quote(iconimage, safe=''))
		torrentinURI += "&image={CHICON}".format(CHICON = urllib.quote(iconimage, safe=''))

	print('Executing: PlayMedia("{0}")'.format(plexusURI))

	if settings.getSetting('player') == "1": xbmc.executebuiltin('PlayMedia("{0}")'.format(plexusURI))
	elif settings.getSetting('player') == "0": xbmc.executebuiltin('PlayMedia("{0}")'.format(torrentinURI))
Exemple #2
0
def sopstreams(name, iconimage, sop):
	print("Call sopstreams with name: " + str(name)  + " sop = " + str(sop))

	if settings.getSetting('addon_history') == "true":
		try: add_to_history(name, sop, iconimage)
		except: pass

	plexusURI = 'plugin://program.plexus/?url={CHID}&mode=2&name={CHNAME}'.format(
				CHID   = urllib.quote(sop,  safe = ''),
				CHNAME = urllib.quote(name, safe = ''))

	if iconimage is not None:
		plexusURI += "&iconimage={CHICON}".format(CHICON = urllib.quote(iconimage, safe=''))

	print('Executing: PlayMedia("{0}")'.format(plexusURI))

	xbmc.executebuiltin('PlayMedia("{0}")'.format(plexusURI))
Exemple #3
0
def acestreams(name, iconimage, chid):
    print("Call acestreams with name: " + str(name) + " chid = " + str(chid))

    if settings.getSetting('addon_history') == "true":
        try:
            add_to_history(name, chid, iconimage)
        except:
            pass

    if not chid.startswith("acestream://"):
        chid = "acestream://" + chid

    plexusURI = 'plugin://program.plexus/?url={CHURL}&mode=1&name={CHNAME}'.format(
        CHURL=urllib.quote(chid, safe=''), CHNAME=urllib.quote(name, safe=''))

    if iconimage:
        plexusURI += "&iconimage={CHICON}".format(
            CHICON=urllib.quote(iconimage, safe=''))

    print('Executing: PlayMedia("{0}")'.format(plexusURI))

    xbmc.executebuiltin('PlayMedia("{0}")'.format(plexusURI))
Exemple #4
0
def command_handler(): #eventually turn this into a command->fn dict
    command = ""
    while "quit" not in command  or "exit" not in command or "nothing" not in command or "go" not in command:
        command = str(input("What do you want to do? \n")).lower()
        if "go" in command and "to" in command or "goto" in command or "show" in command and "me" in command:
            if True:
                webnav.navigate_web(command)
                print("Launching web.")
            else:
                print("You don't currently have web access.")
        elif "headsdownfor" in command or "hdfor" in command:
            print(scheduler.scheduler(command))
        elif "blocktime" in command or "time" in command:
            print(scheduler.wake_update())
        elif "unblock" in command:
            print(scheduler.unblock())
        elif "callme" in command or "call me" in command:
            print(greeting.nickname(command))
        elif "lyrics" in command and "by" in command:
            print(music.query_handler(command))
        elif "run" in command:
            print(terminal.run_bash(command[command.index("run")+3:]))
        elif "plus one" in command or "+1" in command or "+ 1" in command or "plus 1" in command:
            print(motiv.plus_one())
        elif "get score" in command or "getscore" in command:
            print(motiv.get_score(False))
        elif "reset" in command:
            print(motiv.reset())
        elif "quit" in command  or "exit" in command or "nothing" in command or "go" in command:
            break
        else:
            print("Invalid command: " + command)

        if validity_checker(command):
            history.add_to_history(command)
    return "Have a nice day! (=^..^=)"
Exemple #5
0
def sopstreams(name, iconimage, sop, geturl=False):
    if not iconimage:
        iconimage = os.path.join(addonpath, "resources", "art", "sopcast_logo.jpg")
    if "sop://" not in sop:
        sop = "sop://broker.sopcast.com:3912/" + sop
    else:
        pass
    print ("Starting Player Sop URL: " + str(sop))
    labelname = name
    if settings.getSetting("addon_history") == "true":
        try:
            add_to_history(labelname, str(sop), 2, iconimage)
        except:
            pass
    if not xbmc.getCondVisibility("system.platform.windows"):
        if xbmc.getCondVisibility("System.Platform.Android") or settings.getSetting("force_android") == "true":
            if settings.getSetting("external-sopcast") == "0":
                versionNumber = int(xbmc.getInfoLabel("System.BuildVersion")[0:2])
                if versionNumber >= 13:
                    xbmc.executebuiltin(
                        'XBMC.StartAndroidActivity("org.sopcast.android","android.intent.action.VIEW","",' + sop + ")"
                    )
                else:
                    mensagemok(translate(40000), translate(40196), translate(40197))
            else:
                if geturl:
                    return sopstreams_builtin(name, iconimage, sop, True)
                else:
                    sopstreams_builtin(name, iconimage, sop)
        else:
            if geturl:
                return sopstreams_builtin(name, iconimage, sop, True)
            else:
                sopstreams_builtin(name, iconimage, sop)
    else:
        cmd = ["sc", "sdshow", "sopcastp2p"]
        import subprocess

        proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
        config = True
        for line in proc.stdout:
            if " 1060:" in line.rstrip():
                config = False
                print ("Sopcast configuration is not done!")
        if config == False:
            mensagemok(translate(40000), translate(40180), translate(40181), translate(40182))
        else:
            import _winreg

            aReg = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE)

            # Dirty hack to break sopcast h264 codec so double sound can be avoided

            try:
                aKey = _winreg.OpenKey(aReg, r"SOFTWARE\SopCast\Player\InstallPath", 0, _winreg.KEY_READ)
                name, value, type = _winreg.EnumValue(aKey, 0)
                codec_file = os.path.join(os.path.join(value.replace("SopCast.exe", "")), "codec", "sop.ocx")
                _winreg.CloseKey(aKey)
                if xbmcvfs.exists(codec_file):
                    xbmcvfs.rename(
                        codec_file, os.path.join(os.path.join(value.replace("SopCast.exe", "")), "codec", "sop.ocx.old")
                    )
            except:
                pass
            aReg = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE)
            aKey = _winreg.OpenKey(
                aReg, r"SYSTEM\CurrentControlSet\Services\sopcastp2p\Parameters", 3, _winreg.KEY_WRITE
            )
            _winreg.SetValueEx(aKey, "AppParameters", 0, _winreg.REG_SZ, sop)
            _winreg.CloseKey(aKey)
            cmd = ["sc", "start", "sopcastp2p"]
            import subprocess

            proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
            servicecreator = False
            for line in proc.stdout:
                print ("result line: " + line.rstrip())
            res = handle_wait_socket(int(settings.getSetting("socket_time")), translate(40000), translate(40183))

            if res == True:
                print ("Server created - waiting x seconds for confirmation")
                try:
                    sock.close()
                except:
                    pass
                sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                handle_wait(int(settings.getSetting("stream_time")), translate(40000), translate(40184), segunda="")
                try:
                    result = sock.connect(("127.0.0.1", 8902))
                    connected = True
                except:
                    connected = False
                if connected == True:
                    playlist = xbmc.PlayList(1)
                    playlist.clear()
                    listitem = xbmcgui.ListItem(labelname, iconImage=iconimage, thumbnailImage=iconimage)
                    listitem.setLabel(labelname)
                    listitem.setInfo("Video", {"Title": labelname})
                    listitem.setProperty("mimetype", "video/x-msvideo")
                    listitem.setProperty("IsPlayable", "true")
                    windows_sop_url = "http://127.0.0.1:8902/tv.asf"
                    if geturl:
                        return [windows_sop_url, False]
                    listitem.setPath(path=windows_sop_url)
                    playlist.add(windows_sop_url, listitem)
                    xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem)
                    player = SopWindowsPlayer()
                    if int(sys.argv[1]) < 0:
                        player.play(playlist)
                    while player._playbackLock:
                        xbmc.sleep(5000)
                else:
                    xbmc.executebuiltin(
                        "Notification(%s,%s,%i,%s)"
                        % (translate(40000), translate(40040), 1, os.path.join(addonpath, "icon.png"))
                    )
            else:
                xbmc.executebuiltin(
                    "Notification(%s,%s,%i,%s)"
                    % (translate(40000), translate(40040), 1, os.path.join(addonpath, "icon.png"))
                )
            print ("Player reached the end")
            cmd = ["sc", "stop", "sopcastp2p"]
            import subprocess

            proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
            servicecreator = False
            for line in proc.stdout:
                print ("result line" + line.rstrip())
            # dirty hack to break sopcast.exe player codec - renaming the file later
            import _winreg

            aReg = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE)
            try:
                aKey = _winreg.OpenKey(aReg, r"SOFTWARE\SopCast\Player\InstallPath", 0, _winreg.KEY_READ)
                name, value, type = _winreg.EnumValue(aKey, 0)
                codec_file = os.path.join(os.path.join(value.replace("SopCast.exe", "")), "codec", "sop.ocx.old")
                _winreg.CloseKey(aKey)
                if xbmcvfs.exists(codec_file):
                    xbmcvfs.rename(
                        codec_file, os.path.join(os.path.join(value.replace("SopCast.exe", "")), "codec", "sop.ocx")
                    )
            except:
                pass
Exemple #6
0
def sopstreams(name, iconimage, sop):
    if not iconimage: iconimage = os.path.join(addonpath, 'resources', 'art', 'sopcast_logo.jpg')
    if "sop://" not in sop:
        sop = "sop://broker.sopcast.com:3912/" + sop
    else:
        pass
    print("Starting Player Sop URL: " + str(sop))
    labelname = name
    if settings.getSetting('addon_history') == "true":
        try:
            add_to_history(labelname, str(sop), 2, iconimage)
        except:
            pass
    if not xbmc.getCondVisibility('system.platform.windows'):
        if xbmc.getCondVisibility('System.Platform.Android'):
            if settings.getSetting('external-sopcast') == "1":
                xbmc.executebuiltin(
                    'XBMC.StartAndroidActivity("org.sopcast.android","android.intent.action.VIEW","",' + sop + ')')
            else:
                sopstreams_builtin(name, iconimage, sop)
        else:
            sopstreams_builtin(name, iconimage, sop)
    else:
        cmd = ['sc', 'sdshow', 'sopcastp2p']
        import subprocess
        proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
        config = True
        for line in proc.stdout:
            if " 1060:" in line.rstrip():
                config = False
                print("Sopcast configuration is not done!")
        if config == False:
            mensagemok(translate(30000), translate(30027), translate(30028), translate(30029))
        else:
            import _winreg
            aReg = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE)

            # Dirty hack to break sopcast h264 codec so double sound can be avoided

            try:
                aKey = _winreg.OpenKey(aReg, r'SOFTWARE\SopCast\Player\InstallPath', 0, _winreg.KEY_READ)
                name, value, type = _winreg.EnumValue(aKey, 0)
                codec_file = os.path.join(os.path.join(value.replace("SopCast.exe", "")), 'codec', 'sop.ocx')
                _winreg.CloseKey(aKey)
                if xbmcvfs.exists(codec_file): xbmcvfs.rename(codec_file, os.path.join(
                    os.path.join(value.replace("SopCast.exe", "")), 'codec', 'sop.ocx.old'))
            except:
                pass
            aReg = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE)
            aKey = _winreg.OpenKey(aReg, r'SYSTEM\CurrentControlSet\Services\sopcastp2p\Parameters', 3,
                                   _winreg.KEY_WRITE)
            _winreg.SetValueEx(aKey, "AppParameters", 0, _winreg.REG_SZ, sop)
            _winreg.CloseKey(aKey)
            cmd = ['sc', 'start', 'sopcastp2p']
            import subprocess
            proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
            servicecreator = False
            for line in proc.stdout:
                print("result line: " + line.rstrip())
            res = handle_wait_socket(int(settings.getSetting('socket_time')), translate(30000), translate(30030))

            if res == True:
                print("Server created - waiting x seconds for confirmation")
                try:
                    sock.close()
                except:
                    pass
                sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                handle_wait(int(settings.getSetting('stream_time')), translate(30000), translate(30031), segunda='')
                try:
                    result = sock.connect(('127.0.0.1', 8902))
                    connected = True
                except:
                    connected = False
                if connected == True:
                    playlist = xbmc.PlayList(1)
                    playlist.clear()
                    listitem = xbmcgui.ListItem(labelname, iconImage=iconimage, thumbnailImage=iconimage)
                    listitem.setLabel(labelname)
                    listitem.setInfo("Video", {"Title": labelname})
                    listitem.setProperty('mimetype', 'video/x-msvideo')
                    listitem.setProperty('IsPlayable', 'true')
                    windows_sop_url = "http://127.0.0.1:8902/tv.asf"
                    listitem.setPath(path=windows_sop_url)
                    playlist.add(windows_sop_url, listitem)
                    xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem)
                    player = SopWindowsPlayer()
                    if int(sys.argv[1]) < 0:
                        player.play(playlist)
                    while player._playbackLock:
                        xbmc.sleep(5000)
                else:
                    xbmc.executebuiltin("Notification(%s,%s,%i,%s)" % (
                    translate(30000), translate(30032), 1, os.path.join(addonpath, "icon.png")))
            else:
                xbmc.executebuiltin("Notification(%s,%s,%i,%s)" % (
                translate(30000), translate(30032), 1, os.path.join(addonpath, "icon.png")))
            print("Player reached the end")
            cmd = ['sc', 'stop', 'sopcastp2p']
            import subprocess
            proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
            servicecreator = False
            for line in proc.stdout:
                print("result line" + line.rstrip())
            # dirty hack to break sopcast.exe player codec - renaming the file later
            import _winreg
            aReg = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE)
            try:
                aKey = _winreg.OpenKey(aReg, r'SOFTWARE\SopCast\Player\InstallPath', 0, _winreg.KEY_READ)
                name, value, type = _winreg.EnumValue(aKey, 0)
                codec_file = os.path.join(os.path.join(value.replace("SopCast.exe", "")), 'codec', 'sop.ocx.old')
                _winreg.CloseKey(aKey)
                if xbmcvfs.exists(codec_file): xbmcvfs.rename(codec_file, os.path.join(
                    os.path.join(value.replace("SopCast.exe", "")), 'codec', 'sop.ocx'))
            except:
                pass
Exemple #7
0
 def test_add_history(self):
     user = models.User("just-an-dev")
     history.add_to_history(user, "", "", "", "")
Exemple #8
0
def gold(reddit, msg, tx_queue, failover_time):
    user = models.User(msg.author.name)
    if user.is_registered():
        gold_month = number_gold_credit()

        if msg.body.strip() == 'buy':
            # Number of month
            quantity = 1

            # check if we have enough credits
            if not gold_month >= quantity:
                # store in db want an gold, when bot have new credits a PM can be send
                db = TinyDB(config.DATA_PATH + 'reddit_gold_empty.json')
                db.insert({
                    "user": user.username,
                    "quantity": quantity,
                    'time': datetime.datetime.now().isoformat(),
                })
                db.close()

                msg.reply(
                    Template(lang.message_gold_no_more).render(
                        username=user.username))
                return False

            # check user confirmed balance is ok
            if user.get_balance_confirmed() >= config.price_reddit_gold:
                msg.reply(
                    Template(lang.message_gold_no_enough_doge).render(
                        username=user.username))
                return False

            # send amount of one month of gold to address
            tx_id = crypto.tip_user(user.address, config.gold_address,
                                    config.price_reddit_gold, tx_queue,
                                    failover_time)

            if tx_id:
                # send gold reddit
                Redditor(reddit, user.username).gild(months=quantity)

                # update gold reddit table
                store_user_buy(user, quantity, tx_id)

                # update user history
                history.add_to_history(user,
                                       sender=user.username,
                                       receiver="Reddit",
                                       amount=config.price_reddit_gold,
                                       action="buy reddit gold")

                # send succes message
                msg.reply(
                    Template(lang.message_buy_gold_success).render(
                        username=user.username))
            else:
                # send error message
                msg.reply(
                    Template(lang.message_buy_gold_error).render(
                        username=user.username))

        elif msg.body.strip() == 'remind':
            # store in db want an gold, when bot have new credits a PM can be send
            db = TinyDB(config.DATA_PATH + 'reddit_gold_remind.json')
            db.insert({
                "user": user.username,
                "remind": "True",
                'time': datetime.datetime.now().isoformat(),
            })
            db.close()

        else:
            # send info on reddit gold
            msg.reply(
                Template(lang.message_buy_gold).render(
                    username=user.username,
                    gold_credit=gold_month,
                    price=config.price_reddit_gold))
    else:
        bot_logger.logger.info('user %s not registered (command : donate) ' %
                               user.username)
        msg.reply(
            Template(lang.message_need_register +
                     lang.message_footer).render(username=user.username))