예제 #1
0
def handlerPlayEpisode():		
	handler = getattr(__import__(_params['archive']), 'getStream' )	
	stream = handler(_params['url'])
	with open(_episodesRefreshFlag,'w') as f:
		f.write("1") 
	watchlog.setWatched(_watchlogPath, _baseUrl, _params['name'])
	util.play(stream, _params['name'])
	if os.path.isfile(_episodesRefreshFlag):
		xbmc.executebuiltin("Container.Refresh()")
예제 #2
0
파일: gui.py 프로젝트: sblagodatny/kodiplus
 def play(self):
     channel = self.channels[self.selectedChannel]
     url = channel['url']
     headers = None
     if channel['name'] == 'קשת':
         url, headers = streams.getKeshetStream()
     if channel['name'] == 'רשת':
         url, headers = streams.getReshetStream()
     util.play(url, channel['name'], headers)
예제 #3
0
def handlerPlay():
    streams, cookies = youtube.getStreams(_params['id'], _cookiesFile)
    itag = util.firstMatch(youtube.itagsVideo, streams.keys())
    if itag is None:
        itag = util.firstMatch(youtube.itagsLive, streams.keys())
        if itag is None:
            xbmcgui.Dialog().ok('Error', 'Unable to get stream')
            return
    url = streams[itag]
    util.play(url, _params['name'], util.headerCookie(cookies))
예제 #4
0
def test_play():
    from util import play
    from util import read_file_to_list
    from util import count
    p1, p2 = read_file_to_list("testinput.txt")
    p = play(p1, p2)
    assert 306 == count(p)
예제 #5
0
def test_play10():
    from util import play
    init = [3,8,9,1,2,5,4,6,7]
    l = len(init)

    cups = dict()
    for i in range(l):
        cups[init[i]] = init[(i+1) % l]

    play(cups,init[0],10)

    n = 1
    s = ""
    for _ in range(l-1):
        s += str(cups[n])
        n = cups[n]

    assert "92658374" == s
예제 #6
0
 def handle(self, handler_input):
     # type: (HandlerInput) -> Response
     logger.info("In PlaybackFailedHandler")
     request = handler_input.request_envelope.request
     logger.info("Playback failed: {}".format(request.error))
     return util.play(url=util.audio_data(request)["url"],
                      offset=0,
                      text=None,
                      card_data=None,
                      response_builder=handler_input.response_builder)
예제 #7
0
    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        logger.info("In PlayCommandHandler")
        _ = handler_input.attributes_manager.request_attributes["_"]
        request = handler_input.request_envelope.request

        if util.audio_data(request)["start_jingle"]:
            if util.should_play_jingle(handler_input):
                return util.play(
                    url=util.audio_data(request)["start_jingle"],
                    offset=0,
                    text=None,
                    card_data=None,
                    response_builder=handler_input.response_builder)

        return util.play(url=util.audio_data(request)["url"],
                         offset=0,
                         text=None,
                         card_data=None,
                         response_builder=handler_input.response_builder)
예제 #8
0
 def handle(self, handler_input):
     # type: (HandlerInput) -> Response
     logger.info("In ResumeIntentHandler")
     request = handler_input.request_envelope.request
     _ = handler_input.attributes_manager.request_attributes["_"]
     speech = _(data.RESUME_MSG).format(
         util.audio_data(request)["card"]["title"])
     return util.play(url=util.audio_data(request)["url"],
                      offset=0,
                      text=speech,
                      card_data=util.audio_data(request)["card"],
                      response_builder=handler_input.response_builder)
예제 #9
0
def evaluate(inp, client, l, DBlocation):
    inp = inp.split(' ')
    status = client.status()

    if len(inp) > 1 and not str(inp[1]):
        inp.pop()

    if inp[0] == 'p' or 'play' == (inp[0]):
        try:
            if not status['state'] == 'stop':
                if len(inp) == 1:
                    util.pause(client)
                else:
                    util.play(client, int(inp[1]))
            else:
                if len(inp) == 1:
                    util.play(client, 0)
                else:
                    util.play(client, int(inp[1]))
        except:
            print('mpd error: bad song index')
    elif inp[0] == 'pause':
        util.pause(client)
    elif inp[0] == 'next' or inp[0] == 'n':
        util.next(client)
    elif inp[0] == 'previous' or inp[0] == 'ps':
        util.previous(client)
    elif inp[0] == 'stop':
        util.stop(client)
    elif inp[0] == 'pl' or inp[0] == 'playlist':
        util.print_playlist(client)
    elif inp[0] == 'update' or inp[0] == 'u':
        util.update(client)
    elif inp[0] == 'clear':
        util.clear(client)
    elif inp[0] == 'random':
        util.mpdrandom(client, inp[1])
    elif inp[0] == 'shuffle':
        util.shuffle(client)
    elif inp[0] == 'consume':
        util.consume(client, inp[1])
    elif inp[0] == 'swap':
        util.swap(client, int(inp[1]) - 1, int(inp[2]) - 1)
    elif inp[0] == 'single':
        util.single(client, inp[1])
    elif inp[0] == 'search' or inp[0] == 's':
        if '-f' in inp or '--filter' in inp:
            l = util.mpdsearch(inp[1], inp, DBlocation, True)
        else:
            l = util.mpdsearch(inp[1], inp, DBlocation, False)
    elif inp[0] == 'a' or inp[0] == 'add':
        if l:
            for line in l:
                client.add(line)
        else:
            print('You have to search first!')
    elif inp[0] == 'q' or inp[0] == 'quit':
        quit()
    return l
예제 #10
0
    def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        logger.info("In LaunchRequestOrPlayAudioHandler")

        _ = handler_input.attributes_manager.request_attributes["_"]
        request = handler_input.request_envelope.request

        if util.audio_data(request)["start_jingle"]:
            if util.should_play_jingle(handler_input):
                return util.play(
                    url=util.audio_data(request)["start_jingle"],
                    offset=0,
                    text=_(data.WELCOME_MSG).format(
                        util.audio_data(request)["card"]["title"]),
                    card_data=util.audio_data(request)["card"],
                    response_builder=handler_input.response_builder)

        return util.play(url=util.audio_data(request)["url"],
                         offset=0,
                         text=_(data.WELCOME_MSG).format(
                             util.audio_data(request)["card"]["title"]),
                         card_data=util.audio_data(request)["card"],
                         response_builder=handler_input.response_builder)
예제 #11
0
def handlerPlay():
    url = 'file://' + urllib.pathname2url(_params['path'])
    util.play(url, _params['name'])
예제 #12
0
def test_play3():
    from util import play
    a = [5, 4, 6, 7, 8, 9, 1, 3, 2]
    play(a)
    assert a == [8, 9, 1, 3, 4, 6, 7, 2, 5]
예제 #13
0
def test_play2():
    from util import play
    a = [2, 8, 9, 1, 5, 4, 6, 7, 3]
    play(a)
    assert a == [5, 4, 6, 7, 8, 9, 1, 3, 2]
예제 #14
0
def test_play1():
    from util import play
    a = [3, 8, 9, 1, 2, 5, 4, 6, 7]
    play(a)
    assert a == [2, 8, 9, 1, 5, 4, 6, 7, 3]
예제 #15
0
def handlerPlay():
    watchlog.setWatched(_watchedFolder, _baseUrl,
                        _params['hashString'] + '|' + _params['name'])
    util.play(_params['url'], _params['name'])
    xbmc.executebuiltin("Container.Refresh()")
예제 #16
0
def handlerPlay():
    util.play(_params['url'], _params['name'])
예제 #17
0
def test_endless_loop():
    from util import play
    from util import count
    p = play([43, 19], [2, 29, 14])
    assert 0 == count(p)
예제 #18
0
from config import CONTRACT_ADDRESS
from util import play, get_data
import time
import random

while True:
    time.sleep(random.randint(3600, 7200))
    data = get_data()
    time.sleep(45)
    print(play(CONTRACT_ADDRESS, data))