Example #1
0
def handle_url(args):
    (pluginname, plugin) = livestreamer.resolve_url(args.url)

    if not plugin:
        exit(("No plugin can handle url: {0}").format(args.url))

    streams = plugin.get_streams(args.url)

    if not streams:
        exit(("No streams found on url: {0}").format(args.url))

    keys = list(streams.keys())
    keys.sort()
    validstreams = (", ").join(keys)

    if args.stream:
        if args.stream in streams:
            stream = streams[args.stream]
            cmdline = plugin.stream_cmdline(stream, args.output or "-")

            if args.cmdline:
                print(cmdline)
                sys.exit()
            else:
                if not args.output:
                    cmdline = ("{0} | {1} -").format(cmdline, args.player)
                os.system(cmdline)
        else:
            print(("This channel does not have stream: {0}").format(args.stream))
            print(("Valid streams: {0}").format(validstreams))
            sys.exit()
    else:
        print(("Found streams: {0}").format(validstreams))
Example #2
0
def handle_url(args):
    channel = livestreamer.resolve_url(args.url)

    if not channel:
        exit(("No plugin can handle url: {0}").format(args.url))

    try:
        streams = channel.get_streams()
    except livestreamer.PluginError as err:
        exit(("Error from plugin while retrieving streams: {0}").format(err))

    if len(streams) == 0:
        exit(("No streams found on url: {0}").format(args.url))

    keys = list(streams.keys())
    keys.sort()
    validstreams = (", ").join(keys)

    if args.stream:
        if args.stream in streams:
            stream = streams[args.stream]
            cmdline = stream.cmdline(args.output or "-")

            if args.cmdline:
                print(cmdline.format())
                sys.exit()
            else:
                if not args.output:
                    cmdline.pipe = ("{0} -").format(args.player)

                os.system(cmdline.format())
        else:
            print(("This channel does not have stream: {0}").format(args.stream))
            print(("Valid streams: {0}").format(validstreams))
    else:
        print(("Found streams: {0}").format(validstreams))
Example #3
0
File: ocr.py Project: pmrowla/pokr
    screen = cv2.resize(screen, (160, 144))
    return screen

def test_corpus():
    import os
    for fn in os.listdir('corpus'):
        print '#' * 20 + ' ' + fn
        print
        print identifier.screen_to_text(extract_screen(cv2.cvtColor(cv2.imread('corpus/' + fn), cv2.COLOR_BGR2GRAY)))

#test_corpus()

if '--direct' in sys.argv:
    import livestreamer
    livestreamer = livestreamer.Livestreamer()
    plugin = livestreamer.resolve_url('http://twitch.tv/twitchplayspokemon')
    streams = plugin.get_streams()
    cv = cv2.VideoCapture(streams['source'].url)
else:
    cv = cv2.VideoCapture('/dev/stdin')

frame_queue = Queue.Queue(120)

def grab_frames():
    while True:
        cv.grab()
        success, frame = cv.retrieve()
        if success:
            try:
                frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
                frame_queue.put(frame, block=False, timeout=1.)