GiedriusS / TwitchNotifier

A tool that sits in the background and notifies you using libnotify if a channel you follow comes online or goes offline. Optionally it can only check for offline/online channels once.
GNU General Public License v3.0
27 stars 4 forks source link

hangs when using -c for user's follows - py3 3.4.0 #1

Closed stagnation closed 9 years ago

stagnation commented 9 years ago

EDIT: just realized that this is probably working as intended, I just don't have the notification deps set up. 2015-04-28 08:50 gmt+1

from a fresh gitclone: with python3 3.4.0 (less than dependencies but the latest for my LTS ubuntu, will leave this here and look into updating python3 manually in the meantime)

$ ./twitchnotifier -c 1b59d9bd844d438daed1

Traceback (most recent call last): File "./twitchnotifier", line 2, in import library File "/home/spill/bin/gits/TwitchNotifier/library.py", line 69 print('No messages key exists in ' + self.cfg, file=sys.stderr) ^ SyntaxError: invalid syntax

*\ changed shebang to python3 to resolve;

$ ./twitchnotifier -c 1b59d9bd844d438daed1 No messages key exists in twitchnotifier.cfg

^CTraceback (most recent call last): File "./twitchnotifier", line 74, in time.sleep(args.interval) KeyboardInterrupt

*\ got stuck here, had to interupt.

$ python3 twitchnotifier -u nugiyen No messages key exists in twitchnotifier.cfg nugiyen is online $

*\ works nice enough, only want to remove/resolve the no key error

$ python3 twitchnotifier -c 1b59d9bd844d438daed1

*\ hangs, 30secs +

$ python3 twitchnotifier --nick 1b59d9bd844d438daed1

No messages key exists in twitchnotifier.cfg ^CTraceback (most recent call last): File "twitchnotifier", line 76, in new = api.get_status() File "/home/spill/bin/gits/TwitchNotifier/library.py", line 219, in get_status 'limit': limit}) File "/home/spill/bin/gits/TwitchNotifier/library.py", line 114, in get_followed_channels r = requests.get(url, headers=head, params=payload) File "/usr/lib/python3/dist-packages/requests/api.py", line 55, in get return request('get', url, _kwargs) File "/usr/lib/python3/dist-packages/requests/api.py", line 44, in request return session.request(method=method, url=url, _kwargs) File "/usr/lib/python3/dist-packages/requests/sessions.py", line 455, in request resp = self.send(prep, _send_kwargs) File "/usr/lib/python3/dist-packages/requests/sessions.py", line 558, in send r = adapter.send(request, _kwargs) File "/usr/lib/python3/dist-packages/requests/adapters.py", line 330, in send timeout=timeout File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 557, in urlopen body=body, headers=headers) File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 382, in _make_request conn.request(method, url, **httplib_request_kw) File "/usr/lib/python3.4/http/client.py", line 1065, in request self._send_request(method, url, body, headers) File "/usr/lib/python3.4/http/client.py", line 1103, in _send_request self.endheaders(body) File "/usr/lib/python3.4/http/client.py", line 1061, in endheaders self._send_output(message_body) File "/usr/lib/python3.4/http/client.py", line 906, in _send_output self.send(msg) File "/usr/lib/python3.4/http/client.py", line 841, in send self.connect() File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 133, in connect ssl_version=resolved_ssl_version) File "/usr/lib/python3/dist-packages/urllib3/util.py", line 619, in ssl_wrap_socket return context.wrap_socket(sock, server_hostname=server_hostname) File "/usr/lib/python3.4/ssl.py", line 364, in wrap_socket _context=self) File "/usr/lib/python3.4/ssl.py", line 578, in init self.do_handshake() File "/usr/lib/python3.4/ssl.py", line 805, in do_handshake self._sslobj.do_handshake() KeyboardInterrupt

$ ./twitchnotifier -c 1b59d9bd844d438daed1 -n No messages key exists in twitchnotifier.cfg willywonka_hc ziggydlive phgp_tv wcs skysonik nugiyen iammal fazz njw0819

*\ works though,

GiedriusS commented 9 years ago

So does -c work? Please close then. Yeah, some distributions have python 2.x installed as /usr/bin/python and python 3.x as /usr/bin/python3. On archlinux which I use python 3.x is installed as /usr/bin/python thus that's why I use. But I just noticed that there is /usr/bin/python3 which is a symlink to python 3.x so I could change that in the code so you don't have to change it anymore. To remove the " No messages key exists in twitchnotifier.cfg" error put twitchnotifier.cfg in your $XDG_CONFIG_HOME or $HOME/.config with "[messages]" and the required options. You can find an example in the repo. Btw, that error is sent to stderr so you can filter it out if you don't want it with ./twitchnotifier ... 2>/dev/null. And with the newest git version you can add something like "-l ~/log" to make it log every online/offline to ~/log and then see if it works or not

stagnation commented 9 years ago

Alright, now I understand. Thanks. I will invesitgate dependencies and notification's further, is the it intended to output notifications to stdout when a stream goes live as well as deploying notifications? I have it running in the background with only -c now, hoping for channels to go live.

as for the formatting, put the file in .config and it works well with the predefined patterns, I'd like to have the output as

channel name $1 title $5 url, http://twitch.tv/$1

(note line breaks)

for integration into my terminal url grabber that opens mpv / livestreamer, I will look into it further towards the end of the week and sohuld be able to implement it myself and it will then completely replace my old fork, not to mention that the api-way of getting titles is a whole lot faster, very nice.

will close as soon as I can confirm that -c works

stagnation commented 9 years ago

update: just got two popup messages for (two) tscchannels going offline, (still no online message but testing is inconclusive).

update: got an online pop-up, but nothing is written in the terminal. I'd probably prefer that but don't really use the notifier feature.

closing issue, was working the whole time (at least after ubuntu upgrade, that gave me fancier popups)

GiedriusS commented 9 years ago

"... is online/offline" only gets printed to stdout if it fails to show a notification. Unfortunately you won't be able to put '\n' in the .config because python understands it as the end of the key/value line. It makes sense because there is no other way to determine if the key=value line has ended. If you want TwitchNotifier to do that the only way would be removing the option from the .cfg and modifying the defaults in library.py to include '\n' where you want them. Instead you could use some other special character between the info you want and then use something like awk to parse whichever part of it you want. Finally, recently I've added the -l feature where it will write the events to a file in the format you want. You can use that instead of having everything printed out to stdout. TwitchNotifier is intended to be a daemon :)

EDIT: I could implement some time in the future a option to print information about every event to stdout (and a new format in .cfg)

stagnation commented 9 years ago

yeah I settled for the easy solution:

        ret = ret.replace('$8', "http://twitch.tv/"+chan)
        ret = ret.replace('$n', "\n")

so this is the same behavior as what I forked the previous release for. Thank you very much! (my fork took about 10 secs to render the titles, when many streams were on, so this is a huge improvement)