pytchat-ng 0.5.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pytchat_ng-0.5.6/LICENSE +21 -0
- pytchat_ng-0.5.6/PKG-INFO +211 -0
- pytchat_ng-0.5.6/README.md +189 -0
- pytchat_ng-0.5.6/pyproject.toml +38 -0
- pytchat_ng-0.5.6/pytchat/__init__.py +43 -0
- pytchat_ng-0.5.6/pytchat/api.py +34 -0
- pytchat_ng-0.5.6/pytchat/config/__init__.py +16 -0
- pytchat_ng-0.5.6/pytchat/config/mylogger.py +38 -0
- pytchat_ng-0.5.6/pytchat/core/__init__.py +7 -0
- pytchat_ng-0.5.6/pytchat/core/pytchat.py +228 -0
- pytchat_ng-0.5.6/pytchat/core_async/__init__.py +0 -0
- pytchat_ng-0.5.6/pytchat/core_async/buffer.py +38 -0
- pytchat_ng-0.5.6/pytchat/core_async/livechat.py +374 -0
- pytchat_ng-0.5.6/pytchat/core_multithread/__init__.py +0 -0
- pytchat_ng-0.5.6/pytchat/core_multithread/buffer.py +38 -0
- pytchat_ng-0.5.6/pytchat/core_multithread/livechat.py +358 -0
- pytchat_ng-0.5.6/pytchat/exceptions.py +81 -0
- pytchat_ng-0.5.6/pytchat/paramgen/__init__.py +0 -0
- pytchat_ng-0.5.6/pytchat/paramgen/arcparam.py +44 -0
- pytchat_ng-0.5.6/pytchat/paramgen/enc.py +24 -0
- pytchat_ng-0.5.6/pytchat/paramgen/liveparam.py +70 -0
- pytchat_ng-0.5.6/pytchat/parser/__init__.py +0 -0
- pytchat_ng-0.5.6/pytchat/parser/live.py +122 -0
- pytchat_ng-0.5.6/pytchat/processors/__init__.py +0 -0
- pytchat_ng-0.5.6/pytchat/processors/chat_processor.py +30 -0
- pytchat_ng-0.5.6/pytchat/processors/combinator.py +42 -0
- pytchat_ng-0.5.6/pytchat/processors/compatible/__init__.py +0 -0
- pytchat_ng-0.5.6/pytchat/processors/compatible/processor.py +88 -0
- pytchat_ng-0.5.6/pytchat/processors/compatible/renderer/__init__.py +0 -0
- pytchat_ng-0.5.6/pytchat/processors/compatible/renderer/base.py +82 -0
- pytchat_ng-0.5.6/pytchat/processors/compatible/renderer/currency.py +38 -0
- pytchat_ng-0.5.6/pytchat/processors/compatible/renderer/legacypaid.py +42 -0
- pytchat_ng-0.5.6/pytchat/processors/compatible/renderer/membership.py +40 -0
- pytchat_ng-0.5.6/pytchat/processors/compatible/renderer/paidmessage.py +42 -0
- pytchat_ng-0.5.6/pytchat/processors/compatible/renderer/paidsticker.py +47 -0
- pytchat_ng-0.5.6/pytchat/processors/compatible/renderer/textmessage.py +6 -0
- pytchat_ng-0.5.6/pytchat/processors/default/__init__.py +0 -0
- pytchat_ng-0.5.6/pytchat/processors/default/custom_encoder.py +11 -0
- pytchat_ng-0.5.6/pytchat/processors/default/processor.py +181 -0
- pytchat_ng-0.5.6/pytchat/processors/default/renderer/__init__.py +0 -0
- pytchat_ng-0.5.6/pytchat/processors/default/renderer/base.py +101 -0
- pytchat_ng-0.5.6/pytchat/processors/default/renderer/currency.py +38 -0
- pytchat_ng-0.5.6/pytchat/processors/default/renderer/donation.py +6 -0
- pytchat_ng-0.5.6/pytchat/processors/default/renderer/legacypaid.py +15 -0
- pytchat_ng-0.5.6/pytchat/processors/default/renderer/membership.py +18 -0
- pytchat_ng-0.5.6/pytchat/processors/default/renderer/paidmessage.py +47 -0
- pytchat_ng-0.5.6/pytchat/processors/default/renderer/paidsticker.py +47 -0
- pytchat_ng-0.5.6/pytchat/processors/default/renderer/textmessage.py +6 -0
- pytchat_ng-0.5.6/pytchat/processors/dummy_processor.py +10 -0
- pytchat_ng-0.5.6/pytchat/processors/html_archiver.py +170 -0
- pytchat_ng-0.5.6/pytchat/processors/jsonfile_archiver.py +69 -0
- pytchat_ng-0.5.6/pytchat/processors/simple_display_processor.py +61 -0
- pytchat_ng-0.5.6/pytchat/processors/speed/__init__.py +0 -0
- pytchat_ng-0.5.6/pytchat/processors/speed/calculator.py +186 -0
- pytchat_ng-0.5.6/pytchat/processors/superchat/__init__.py +0 -0
- pytchat_ng-0.5.6/pytchat/processors/superchat/calculator.py +75 -0
- pytchat_ng-0.5.6/pytchat/processors/tsv_archiver.py +67 -0
- pytchat_ng-0.5.6/pytchat/util/__init__.py +147 -0
- pytchat_ng-0.5.6/pytchat_ng.egg-info/PKG-INFO +211 -0
- pytchat_ng-0.5.6/pytchat_ng.egg-info/SOURCES.txt +72 -0
- pytchat_ng-0.5.6/pytchat_ng.egg-info/dependency_links.txt +1 -0
- pytchat_ng-0.5.6/pytchat_ng.egg-info/requires.txt +5 -0
- pytchat_ng-0.5.6/pytchat_ng.egg-info/top_level.txt +2 -0
- pytchat_ng-0.5.6/setup.cfg +4 -0
- pytchat_ng-0.5.6/tests/test_calculator_parse.py +71 -0
- pytchat_ng-0.5.6/tests/test_compatible_processor.py +180 -0
- pytchat_ng-0.5.6/tests/test_compatible_processor2.py +33 -0
- pytchat_ng-0.5.6/tests/test_default_processor.py +227 -0
- pytchat_ng-0.5.6/tests/test_default_processor2.py +108 -0
- pytchat_ng-0.5.6/tests/test_extract_video_id.py +55 -0
- pytchat_ng-0.5.6/tests/test_jsonfile_archiver.py +48 -0
- pytchat_ng-0.5.6/tests/test_parser.py +34 -0
- pytchat_ng-0.5.6/tests/test_speed_calculator.py +64 -0
- pytchat_ng-0.5.6/tests/test_speed_calculator2.py +18 -0
pytchat_ng-0.5.6/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 revertical
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pytchat-ng
|
|
3
|
+
Version: 0.5.6
|
|
4
|
+
Summary: a python library for fetching youtube live chat. (next generation)
|
|
5
|
+
Author-email: revertical <screenkidgreen7@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/revertical/pytchat-ng
|
|
8
|
+
Keywords: youtube,livechat,asyncio
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Programming Language :: Python
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Requires-Python: >=3.7
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Requires-Dist: httpx[http2]
|
|
18
|
+
Provides-Extra: test
|
|
19
|
+
Requires-Dist: pytest-mock; extra == "test"
|
|
20
|
+
Requires-Dist: pytest-httpx; extra == "test"
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
|
|
23
|
+
pytchat-ng
|
|
24
|
+
=======
|
|
25
|
+
|
|
26
|
+
pytchat-ng is a python library for fetching youtube live chat (Next Generation).
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
<br><br><br>
|
|
30
|
+
## Description
|
|
31
|
+
pytchat is a python library for fetching youtube live chat
|
|
32
|
+
without using Selenium or BeautifulSoup.
|
|
33
|
+
|
|
34
|
+
Other features:
|
|
35
|
+
+ Customizable [chat data processors](https://github.com/taizan-hokuto/pytchat/wiki/ChatProcessor) including youtube api compatible one.
|
|
36
|
+
+ Available on asyncio context.
|
|
37
|
+
+ Quick fetching of initial chat data by generating continuation params
|
|
38
|
+
instead of web scraping.
|
|
39
|
+
|
|
40
|
+
For more detailed information, see [wiki](https://github.com/taizan-hokuto/pytchat/wiki). <br>
|
|
41
|
+
|
|
42
|
+
## Install
|
|
43
|
+
```python
|
|
44
|
+
pip install pytchat
|
|
45
|
+
```
|
|
46
|
+
## Examples
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
### Fetch chat data (see [wiki](https://github.com/taizan-hokuto/pytchat/wiki/PytchatCore))
|
|
50
|
+
```python
|
|
51
|
+
import pytchat
|
|
52
|
+
chat = pytchat.create(video_id="uIx8l2xlYVY")
|
|
53
|
+
while chat.is_alive():
|
|
54
|
+
for c in chat.get().sync_items():
|
|
55
|
+
print(f"{c.datetime} [{c.author.name}]- {c.message}")
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
### Output JSON format string (feature of [DefaultProcessor](https://github.com/taizan-hokuto/pytchat/wiki/DefaultProcessor))
|
|
60
|
+
```python
|
|
61
|
+
import pytchat
|
|
62
|
+
import time
|
|
63
|
+
|
|
64
|
+
chat = pytchat.create(video_id="uIx8l2xlYVY")
|
|
65
|
+
while chat.is_alive():
|
|
66
|
+
print(chat.get().json())
|
|
67
|
+
time.sleep(5)
|
|
68
|
+
'''
|
|
69
|
+
# Each chat item can also be output in JSON format.
|
|
70
|
+
for c in chat.get().items:
|
|
71
|
+
print(c.json())
|
|
72
|
+
'''
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
### other
|
|
77
|
+
+ Fetch chat with a buffer ([LiveChat](https://github.com/taizan-hokuto/pytchat/wiki/LiveChat))
|
|
78
|
+
|
|
79
|
+
+ Use with asyncio ([LiveChatAsync](https://github.com/taizan-hokuto/pytchat/wiki/LiveChatAsync))
|
|
80
|
+
|
|
81
|
+
+ YT API compatible chat processor ([CompatibleProcessor](https://github.com/taizan-hokuto/pytchat/wiki/CompatibleProcessor))
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
## Structure of Default Processor
|
|
85
|
+
Each item can be got with `sync_items()` function.
|
|
86
|
+
<table>
|
|
87
|
+
<tr>
|
|
88
|
+
<th>name</th>
|
|
89
|
+
<th>type</th>
|
|
90
|
+
<th>remarks</th>
|
|
91
|
+
</tr>
|
|
92
|
+
<tr>
|
|
93
|
+
<td>type</td>
|
|
94
|
+
<td>str</td>
|
|
95
|
+
<td>"superChat","textMessage","superSticker","newSponsor"</td>
|
|
96
|
+
</tr>
|
|
97
|
+
<tr>
|
|
98
|
+
<td>id</td>
|
|
99
|
+
<td>str</td>
|
|
100
|
+
<td></td>
|
|
101
|
+
</tr>
|
|
102
|
+
<tr>
|
|
103
|
+
<td>message</td>
|
|
104
|
+
<td>str</td>
|
|
105
|
+
<td>emojis are represented by ":(shortcut text):"</td>
|
|
106
|
+
</tr>
|
|
107
|
+
<tr>
|
|
108
|
+
<td>messageEx</td>
|
|
109
|
+
<td>str</td>
|
|
110
|
+
<td>list of message texts and emoji dicts(id, txt, url).</td>
|
|
111
|
+
</tr>
|
|
112
|
+
<tr>
|
|
113
|
+
<td>timestamp</td>
|
|
114
|
+
<td>int</td>
|
|
115
|
+
<td>unixtime milliseconds</td>
|
|
116
|
+
</tr>
|
|
117
|
+
<tr>
|
|
118
|
+
<td>datetime</td>
|
|
119
|
+
<td>str</td>
|
|
120
|
+
<td>e.g. "2019-10-10 12:34:56"</td>
|
|
121
|
+
</tr>
|
|
122
|
+
<td>elapsedTime</td>
|
|
123
|
+
<td>str</td>
|
|
124
|
+
<td>elapsed time. (e.g. "1:02:27") *Replay Only.</td>
|
|
125
|
+
</tr>
|
|
126
|
+
<tr>
|
|
127
|
+
<td>amountValue</td>
|
|
128
|
+
<td>float</td>
|
|
129
|
+
<td>e.g. 1,234.0</td>
|
|
130
|
+
</tr>
|
|
131
|
+
<tr>
|
|
132
|
+
<td>amountString</td>
|
|
133
|
+
<td>str</td>
|
|
134
|
+
<td>e.g. "$ 1,234"</td>
|
|
135
|
+
</tr>
|
|
136
|
+
<tr>
|
|
137
|
+
<td>currency</td>
|
|
138
|
+
<td>str</td>
|
|
139
|
+
<td><a href="https://en.wikipedia.org/wiki/ISO_4217">ISO 4217 currency codes</a> (e.g. "USD")</td>
|
|
140
|
+
</tr>
|
|
141
|
+
<tr>
|
|
142
|
+
<td>bgColor</td>
|
|
143
|
+
<td>int</td>
|
|
144
|
+
<td>RGB Int</td>
|
|
145
|
+
</tr>
|
|
146
|
+
<tr>
|
|
147
|
+
<td>author</td>
|
|
148
|
+
<td>object</td>
|
|
149
|
+
<td>see below</td>
|
|
150
|
+
</tr>
|
|
151
|
+
</table>
|
|
152
|
+
|
|
153
|
+
Structure of author object.
|
|
154
|
+
<table>
|
|
155
|
+
<tr>
|
|
156
|
+
<th>name</th>
|
|
157
|
+
<th>type</th>
|
|
158
|
+
<th>remarks</th>
|
|
159
|
+
</tr>
|
|
160
|
+
<tr>
|
|
161
|
+
<td>name</td>
|
|
162
|
+
<td>str</td>
|
|
163
|
+
<td></td>
|
|
164
|
+
</tr>
|
|
165
|
+
<tr>
|
|
166
|
+
<td>channelId</td>
|
|
167
|
+
<td>str</td>
|
|
168
|
+
<td>*chatter's channel ID.</td>
|
|
169
|
+
</tr>
|
|
170
|
+
<tr>
|
|
171
|
+
<td>channelUrl</td>
|
|
172
|
+
<td>str</td>
|
|
173
|
+
<td></td>
|
|
174
|
+
</tr>
|
|
175
|
+
<tr>
|
|
176
|
+
<td>imageUrl</td>
|
|
177
|
+
<td>str</td>
|
|
178
|
+
<td></td>
|
|
179
|
+
</tr>
|
|
180
|
+
<tr>
|
|
181
|
+
<td>badgeUrl</td>
|
|
182
|
+
<td>str</td>
|
|
183
|
+
<td></td>
|
|
184
|
+
</tr>
|
|
185
|
+
<tr>
|
|
186
|
+
<td>isVerified</td>
|
|
187
|
+
<td>bool</td>
|
|
188
|
+
<td></td>
|
|
189
|
+
</tr>
|
|
190
|
+
<tr>
|
|
191
|
+
<td>isChatOwner</td>
|
|
192
|
+
<td>bool</td>
|
|
193
|
+
<td></td>
|
|
194
|
+
</tr>
|
|
195
|
+
<tr>
|
|
196
|
+
<td>isChatSponsor</td>
|
|
197
|
+
<td>bool</td>
|
|
198
|
+
<td></td>
|
|
199
|
+
</tr>
|
|
200
|
+
<tr>
|
|
201
|
+
<td>isChatModerator</td>
|
|
202
|
+
<td>bool</td>
|
|
203
|
+
<td></td>
|
|
204
|
+
</tr>
|
|
205
|
+
</table>
|
|
206
|
+
|
|
207
|
+
## Licence
|
|
208
|
+
|
|
209
|
+
[](LICENSE)
|
|
210
|
+
|
|
211
|
+
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
pytchat-ng
|
|
2
|
+
=======
|
|
3
|
+
|
|
4
|
+
pytchat-ng is a python library for fetching youtube live chat (Next Generation).
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
<br><br><br>
|
|
8
|
+
## Description
|
|
9
|
+
pytchat is a python library for fetching youtube live chat
|
|
10
|
+
without using Selenium or BeautifulSoup.
|
|
11
|
+
|
|
12
|
+
Other features:
|
|
13
|
+
+ Customizable [chat data processors](https://github.com/taizan-hokuto/pytchat/wiki/ChatProcessor) including youtube api compatible one.
|
|
14
|
+
+ Available on asyncio context.
|
|
15
|
+
+ Quick fetching of initial chat data by generating continuation params
|
|
16
|
+
instead of web scraping.
|
|
17
|
+
|
|
18
|
+
For more detailed information, see [wiki](https://github.com/taizan-hokuto/pytchat/wiki). <br>
|
|
19
|
+
|
|
20
|
+
## Install
|
|
21
|
+
```python
|
|
22
|
+
pip install pytchat
|
|
23
|
+
```
|
|
24
|
+
## Examples
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Fetch chat data (see [wiki](https://github.com/taizan-hokuto/pytchat/wiki/PytchatCore))
|
|
28
|
+
```python
|
|
29
|
+
import pytchat
|
|
30
|
+
chat = pytchat.create(video_id="uIx8l2xlYVY")
|
|
31
|
+
while chat.is_alive():
|
|
32
|
+
for c in chat.get().sync_items():
|
|
33
|
+
print(f"{c.datetime} [{c.author.name}]- {c.message}")
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
### Output JSON format string (feature of [DefaultProcessor](https://github.com/taizan-hokuto/pytchat/wiki/DefaultProcessor))
|
|
38
|
+
```python
|
|
39
|
+
import pytchat
|
|
40
|
+
import time
|
|
41
|
+
|
|
42
|
+
chat = pytchat.create(video_id="uIx8l2xlYVY")
|
|
43
|
+
while chat.is_alive():
|
|
44
|
+
print(chat.get().json())
|
|
45
|
+
time.sleep(5)
|
|
46
|
+
'''
|
|
47
|
+
# Each chat item can also be output in JSON format.
|
|
48
|
+
for c in chat.get().items:
|
|
49
|
+
print(c.json())
|
|
50
|
+
'''
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
### other
|
|
55
|
+
+ Fetch chat with a buffer ([LiveChat](https://github.com/taizan-hokuto/pytchat/wiki/LiveChat))
|
|
56
|
+
|
|
57
|
+
+ Use with asyncio ([LiveChatAsync](https://github.com/taizan-hokuto/pytchat/wiki/LiveChatAsync))
|
|
58
|
+
|
|
59
|
+
+ YT API compatible chat processor ([CompatibleProcessor](https://github.com/taizan-hokuto/pytchat/wiki/CompatibleProcessor))
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
## Structure of Default Processor
|
|
63
|
+
Each item can be got with `sync_items()` function.
|
|
64
|
+
<table>
|
|
65
|
+
<tr>
|
|
66
|
+
<th>name</th>
|
|
67
|
+
<th>type</th>
|
|
68
|
+
<th>remarks</th>
|
|
69
|
+
</tr>
|
|
70
|
+
<tr>
|
|
71
|
+
<td>type</td>
|
|
72
|
+
<td>str</td>
|
|
73
|
+
<td>"superChat","textMessage","superSticker","newSponsor"</td>
|
|
74
|
+
</tr>
|
|
75
|
+
<tr>
|
|
76
|
+
<td>id</td>
|
|
77
|
+
<td>str</td>
|
|
78
|
+
<td></td>
|
|
79
|
+
</tr>
|
|
80
|
+
<tr>
|
|
81
|
+
<td>message</td>
|
|
82
|
+
<td>str</td>
|
|
83
|
+
<td>emojis are represented by ":(shortcut text):"</td>
|
|
84
|
+
</tr>
|
|
85
|
+
<tr>
|
|
86
|
+
<td>messageEx</td>
|
|
87
|
+
<td>str</td>
|
|
88
|
+
<td>list of message texts and emoji dicts(id, txt, url).</td>
|
|
89
|
+
</tr>
|
|
90
|
+
<tr>
|
|
91
|
+
<td>timestamp</td>
|
|
92
|
+
<td>int</td>
|
|
93
|
+
<td>unixtime milliseconds</td>
|
|
94
|
+
</tr>
|
|
95
|
+
<tr>
|
|
96
|
+
<td>datetime</td>
|
|
97
|
+
<td>str</td>
|
|
98
|
+
<td>e.g. "2019-10-10 12:34:56"</td>
|
|
99
|
+
</tr>
|
|
100
|
+
<td>elapsedTime</td>
|
|
101
|
+
<td>str</td>
|
|
102
|
+
<td>elapsed time. (e.g. "1:02:27") *Replay Only.</td>
|
|
103
|
+
</tr>
|
|
104
|
+
<tr>
|
|
105
|
+
<td>amountValue</td>
|
|
106
|
+
<td>float</td>
|
|
107
|
+
<td>e.g. 1,234.0</td>
|
|
108
|
+
</tr>
|
|
109
|
+
<tr>
|
|
110
|
+
<td>amountString</td>
|
|
111
|
+
<td>str</td>
|
|
112
|
+
<td>e.g. "$ 1,234"</td>
|
|
113
|
+
</tr>
|
|
114
|
+
<tr>
|
|
115
|
+
<td>currency</td>
|
|
116
|
+
<td>str</td>
|
|
117
|
+
<td><a href="https://en.wikipedia.org/wiki/ISO_4217">ISO 4217 currency codes</a> (e.g. "USD")</td>
|
|
118
|
+
</tr>
|
|
119
|
+
<tr>
|
|
120
|
+
<td>bgColor</td>
|
|
121
|
+
<td>int</td>
|
|
122
|
+
<td>RGB Int</td>
|
|
123
|
+
</tr>
|
|
124
|
+
<tr>
|
|
125
|
+
<td>author</td>
|
|
126
|
+
<td>object</td>
|
|
127
|
+
<td>see below</td>
|
|
128
|
+
</tr>
|
|
129
|
+
</table>
|
|
130
|
+
|
|
131
|
+
Structure of author object.
|
|
132
|
+
<table>
|
|
133
|
+
<tr>
|
|
134
|
+
<th>name</th>
|
|
135
|
+
<th>type</th>
|
|
136
|
+
<th>remarks</th>
|
|
137
|
+
</tr>
|
|
138
|
+
<tr>
|
|
139
|
+
<td>name</td>
|
|
140
|
+
<td>str</td>
|
|
141
|
+
<td></td>
|
|
142
|
+
</tr>
|
|
143
|
+
<tr>
|
|
144
|
+
<td>channelId</td>
|
|
145
|
+
<td>str</td>
|
|
146
|
+
<td>*chatter's channel ID.</td>
|
|
147
|
+
</tr>
|
|
148
|
+
<tr>
|
|
149
|
+
<td>channelUrl</td>
|
|
150
|
+
<td>str</td>
|
|
151
|
+
<td></td>
|
|
152
|
+
</tr>
|
|
153
|
+
<tr>
|
|
154
|
+
<td>imageUrl</td>
|
|
155
|
+
<td>str</td>
|
|
156
|
+
<td></td>
|
|
157
|
+
</tr>
|
|
158
|
+
<tr>
|
|
159
|
+
<td>badgeUrl</td>
|
|
160
|
+
<td>str</td>
|
|
161
|
+
<td></td>
|
|
162
|
+
</tr>
|
|
163
|
+
<tr>
|
|
164
|
+
<td>isVerified</td>
|
|
165
|
+
<td>bool</td>
|
|
166
|
+
<td></td>
|
|
167
|
+
</tr>
|
|
168
|
+
<tr>
|
|
169
|
+
<td>isChatOwner</td>
|
|
170
|
+
<td>bool</td>
|
|
171
|
+
<td></td>
|
|
172
|
+
</tr>
|
|
173
|
+
<tr>
|
|
174
|
+
<td>isChatSponsor</td>
|
|
175
|
+
<td>bool</td>
|
|
176
|
+
<td></td>
|
|
177
|
+
</tr>
|
|
178
|
+
<tr>
|
|
179
|
+
<td>isChatModerator</td>
|
|
180
|
+
<td>bool</td>
|
|
181
|
+
<td></td>
|
|
182
|
+
</tr>
|
|
183
|
+
</table>
|
|
184
|
+
|
|
185
|
+
## Licence
|
|
186
|
+
|
|
187
|
+
[](LICENSE)
|
|
188
|
+
|
|
189
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=64", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "pytchat-ng"
|
|
7
|
+
version = "0.5.6"
|
|
8
|
+
description = "a python library for fetching youtube live chat. (next generation)"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
requires-python = ">=3.7"
|
|
13
|
+
authors = [
|
|
14
|
+
{name = "revertical", email = "screenkidgreen7@gmail.com"},
|
|
15
|
+
]
|
|
16
|
+
keywords = ["youtube", "livechat", "asyncio"]
|
|
17
|
+
classifiers = [
|
|
18
|
+
"Development Status :: 4 - Beta",
|
|
19
|
+
"Programming Language :: Python",
|
|
20
|
+
"Programming Language :: Python :: 3.7",
|
|
21
|
+
"Programming Language :: Python :: 3.8",
|
|
22
|
+
"Programming Language :: Python :: 3.9",
|
|
23
|
+
]
|
|
24
|
+
dependencies = [
|
|
25
|
+
"httpx[http2]",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
[project.optional-dependencies]
|
|
29
|
+
test = [
|
|
30
|
+
"pytest-mock",
|
|
31
|
+
"pytest-httpx",
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
[project.urls]
|
|
35
|
+
Homepage = "https://github.com/revertical/pytchat-ng"
|
|
36
|
+
|
|
37
|
+
[tool.setuptools.packages.find]
|
|
38
|
+
exclude = ["tests*", "testrun*"]
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"""
|
|
2
|
+
pytchat is a lightweight python library to browse youtube livechat without Selenium or BeautifulSoup.
|
|
3
|
+
"""
|
|
4
|
+
__copyright__ = 'Copyright (C) 2019, 2020, 2021 revertical'
|
|
5
|
+
__license__ = 'MIT'
|
|
6
|
+
__author__ = 'revertical'
|
|
7
|
+
__author_email__ = 'screenkidgreen7@gmail.com'
|
|
8
|
+
__url__ = 'https://github.com/revertical/pytchat-ng'
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
from .exceptions import (
|
|
12
|
+
ChatParseException,
|
|
13
|
+
ResponseContextError,
|
|
14
|
+
NoContents,
|
|
15
|
+
NoContinuation,
|
|
16
|
+
IllegalFunctionCall,
|
|
17
|
+
InvalidVideoIdException,
|
|
18
|
+
UnknownConnectionError,
|
|
19
|
+
RetryExceedMaxCount,
|
|
20
|
+
ChatDataFinished,
|
|
21
|
+
ReceivedUnknownContinuation,
|
|
22
|
+
FailedExtractContinuation,
|
|
23
|
+
VideoInfoParseError,
|
|
24
|
+
PatternUnmatchError
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
from .api import (
|
|
28
|
+
config,
|
|
29
|
+
LiveChat,
|
|
30
|
+
LiveChatAsync,
|
|
31
|
+
ChatProcessor,
|
|
32
|
+
CompatibleProcessor,
|
|
33
|
+
DummyProcessor,
|
|
34
|
+
DefaultProcessor,
|
|
35
|
+
HTMLArchiver,
|
|
36
|
+
TSVArchiver,
|
|
37
|
+
JsonfileArchiver,
|
|
38
|
+
SimpleDisplayProcessor,
|
|
39
|
+
SpeedCalculator,
|
|
40
|
+
SuperchatCalculator,
|
|
41
|
+
create
|
|
42
|
+
)
|
|
43
|
+
# flake8: noqa
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
from . import config
|
|
2
|
+
from .core import create
|
|
3
|
+
from .core_multithread.livechat import LiveChat
|
|
4
|
+
from .core_async.livechat import LiveChatAsync
|
|
5
|
+
from .processors.chat_processor import ChatProcessor
|
|
6
|
+
from .processors.compatible.processor import CompatibleProcessor
|
|
7
|
+
from .processors.default.processor import DefaultProcessor
|
|
8
|
+
from .processors.dummy_processor import DummyProcessor
|
|
9
|
+
from .processors.html_archiver import HTMLArchiver
|
|
10
|
+
from .processors.tsv_archiver import TSVArchiver
|
|
11
|
+
from .processors.jsonfile_archiver import JsonfileArchiver
|
|
12
|
+
from .processors.simple_display_processor import SimpleDisplayProcessor
|
|
13
|
+
from .processors.speed.calculator import SpeedCalculator
|
|
14
|
+
from .processors.superchat.calculator import SuperchatCalculator
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
__all__ = [
|
|
18
|
+
config,
|
|
19
|
+
LiveChat,
|
|
20
|
+
LiveChatAsync,
|
|
21
|
+
ChatProcessor,
|
|
22
|
+
CompatibleProcessor,
|
|
23
|
+
DummyProcessor,
|
|
24
|
+
DefaultProcessor,
|
|
25
|
+
HTMLArchiver,
|
|
26
|
+
TSVArchiver,
|
|
27
|
+
JsonfileArchiver,
|
|
28
|
+
SimpleDisplayProcessor,
|
|
29
|
+
SpeedCalculator,
|
|
30
|
+
SuperchatCalculator,
|
|
31
|
+
create
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
# flake8: noqa
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import logging # noqa
|
|
2
|
+
from . import mylogger
|
|
3
|
+
from base64 import a85decode as dc
|
|
4
|
+
headers = {
|
|
5
|
+
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36 Edg/86.0.622.63,gzip(gfe)',
|
|
6
|
+
}
|
|
7
|
+
m_headers = {
|
|
8
|
+
'user-agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Mobile Safari/537.36 Edg/91.0.864.59',
|
|
9
|
+
}
|
|
10
|
+
_sml = dc(b"BQS?8F#ks-GB\\6`H#IhIF^eo7@rH3;H#IhIF^eor06T''Ch\\'(?XmbXF>%9<FC/iuG%G#jBOQ!ICLqcS5tQB2;gCZ)?UdXC;f$GR3)MM2<(0>O7mh!,G@+K5?SO9T@okV").decode()
|
|
11
|
+
_smr = dc(b"BQS?8F#ks-GB\\6`H#IhIF^eo7@rH3;H#IhIF^eor06T''Ch\\'(?XmbXF>%9<FC/iuG%G#jBOQ!iEb03+@<k(QAU-F)8U=fDGsP557S5F7CiNH7;)D3N77^*B6YU@\\?WfBr0emZX=#^").decode()
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def logger(module_name: str, loglevel=None):
|
|
15
|
+
module_logger = mylogger.get_logger(module_name, loglevel=loglevel)
|
|
16
|
+
return module_logger
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from logging import NullHandler, getLogger, StreamHandler, FileHandler
|
|
2
|
+
import logging
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def get_logger(modname, loglevel=logging.DEBUG):
|
|
7
|
+
logger = getLogger(modname)
|
|
8
|
+
if loglevel is None:
|
|
9
|
+
logger.addHandler(NullHandler())
|
|
10
|
+
return logger
|
|
11
|
+
logger.setLevel(loglevel)
|
|
12
|
+
# create handler1 for showing info
|
|
13
|
+
handler1 = StreamHandler()
|
|
14
|
+
my_formatter = MyFormatter()
|
|
15
|
+
handler1.setFormatter(my_formatter)
|
|
16
|
+
|
|
17
|
+
handler1.setLevel(loglevel)
|
|
18
|
+
logger.addHandler(handler1)
|
|
19
|
+
# create handler2 for recording log file
|
|
20
|
+
if loglevel <= logging.DEBUG:
|
|
21
|
+
handler2 = FileHandler(filename="log.txt", encoding='utf-8')
|
|
22
|
+
handler2.setLevel(logging.ERROR)
|
|
23
|
+
handler2.setFormatter(my_formatter)
|
|
24
|
+
|
|
25
|
+
logger.addHandler(handler2)
|
|
26
|
+
return logger
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class MyFormatter(logging.Formatter):
|
|
30
|
+
def format(self, record):
|
|
31
|
+
timestamp = (
|
|
32
|
+
datetime.fromtimestamp(record.created)).strftime("%m-%d %H:%M:%S")
|
|
33
|
+
module = (record.module).ljust(15)
|
|
34
|
+
funcname = (record.funcName).ljust(18)
|
|
35
|
+
lineno = str(record.lineno).rjust(4)
|
|
36
|
+
message = record.getMessage()
|
|
37
|
+
|
|
38
|
+
return timestamp + '| ' + module + ' { ' + funcname + ':' + lineno + '} - ' + message
|