github-readme-youtube-cards
github-readme-youtube-cards copied to clipboard
🚀 Feature: JSON output option
The user may want to parse the output manually in a different action step.
An option, for example, output_type: "json" could be useful to allow such customization more easily.
A format such as the following may be useful (all the params, plus the svg card url)
[
{
"id": "...",
"title": "...",
"timestamp": "...",
"background_color": "...",
"title_color": "...",
"stats_color": "...",
"width": "...",
"duration": "...", // if applicable
"image_url": "https://ytcards.demolab.com/?id=...&...",
},
{
...
},
]
This can be coordinated with #24 since both involve adding output_type.
!assign
Hi @HeyAnirudh, any updates on this issue?
hey, @DenverCoder1 wasn't well for a few days and had trouble setting up the project. I did ask people out in discord but no luck yet .
The CONTRIBUTING.md has some info on getting things set up and running assuming you already have Python installed and an editor.
If there are any specific issues you are facing, feel free to ask. The more specific you are with the question, the more likely it is someone can help.
so while creating API credentials ,what shall we use

and also where shall i add the API key and channel id .
You don't need an API key to run the project. It only really affects whether duration is included in the params or not.
Here's some details about YouTube API keys in case it helps though https://github.com/DenverCoder1/github-readme-youtube-cards/wiki/Setting-Up-the-Action-with-a-YouTube-API-Key
To test the action you can run the python part like this
python action.py --channel=UCipSxT7a3rn81vGLw9lqRkg --comment-tag-name="EXAMPLE-YOUTUBE-CARDS"
With api key:
python action.py --channel=UCipSxT7a3rn81vGLw9lqRkg --comment-tag-name="EXAMPLE-YOUTUBE-CARDS" --youtube-api-key="your-key"
You can see the action.yml and action.py for more details on what it can do
stuck with this error

stuck with this error
What version of python are you running?
i.e what does python --version tell you?
It works for me on Python 3.10.8 (it's written to be run with Python 3.10)
Some clarification on the requested issue:
It was mentioned in the issue that a new output_type input would be made, but I'm realizing this doesn't really make much sense since you wouldn't update a readme with that json.
Instead, I think it should be an additional output, i.e. you would have markdown which is already an output, and json as another.
In the action.yml, the way to do that would be something like
echo "::set-output name=json::$(<something that echos the json here>)"
If you were to create a file with the json in the action.py (eg. save it in youtube-cards-output.json), you could set the output with
echo "::set-output name=json::$(cat youtube-cards-output.json)"
Would want to make sure to remove it though, so it doesn't commit, for example, you could do afterwards rm youtube-cards-output.json to delete it.
stuck with this error
What version of python are you running?
i.e what does
python --versiontell you?It works for me on Python 3.10.8 (it's written to be run with Python 3.10)
yeah its 3.10.8 for me
so before it gave an error
in line 146 I have updated r with "rb" which solves it. but after that, it showed the same issue as before.
Try using encoding="utf8" in the open function, that's usually what fixes the "charmap can't decode" issue.
Try to keep it as "r" and not "rb" since it's more useful for it to be a string and not bytes.
Also if you manage to fix the charmap decoding issue, feel free to make a pull request for that. I haven't seen the issue come up before, but it might only occur with certain channels.
Try using
encoding="utf8"in the open function, that's usually what fixes the "charmap can't decode" issue.Try to keep it as "r" and not "rb" since it's more useful for it to be a string and not bytes.
yeah that solved the charmap issue
@DenverCoder1 should I open a pr for that?
Sure, it's good to keep separate issues in separate PRs, so you can feel free to open a PR specifically to change that.