thememasterchat 0.1.0.1__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.
Files changed (75) hide show
  1. thememasterchat-0.1.0.1/LICENSE +23 -0
  2. thememasterchat-0.1.0.1/PKG-INFO +212 -0
  3. thememasterchat-0.1.0.1/README.md +191 -0
  4. thememasterchat-0.1.0.1/pyproject.toml +37 -0
  5. thememasterchat-0.1.0.1/pytchat/__init__.py +44 -0
  6. thememasterchat-0.1.0.1/pytchat/api.py +34 -0
  7. thememasterchat-0.1.0.1/pytchat/config/__init__.py +16 -0
  8. thememasterchat-0.1.0.1/pytchat/config/mylogger.py +38 -0
  9. thememasterchat-0.1.0.1/pytchat/core/__init__.py +7 -0
  10. thememasterchat-0.1.0.1/pytchat/core/pytchat.py +229 -0
  11. thememasterchat-0.1.0.1/pytchat/core_async/__init__.py +0 -0
  12. thememasterchat-0.1.0.1/pytchat/core_async/buffer.py +38 -0
  13. thememasterchat-0.1.0.1/pytchat/core_async/livechat.py +374 -0
  14. thememasterchat-0.1.0.1/pytchat/core_multithread/__init__.py +0 -0
  15. thememasterchat-0.1.0.1/pytchat/core_multithread/buffer.py +38 -0
  16. thememasterchat-0.1.0.1/pytchat/core_multithread/livechat.py +358 -0
  17. thememasterchat-0.1.0.1/pytchat/exceptions.py +81 -0
  18. thememasterchat-0.1.0.1/pytchat/paramgen/__init__.py +0 -0
  19. thememasterchat-0.1.0.1/pytchat/paramgen/arcparam.py +44 -0
  20. thememasterchat-0.1.0.1/pytchat/paramgen/enc.py +24 -0
  21. thememasterchat-0.1.0.1/pytchat/paramgen/liveparam.py +70 -0
  22. thememasterchat-0.1.0.1/pytchat/parser/__init__.py +0 -0
  23. thememasterchat-0.1.0.1/pytchat/parser/live.py +122 -0
  24. thememasterchat-0.1.0.1/pytchat/processors/__init__.py +0 -0
  25. thememasterchat-0.1.0.1/pytchat/processors/chat_processor.py +30 -0
  26. thememasterchat-0.1.0.1/pytchat/processors/combinator.py +42 -0
  27. thememasterchat-0.1.0.1/pytchat/processors/compatible/__init__.py +0 -0
  28. thememasterchat-0.1.0.1/pytchat/processors/compatible/processor.py +88 -0
  29. thememasterchat-0.1.0.1/pytchat/processors/compatible/renderer/__init__.py +0 -0
  30. thememasterchat-0.1.0.1/pytchat/processors/compatible/renderer/base.py +82 -0
  31. thememasterchat-0.1.0.1/pytchat/processors/compatible/renderer/currency.py +38 -0
  32. thememasterchat-0.1.0.1/pytchat/processors/compatible/renderer/legacypaid.py +42 -0
  33. thememasterchat-0.1.0.1/pytchat/processors/compatible/renderer/membership.py +40 -0
  34. thememasterchat-0.1.0.1/pytchat/processors/compatible/renderer/paidmessage.py +42 -0
  35. thememasterchat-0.1.0.1/pytchat/processors/compatible/renderer/paidsticker.py +47 -0
  36. thememasterchat-0.1.0.1/pytchat/processors/compatible/renderer/textmessage.py +6 -0
  37. thememasterchat-0.1.0.1/pytchat/processors/default/__init__.py +0 -0
  38. thememasterchat-0.1.0.1/pytchat/processors/default/custom_encoder.py +11 -0
  39. thememasterchat-0.1.0.1/pytchat/processors/default/processor.py +181 -0
  40. thememasterchat-0.1.0.1/pytchat/processors/default/renderer/__init__.py +0 -0
  41. thememasterchat-0.1.0.1/pytchat/processors/default/renderer/base.py +101 -0
  42. thememasterchat-0.1.0.1/pytchat/processors/default/renderer/currency.py +38 -0
  43. thememasterchat-0.1.0.1/pytchat/processors/default/renderer/donation.py +6 -0
  44. thememasterchat-0.1.0.1/pytchat/processors/default/renderer/legacypaid.py +15 -0
  45. thememasterchat-0.1.0.1/pytchat/processors/default/renderer/membership.py +18 -0
  46. thememasterchat-0.1.0.1/pytchat/processors/default/renderer/paidmessage.py +47 -0
  47. thememasterchat-0.1.0.1/pytchat/processors/default/renderer/paidsticker.py +47 -0
  48. thememasterchat-0.1.0.1/pytchat/processors/default/renderer/textmessage.py +6 -0
  49. thememasterchat-0.1.0.1/pytchat/processors/dummy_processor.py +10 -0
  50. thememasterchat-0.1.0.1/pytchat/processors/html_archiver.py +170 -0
  51. thememasterchat-0.1.0.1/pytchat/processors/jsonfile_archiver.py +69 -0
  52. thememasterchat-0.1.0.1/pytchat/processors/simple_display_processor.py +61 -0
  53. thememasterchat-0.1.0.1/pytchat/processors/speed/__init__.py +0 -0
  54. thememasterchat-0.1.0.1/pytchat/processors/speed/calculator.py +186 -0
  55. thememasterchat-0.1.0.1/pytchat/processors/superchat/__init__.py +0 -0
  56. thememasterchat-0.1.0.1/pytchat/processors/superchat/calculator.py +75 -0
  57. thememasterchat-0.1.0.1/pytchat/processors/tsv_archiver.py +67 -0
  58. thememasterchat-0.1.0.1/pytchat/util/__init__.py +195 -0
  59. thememasterchat-0.1.0.1/setup.cfg +4 -0
  60. thememasterchat-0.1.0.1/tests/test_calculator_parse.py +71 -0
  61. thememasterchat-0.1.0.1/tests/test_channelid_and_nocontents.py +86 -0
  62. thememasterchat-0.1.0.1/tests/test_compatible_processor.py +180 -0
  63. thememasterchat-0.1.0.1/tests/test_compatible_processor2.py +33 -0
  64. thememasterchat-0.1.0.1/tests/test_default_processor.py +227 -0
  65. thememasterchat-0.1.0.1/tests/test_default_processor2.py +108 -0
  66. thememasterchat-0.1.0.1/tests/test_extract_video_id.py +55 -0
  67. thememasterchat-0.1.0.1/tests/test_jsonfile_archiver.py +48 -0
  68. thememasterchat-0.1.0.1/tests/test_parser.py +34 -0
  69. thememasterchat-0.1.0.1/tests/test_speed_calculator.py +64 -0
  70. thememasterchat-0.1.0.1/tests/test_speed_calculator2.py +18 -0
  71. thememasterchat-0.1.0.1/thememasterchat.egg-info/PKG-INFO +212 -0
  72. thememasterchat-0.1.0.1/thememasterchat.egg-info/SOURCES.txt +73 -0
  73. thememasterchat-0.1.0.1/thememasterchat.egg-info/dependency_links.txt +1 -0
  74. thememasterchat-0.1.0.1/thememasterchat.egg-info/requires.txt +5 -0
  75. thememasterchat-0.1.0.1/thememasterchat.egg-info/top_level.txt +2 -0
@@ -0,0 +1,23 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 taizan-hokuto
4
+ Copyright (c) 2020 revertical
5
+ Copyright (c) 2026 Theme Master
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ SOFTWARE.
@@ -0,0 +1,212 @@
1
+ Metadata-Version: 2.4
2
+ Name: thememasterchat
3
+ Version: 0.1.0.1
4
+ Summary: a python library for fetching youtube live chat (fork of pytchat-ng, imports as pytchat).
5
+ Author: Theme Master
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/ThemeMasterOS/ThemeMasterChat
8
+ Keywords: youtube,livechat,asyncio
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Programming Language :: Python
11
+ Classifier: Programming Language :: Python :: 3.8
12
+ Classifier: Programming Language :: Python :: 3.9
13
+ Requires-Python: >=3.8
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: httpx[http2]
17
+ Provides-Extra: test
18
+ Requires-Dist: pytest-mock; extra == "test"
19
+ Requires-Dist: pytest-httpx; extra == "test"
20
+ Dynamic: license-file
21
+
22
+ # ThemeMasterChat
23
+
24
+ ThemeMasterChat is a python library for fetching youtube live chat.
25
+
26
+ > Forked from [pytchat-ng](https://github.com/revertical/pytchat-ng) (revertical), itself forked from [pytchat](https://github.com/taizan-hokuto/pytchat) (taizan-hokuto). Import name stays `pytchat`.
27
+ > Uninstall `pytchat` / `pytchat-ng` first: `pip uninstall pytchat pytchat-ng`
28
+
29
+
30
+ <br><br><br>
31
+ ## Description
32
+ pytchat is a python library for fetching youtube live chat
33
+ without using Selenium or BeautifulSoup.
34
+
35
+ Other features:
36
+ + Customizable [chat data processors](https://github.com/taizan-hokuto/pytchat/wiki/ChatProcessor) including youtube api compatible one.
37
+ + Available on asyncio context.
38
+ + Quick fetching of initial chat data by generating continuation params
39
+ instead of web scraping.
40
+
41
+ For more detailed information, see [wiki](https://github.com/taizan-hokuto/pytchat/wiki). <br>
42
+
43
+ ## Install
44
+ ```python
45
+ pip install thememasterchat
46
+ ```
47
+ ## Examples
48
+
49
+
50
+ ### Fetch chat data (see [wiki](https://github.com/taizan-hokuto/pytchat/wiki/PytchatCore))
51
+ ```python
52
+ import pytchat
53
+ chat = pytchat.create(video_id="uIx8l2xlYVY")
54
+ while chat.is_alive():
55
+ for c in chat.get().sync_items():
56
+ print(f"{c.datetime} [{c.author.name}]- {c.message}")
57
+ ```
58
+
59
+
60
+ ### Output JSON format string (feature of [DefaultProcessor](https://github.com/taizan-hokuto/pytchat/wiki/DefaultProcessor))
61
+ ```python
62
+ import pytchat
63
+ import time
64
+
65
+ chat = pytchat.create(video_id="uIx8l2xlYVY")
66
+ while chat.is_alive():
67
+ print(chat.get().json())
68
+ time.sleep(5)
69
+ '''
70
+ # Each chat item can also be output in JSON format.
71
+ for c in chat.get().items:
72
+ print(c.json())
73
+ '''
74
+ ```
75
+
76
+
77
+ ### other
78
+ + Fetch chat with a buffer ([LiveChat](https://github.com/taizan-hokuto/pytchat/wiki/LiveChat))
79
+
80
+ + Use with asyncio ([LiveChatAsync](https://github.com/taizan-hokuto/pytchat/wiki/LiveChatAsync))
81
+
82
+ + YT API compatible chat processor ([CompatibleProcessor](https://github.com/taizan-hokuto/pytchat/wiki/CompatibleProcessor))
83
+
84
+
85
+ ## Structure of Default Processor
86
+ Each item can be got with `sync_items()` function.
87
+ <table>
88
+ <tr>
89
+ <th>name</th>
90
+ <th>type</th>
91
+ <th>remarks</th>
92
+ </tr>
93
+ <tr>
94
+ <td>type</td>
95
+ <td>str</td>
96
+ <td>"superChat","textMessage","superSticker","newSponsor"</td>
97
+ </tr>
98
+ <tr>
99
+ <td>id</td>
100
+ <td>str</td>
101
+ <td></td>
102
+ </tr>
103
+ <tr>
104
+ <td>message</td>
105
+ <td>str</td>
106
+ <td>emojis are represented by ":(shortcut text):"</td>
107
+ </tr>
108
+ <tr>
109
+ <td>messageEx</td>
110
+ <td>str</td>
111
+ <td>list of message texts and emoji dicts(id, txt, url).</td>
112
+ </tr>
113
+ <tr>
114
+ <td>timestamp</td>
115
+ <td>int</td>
116
+ <td>unixtime milliseconds</td>
117
+ </tr>
118
+ <tr>
119
+ <td>datetime</td>
120
+ <td>str</td>
121
+ <td>e.g. "2019-10-10 12:34:56"</td>
122
+ </tr>
123
+ <td>elapsedTime</td>
124
+ <td>str</td>
125
+ <td>elapsed time. (e.g. "1:02:27") *Replay Only.</td>
126
+ </tr>
127
+ <tr>
128
+ <td>amountValue</td>
129
+ <td>float</td>
130
+ <td>e.g. 1,234.0</td>
131
+ </tr>
132
+ <tr>
133
+ <td>amountString</td>
134
+ <td>str</td>
135
+ <td>e.g. "$ 1,234"</td>
136
+ </tr>
137
+ <tr>
138
+ <td>currency</td>
139
+ <td>str</td>
140
+ <td><a href="https://en.wikipedia.org/wiki/ISO_4217">ISO 4217 currency codes</a> (e.g. "USD")</td>
141
+ </tr>
142
+ <tr>
143
+ <td>bgColor</td>
144
+ <td>int</td>
145
+ <td>RGB Int</td>
146
+ </tr>
147
+ <tr>
148
+ <td>author</td>
149
+ <td>object</td>
150
+ <td>see below</td>
151
+ </tr>
152
+ </table>
153
+
154
+ Structure of author object.
155
+ <table>
156
+ <tr>
157
+ <th>name</th>
158
+ <th>type</th>
159
+ <th>remarks</th>
160
+ </tr>
161
+ <tr>
162
+ <td>name</td>
163
+ <td>str</td>
164
+ <td></td>
165
+ </tr>
166
+ <tr>
167
+ <td>channelId</td>
168
+ <td>str</td>
169
+ <td>*chatter's channel ID.</td>
170
+ </tr>
171
+ <tr>
172
+ <td>channelUrl</td>
173
+ <td>str</td>
174
+ <td></td>
175
+ </tr>
176
+ <tr>
177
+ <td>imageUrl</td>
178
+ <td>str</td>
179
+ <td></td>
180
+ </tr>
181
+ <tr>
182
+ <td>badgeUrl</td>
183
+ <td>str</td>
184
+ <td></td>
185
+ </tr>
186
+ <tr>
187
+ <td>isVerified</td>
188
+ <td>bool</td>
189
+ <td></td>
190
+ </tr>
191
+ <tr>
192
+ <td>isChatOwner</td>
193
+ <td>bool</td>
194
+ <td></td>
195
+ </tr>
196
+ <tr>
197
+ <td>isChatSponsor</td>
198
+ <td>bool</td>
199
+ <td></td>
200
+ </tr>
201
+ <tr>
202
+ <td>isChatModerator</td>
203
+ <td>bool</td>
204
+ <td></td>
205
+ </tr>
206
+ </table>
207
+
208
+ ## Licence
209
+
210
+ [![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE)
211
+
212
+
@@ -0,0 +1,191 @@
1
+ # ThemeMasterChat
2
+
3
+ ThemeMasterChat is a python library for fetching youtube live chat.
4
+
5
+ > Forked from [pytchat-ng](https://github.com/revertical/pytchat-ng) (revertical), itself forked from [pytchat](https://github.com/taizan-hokuto/pytchat) (taizan-hokuto). Import name stays `pytchat`.
6
+ > Uninstall `pytchat` / `pytchat-ng` first: `pip uninstall pytchat pytchat-ng`
7
+
8
+
9
+ <br><br><br>
10
+ ## Description
11
+ pytchat is a python library for fetching youtube live chat
12
+ without using Selenium or BeautifulSoup.
13
+
14
+ Other features:
15
+ + Customizable [chat data processors](https://github.com/taizan-hokuto/pytchat/wiki/ChatProcessor) including youtube api compatible one.
16
+ + Available on asyncio context.
17
+ + Quick fetching of initial chat data by generating continuation params
18
+ instead of web scraping.
19
+
20
+ For more detailed information, see [wiki](https://github.com/taizan-hokuto/pytchat/wiki). <br>
21
+
22
+ ## Install
23
+ ```python
24
+ pip install thememasterchat
25
+ ```
26
+ ## Examples
27
+
28
+
29
+ ### Fetch chat data (see [wiki](https://github.com/taizan-hokuto/pytchat/wiki/PytchatCore))
30
+ ```python
31
+ import pytchat
32
+ chat = pytchat.create(video_id="uIx8l2xlYVY")
33
+ while chat.is_alive():
34
+ for c in chat.get().sync_items():
35
+ print(f"{c.datetime} [{c.author.name}]- {c.message}")
36
+ ```
37
+
38
+
39
+ ### Output JSON format string (feature of [DefaultProcessor](https://github.com/taizan-hokuto/pytchat/wiki/DefaultProcessor))
40
+ ```python
41
+ import pytchat
42
+ import time
43
+
44
+ chat = pytchat.create(video_id="uIx8l2xlYVY")
45
+ while chat.is_alive():
46
+ print(chat.get().json())
47
+ time.sleep(5)
48
+ '''
49
+ # Each chat item can also be output in JSON format.
50
+ for c in chat.get().items:
51
+ print(c.json())
52
+ '''
53
+ ```
54
+
55
+
56
+ ### other
57
+ + Fetch chat with a buffer ([LiveChat](https://github.com/taizan-hokuto/pytchat/wiki/LiveChat))
58
+
59
+ + Use with asyncio ([LiveChatAsync](https://github.com/taizan-hokuto/pytchat/wiki/LiveChatAsync))
60
+
61
+ + YT API compatible chat processor ([CompatibleProcessor](https://github.com/taizan-hokuto/pytchat/wiki/CompatibleProcessor))
62
+
63
+
64
+ ## Structure of Default Processor
65
+ Each item can be got with `sync_items()` function.
66
+ <table>
67
+ <tr>
68
+ <th>name</th>
69
+ <th>type</th>
70
+ <th>remarks</th>
71
+ </tr>
72
+ <tr>
73
+ <td>type</td>
74
+ <td>str</td>
75
+ <td>"superChat","textMessage","superSticker","newSponsor"</td>
76
+ </tr>
77
+ <tr>
78
+ <td>id</td>
79
+ <td>str</td>
80
+ <td></td>
81
+ </tr>
82
+ <tr>
83
+ <td>message</td>
84
+ <td>str</td>
85
+ <td>emojis are represented by ":(shortcut text):"</td>
86
+ </tr>
87
+ <tr>
88
+ <td>messageEx</td>
89
+ <td>str</td>
90
+ <td>list of message texts and emoji dicts(id, txt, url).</td>
91
+ </tr>
92
+ <tr>
93
+ <td>timestamp</td>
94
+ <td>int</td>
95
+ <td>unixtime milliseconds</td>
96
+ </tr>
97
+ <tr>
98
+ <td>datetime</td>
99
+ <td>str</td>
100
+ <td>e.g. "2019-10-10 12:34:56"</td>
101
+ </tr>
102
+ <td>elapsedTime</td>
103
+ <td>str</td>
104
+ <td>elapsed time. (e.g. "1:02:27") *Replay Only.</td>
105
+ </tr>
106
+ <tr>
107
+ <td>amountValue</td>
108
+ <td>float</td>
109
+ <td>e.g. 1,234.0</td>
110
+ </tr>
111
+ <tr>
112
+ <td>amountString</td>
113
+ <td>str</td>
114
+ <td>e.g. "$ 1,234"</td>
115
+ </tr>
116
+ <tr>
117
+ <td>currency</td>
118
+ <td>str</td>
119
+ <td><a href="https://en.wikipedia.org/wiki/ISO_4217">ISO 4217 currency codes</a> (e.g. "USD")</td>
120
+ </tr>
121
+ <tr>
122
+ <td>bgColor</td>
123
+ <td>int</td>
124
+ <td>RGB Int</td>
125
+ </tr>
126
+ <tr>
127
+ <td>author</td>
128
+ <td>object</td>
129
+ <td>see below</td>
130
+ </tr>
131
+ </table>
132
+
133
+ Structure of author object.
134
+ <table>
135
+ <tr>
136
+ <th>name</th>
137
+ <th>type</th>
138
+ <th>remarks</th>
139
+ </tr>
140
+ <tr>
141
+ <td>name</td>
142
+ <td>str</td>
143
+ <td></td>
144
+ </tr>
145
+ <tr>
146
+ <td>channelId</td>
147
+ <td>str</td>
148
+ <td>*chatter's channel ID.</td>
149
+ </tr>
150
+ <tr>
151
+ <td>channelUrl</td>
152
+ <td>str</td>
153
+ <td></td>
154
+ </tr>
155
+ <tr>
156
+ <td>imageUrl</td>
157
+ <td>str</td>
158
+ <td></td>
159
+ </tr>
160
+ <tr>
161
+ <td>badgeUrl</td>
162
+ <td>str</td>
163
+ <td></td>
164
+ </tr>
165
+ <tr>
166
+ <td>isVerified</td>
167
+ <td>bool</td>
168
+ <td></td>
169
+ </tr>
170
+ <tr>
171
+ <td>isChatOwner</td>
172
+ <td>bool</td>
173
+ <td></td>
174
+ </tr>
175
+ <tr>
176
+ <td>isChatSponsor</td>
177
+ <td>bool</td>
178
+ <td></td>
179
+ </tr>
180
+ <tr>
181
+ <td>isChatModerator</td>
182
+ <td>bool</td>
183
+ <td></td>
184
+ </tr>
185
+ </table>
186
+
187
+ ## Licence
188
+
189
+ [![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE)
190
+
191
+
@@ -0,0 +1,37 @@
1
+ [build-system]
2
+ requires = ["setuptools>=64", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "thememasterchat"
7
+ version = "0.1.0.1"
8
+ description = "a python library for fetching youtube live chat (fork of pytchat-ng, imports as pytchat)."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.8"
13
+ authors = [
14
+ {name = "Theme Master"},
15
+ ]
16
+ keywords = ["youtube", "livechat", "asyncio"]
17
+ classifiers = [
18
+ "Development Status :: 4 - Beta",
19
+ "Programming Language :: Python",
20
+ "Programming Language :: Python :: 3.8",
21
+ "Programming Language :: Python :: 3.9",
22
+ ]
23
+ dependencies = [
24
+ "httpx[http2]",
25
+ ]
26
+
27
+ [project.optional-dependencies]
28
+ test = [
29
+ "pytest-mock",
30
+ "pytest-httpx",
31
+ ]
32
+
33
+ [project.urls]
34
+ Homepage = "https://github.com/ThemeMasterOS/ThemeMasterChat"
35
+
36
+ [tool.setuptools.packages.find]
37
+ exclude = ["tests*", "testrun*"]
@@ -0,0 +1,44 @@
1
+ """
2
+ pytchat is a lightweight python library to browse youtube livechat without Selenium or BeautifulSoup.
3
+ """
4
+ __copyright__ = 'Copyright (C) 2019, 2020, 2021 taizan-hokuto, revertical, Theme Master'
5
+ __license__ = 'MIT'
6
+ __version__ = '0.1.0.1'
7
+ __author__ = 'Theme Master'
8
+ __url__ = 'https://github.com/ThemeMasterOS/ThemeMasterChat'
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
+
44
+ # 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
@@ -0,0 +1,7 @@
1
+ from .pytchat import PytchatCore
2
+ from .. util import extract_video_id
3
+
4
+
5
+ def create(video_id: str, **kwargs):
6
+ _vid = extract_video_id(video_id)
7
+ return PytchatCore(_vid, **kwargs)