gapato / livestreamer-curses

Limited text interface/front-end to http://github.com/chrippa/livestreamer
MIT License
35 stars 2 forks source link

Python 3 support #3

Closed Serranya closed 10 years ago

Serranya commented 10 years ago

Hello im getting the following error with version 1.1.0:

Traceback (most recent call last):
  File "/usr/bin/livestreamer-curses", line 9, in <module>
    load_entry_point('livestreamer-curses==1.1.0', 'console_scripts', 'livestreamer-curses')()
  File "/usr/lib/python3.4/site-packages/livestreamer_curses/main.py", line 881, in main
    parser.add_argument('-d', type=unicode, metavar='database', help='default: ~/.livestreamer-curses.db',
NameError: name 'unicode' is not defined

I dont know any python, but i think the cmd string should be quoted.

gapato commented 10 years ago

Are you using Python 3, by chance ? It's not supported yet, unfortunately.

Serranya commented 10 years ago

Yes, im using Python 3.4.1

gapato commented 10 years ago

Great, I'll work on that. Meanwhile, I guess you will have to stick to 2.6-2.7

gapato commented 10 years ago

I've pushed initial support, you can test with : $ git clone http://github.com/gapato/livestreamer-curses/ $ cd livestreamer-curses $ git checkout python3 $ sudo python setup.py install # or wherever your python3 interpreter is and report back.

Serranya commented 10 years ago

It installed without a problem. I also added a stream, and played it. No problems so far :+1:

Serranya commented 10 years ago

Ok i found a way to crash it again. The Crash is reproducible: Start livestreamer-curses filter by a random string unset filter press o

If have CHECK_ONLINE_ON_START = True in my .livestreamer-cursesrc and all streams where offline at the time of testing

The Error i get is:

Traceback (most recent call last):
  File "/usr/bin/livestreamer-curses", line 9, in <module>
    load_entry_point('livestreamer-curses==1.1.0', 'console_scripts', 'livestreamer-curses')()
  File "/usr/lib/python3.4/site-packages/livestreamer_curses/main.py", line 908, in main
    curses.wrapper(l)
  File "/usr/lib/python3.4/curses/__init__.py", line 94, in wrapper
    return func(stdscr, *args, **kwds)
  File "/usr/lib/python3.4/site-packages/livestreamer_curses/main.py", line 221, in __call__
    self.run()
  File "/usr/lib/python3.4/site-packages/livestreamer_curses/main.py", line 361, in run
    self.refilter_streams()
  File "/usr/lib/python3.4/site-packages/livestreamer_curses/main.py", line 728, in refilter_streams
    and (self.filter in s['name'].lower() or self.filter in s['url'].lower())):
TypeError: 'in <string>' requires string as left operand, not NoneType
Serranya commented 10 years ago

And another crash with the same setting as above e.g CHECK_ONLINE_ON_START = True and no streams are online.

Also reproducible open livestreamer-curses press a enter url press enter

Traceback (most recent call last):
  File "/usr/bin/livestreamer-curses", line 9, in <module>
    load_entry_point('livestreamer-curses==1.1.0', 'console_scripts', 'livestreamer-curses')()
  File "/usr/lib/python3.4/site-packages/livestreamer_curses/main.py", line 908, in main
    curses.wrapper(l)
  File "/usr/lib/python3.4/curses/__init__.py", line 94, in wrapper
    return func(stdscr, *args, **kwds)
  File "/usr/lib/python3.4/site-packages/livestreamer_curses/main.py", line 221, in __call__
    self.run()
  File "/usr/lib/python3.4/site-packages/livestreamer_curses/main.py", line 356, in run
    self.prompt_new_stream()
  File "/usr/lib/python3.4/site-packages/livestreamer_curses/main.py", line 853, in prompt_new_stream
    self.add_stream(name, url)
  File "/usr/lib/python3.4/site-packages/livestreamer_curses/main.py", line 762, in add_stream
    for (k,v) in s_res.iteritems():
AttributeError: 'dict' object has no attribute 'iteritems'
gapato commented 10 years ago

It looks like the first error is not Python 3 specific, and the second definitely is. I'll look into it, thank you for your reports!

raylu commented 10 years ago

dict.iteritems was renamed to dict.items. if you want the old items, you need to list(dict.items()) (but you don't)

gapato commented 10 years ago

Is there an alternative to list(dict.items()) if I want to keep 2.x compatiblity, which I do ?

gapato commented 10 years ago

I've pushed a couple of fixes, it should work better now. Writing Python 2/3 compatible code is horrible, fwiw.

Serranya commented 10 years ago

Great, all the problems i reported are now gone :)

But i found already the next problem :D

If i maximize the window of my terminal, i get the following

Traceback (most recent call last):
  File "/usr/bin/livestreamer-curses", line 9, in <module>
    load_entry_point('livestreamer-curses==1.1.0', 'console_scripts', 'livestreamer-curses')()
  File "/usr/lib/python3.4/site-packages/livestreamer_curses/main.py", line 925, in main
    curses.wrapper(l)
  File "/usr/lib/python3.4/curses/__init__.py", line 94, in wrapper
    return func(stdscr, *args, **kwds)
  File "/usr/lib/python3.4/site-packages/livestreamer_curses/main.py", line 238, in __call__
    self.run()
  File "/usr/lib/python3.4/site-packages/livestreamer_curses/main.py", line 315, in run
    (r, w, x) = select.select(souts, [], [], 1)
  File "/usr/lib/python3.4/site-packages/livestreamer_curses/main.py", line 296, in resize
    self.move(stream_cursor, absolute=True, pad_name='streams')
  File "/usr/lib/python3.4/site-packages/livestreamer_curses/main.py", line 570, in move
    self.refresh_current_pad()
  File "/usr/lib/python3.4/site-packages/livestreamer_curses/main.py", line 505, in refresh_current_pad
    pad.refresh(self.offsets[self.current_pad], 0, 2, self.pad_x, self.pad_h, self.pad_w)
_curses.error: prefresh() returned ERR

Im using XFCE 4.10 with the default terminal and windowmanager.

gapato commented 10 years ago

I have the same issue, it not easy to trigger however. Could you open a separate issue ?

Serranya commented 10 years ago

I have opened Issue https://github.com/gapato/livestreamer-curses/issues/4.

gapato commented 10 years ago

Ok, I will leave this issue open for a few days in case some other bug crops up, and if not I'll merge into master.