Giter Club home page Giter Club logo

Comments (2)

xenova avatar xenova commented on September 20, 2024

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.

xenova avatar xenova commented on September 20, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.