Comments (2)
Hi there.
Yes, custom formatting is on the list to-do. In fact, I am busy with it right now in the package
branch.
When you say
there should be option to display message author id along with author name for easier access.
What are you referring to by "easier access"? If you are only using the text which is output the console, you would need to do string manipulation later on in order to extract the author id.
I recommend to use the raw JSON data if you need access to more information. The current implementation has a simple to use python module too (with callback functionality), so you can customize the output to your liking, without needing to do any string manipulation.
from chat-downloader.
Just so I can close the issue, here is an example of how you would use the python module to achieve what you were looking for:
from chat_downloader import ChatDownloader
from chat_downloader.utils import multi_get
url = 'https://www.youtube.com/watch?v=5qap5aO4i9A'
chat = ChatDownloader().get_chat(url) # create a generator
for message in chat: # iterate over messages
author_id = multi_get(message, 'author', 'id') # get author id (None if doesn't exist)
standard_message = chat.format(message) # format message as normal
print(author_id, standard_message) # print the author id along with the message
Another (more advanced) way would be to define a custom formatting json file (e.g. see the json file in
custom_formats.zip ) and use the format arguments
Format Arguments:
--format FORMAT Specify how messages should be formatted for printing, defaults to the site's default value
--format_file FORMAT_FILE
Specify the path of the format file to choose formats from, defaults to None
For example, using this example.json
(in example.zip )
{
"example": {
"template": "{time_text|timestamp}{author.badges}{money.text}{author.display_name|author.name}{author.id}{message}",
"keys": {
"time_text": "{} | ",
"timestamp": {
"template": "{} | ",
"format": "%Y-%m-%d %H:%M:%S"
},
"author.badges": {
"template": "({}) ",
"separator": ", "
},
"money.text": "*{}* ",
"author.id" : " ({})",
"message": ": {}"
}
}
}
and running the following command:
chat_downloader https://www.youtube.com/watch?v=5qap5aO4i9A --format example --format_file example.json
would output as:
2021-06-30 23:31:29 | İmam Reus (UCTt71c985oXN-uf7HR7gAdQ): @Kadir aha verdi
2021-06-30 23:31:30 | العاصي عاصي (UCL6qCSt2XEkjbzvzcUYVUew): وصلت أربعة وثلاثين 😂
2021-06-30 23:31:31 | ALVN (UC0geDakVwLEan81skcXXwRg): منورة
2021-06-30 23:31:32 | Frayqille (UCnDVVmV9WGNIt66h1ZA0FCg): КУРСЕД
2021-06-30 23:31:32 | Gh (UCUVw1iuIhqhsw4WuxXUKSpg): هايات
2021-06-30 23:31:34 | Native ads (UCZhuH-pXyKBmpIRBRPR-aBw): هاي
2021-06-30 23:31:34 | Technogun (UC6GIfAlgYvrO3nD9HFsDLJQ): It’s me ya boo
2021-06-30 23:31:34 | Noelle Green (UCMu2pcjkShgvM8gyBz8t-Ig): did you know that your eyes is looking at your nose?? you just cant see it.
2021-06-30 23:31:34 | Santi Namor (UCThalLQGubqvZef5pXm_X2w): no les entiendo un pingo muchachos, sigan bien
Hope this helps! Let me know if you have any more questions.
from chat-downloader.
Related Issues (20)
- [BUG] On my pc it works but on my friend's it doesn't HOT 5
- how can stop sesion chat?
- [QUESTION] How do I get chat log from start of live youtube broadcast? HOT 3
- REMOVE THIS, THANKS
- Incomplete Parsing of Fundraising Donation Messages in Live Chat HOT 2
- [QUESTION] Title goes here
- ModuleNotFoundError: No module named 'chardet'
- [QUESTION] How can I stop chat downloader if the livestreaming is offline
- [FEATURE] [Twitch] Add `{datetime}` in ouput operation
- [FEATURE] [Youtube] Add filter for stream announce
- [FEATURE] create_clip function
- [BUG] Filename string after --output cannot begin with dash(-) due to mis-interpretated as option HOT 5
- [BUG] socs.value missing from cookies
- CHAT STOPED AFTER ANY TIME HOT 2
- [QUESTION] How to replace shorthand emotes, like :confounded_face:, with UTF, like 😖 ?
- [BUG] YouTube URL parsing error
- [FEATURE] errorlevel 0
- inactivity_timeout HOT 1
- [FEATURE] Kick support
- [QUESTION] Module Hook? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chat-downloader.