Skip to content

Commit

Permalink
Using new RxPY imports. Properly using the helix stream object. Readm…
Browse files Browse the repository at this point in the history
…e examples updated.
  • Loading branch information
PetterKraabol committed Jul 17, 2019
1 parent 550481a commit 89c67fa
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 8 deletions.
8 changes: 4 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ print(helix.video(318017128).title)
```python
# Video Comments (VOD chat)

for comment in helix.video(318017128).comments():
for comment in helix.video(318017128).comments:
print(comment.commenter.display_name)


Expand All @@ -55,13 +55,13 @@ for video, comments in helix.videos([318017128, 317650435]).comments():
print(comment.commenter.display_name, comment.message.body)


for video, comments in helix.user('sodapoppin').videos().comments():
for video, comments in helix.user('sodapoppin').videos().comments:
for comment in comments:
print(comment.commenter.display_name, comment.message.body)


for user, videos in helix.users('sodapoppin', 'reckful').videos(first=5):
for video, comments in videos.comments():
for video, comments in videos.comments:
for comment in comments:
print(comment.commenter.display_name, comment.message.body)
```
Expand All @@ -70,7 +70,7 @@ for user, videos in helix.users('sodapoppin', 'reckful').videos(first=5):
# Twitch Chat

twitch.Chat(channel='#sodapoppin', nickname='zarlach', oauth='oauth:xxxxxx').subscribe(
lambda message: print(message.channel, message.user().display_name, message.text))
lambda message: print(message.channel, message.user.display_name, message.text))
```

### Features
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@
test_suite='tests',
tests_require=test_requirements,
url='https://github.com/PetterKraabol/Twitch-Python',
version='0.0.13',
version='0.0.12',
zip_safe=True,
)
2 changes: 1 addition & 1 deletion twitch/chat/chat.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import time
from typing import Optional

from rx.subjects import Subject
from rx.subject import Subject

import twitch
import twitch.chat as chat
Expand Down
2 changes: 1 addition & 1 deletion twitch/chat/irc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import threading
from typing import List

from rx.subjects import Subject
from rx.subject import Subject


class IRC(threading.Thread):
Expand Down
8 changes: 8 additions & 0 deletions twitch/helix/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ def videos(self, **kwargs) -> 'helix.Videos':
def stream(self) -> 'helix.Stream':
return helix.Streams(api=self._api, user_id=int(self.id))[0]

@property
def is_live(self) -> bool:
try:
if self.stream:
return True
except helix.StreamNotFound:
return False

def following(self, **kwargs) -> 'helix.Follows':
kwargs['from_id'] = self.id
return helix.Follows(api=self._api, follow_type='following', **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion twitch/helix/resources/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self, api: API, **kwargs):
response: dict = self._api.get(self._path, params=kwargs)

if response['data']:
self._data = [Stream(api=self._api, data=video) for video in
self._data = [helix.Stream(api=self._api, data=video) for video in
self._api.get(self._path, params=kwargs)['data']]
else:
raise StreamNotFound('No stream was found')
Expand Down

0 comments on commit 89c67fa

Please sign in to comment.