8000 Add API examples for various social media sites by DJDevon3 · Pull Request #115 · adafruit/Adafruit_CircuitPython_Requests · GitHub
[go: up one dir, main page]

Skip to content

Add API examples for various social media sites #115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Nov 12, 2022
Merged

Add API examples for various social media sites #115

merged 10 commits into from
Nov 12, 2022

Conversation

DJDevon3
Copy link
Contributor

Includes Youtube, Twitter, Github, and Discord examples.

Example script for YouTube API. Includes some error correction and time based requests. Returns basic channel stats. Amount of serial prints configurable with debugger booleans.
Example script for Twitter API. Includes some error correction and time based requests. Returns basic stats. Amount of serial prints configurable with debugger booleans.
Example script for Github API. Includes some error correction and time based requests. Returns basic stats. Amount of serial prints configurable with debugger booleans.
Example script for Adafruit Discord Active Online Members. Includes some error correction and time based requests. Returns basic json data. Amount of serial prints configurable with debugger booleans.
Example script for Discord API. Includes some error correction and time based requests. Returns basic stats. Amount of serial prints configurable with debugger booleans.
reordered json before wifi import
pre-commit with black formatting
@tekktrik tekktrik requested a review from a team October 25, 2022 02:19
sleep_time_conversion = "days"

# https://img.shields.io/discord/327254708534116352.svg
ADA_DISCORD_SVG = "https://img.shields.io/discord/327254708534116352.json"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find! I didn't know there was JSON data available directly. Since it's not using an svg anymore lets change the variable name to ADA_DISCORD_JSON or something that matches the new type instead.

print("Full API GET URL: ", ADA_DISCORD_SVG)
print("===============================")
try:
ada_SVG_response = requests.get(ADA_DISCORD_SVG).json()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one can get rid of svg in the name of the variable as well. it could switch to json, or use 'discord' so that it's not tied to a specific type

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes I originally started naming everything SVG and about halfway through found the JSON file. Forgot to rename everything. Will do. BTW I never did figure out how to work with the SVG directly. Typed in .json at the end of the filename in a fit of hair pulling desperation... and like a miracle it actually worked. Felt like I'd found a hidden cheat code. :P

Updated as recommended by FoamyGuy during his livestream. No more regex needed, using string replace.
@DJDevon3
Copy link
Contributor Author

I have to run black first before every commit? Ugh black you vex me.

@tekktrik
Copy link
Member
tekktrik commented Nov 10, 2022

I have to run black first before every commit? Ugh black you vex me.

It does it automatically if you have pre-commit installed, but you can also not install it and run pre-commit run --all-files right before pushing which is what I do if I'm doing extensive changes where I know pylint or black will complain during incremental commits.

@DJDevon3
Copy link
Contributor Author

hmm thought i'd installed pre-commit, maybe that was on my WSL ubuntu instance. installed again hopefully won't have this issue next time?

It's public info so doesn't need to be in secrets.py
@DJDevon3
Copy link
Contributor Author
DJDevon3 commented Nov 10, 2022

Nice, looks like it passed this time without having to run black manually. Think I've fixed everything requested?

Copy link
Contributor
@FoamyGuy FoamyGuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great new examples, thanks @DJDevon3!

These look good to me. I tested discord, gh, and yt successfully on Feather S2 TFT. I looked over the twitter one, and it looks good to me, but did not run it.

@FoamyGuy FoamyGuy merged commit 640bfac into adafruit:main Nov 12, 2022
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Nov 13, 2022
Updating https://github.com/adafruit/Adafruit_CircuitPython_LED_Animation to 2.6.1 from 2.6.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_LED_Animation#103 from adafruit/optimizations
  > Merge pull request adafruit/Adafruit_CircuitPython_LED_Animation#102 from tekktrik/dev/fix-pylint-errors
  > Update .pylintrc for v2.15.5
  > Fix release CI files
  > Update pylint to 2.15.5
  > Updated pylint version to 2.13.0
  > Switching to composite actions

Updating https://github.com/adafruit/Adafruit_CircuitPython_Requests to 1.12.10 from 1.12.9:
  > Merge pull request adafruit/Adafruit_CircuitPython_Requests#115 from DJDevon3/main
  > Merge pull request adafruit/Adafruit_CircuitPython_Requests#119 from tekktrik/main
  > Update .pylintrc for v2.15.5
  > Fix release CI files
  > Update pylint to 2.15.5
  > Updated pylint version to 2.13.0
  > Switching to composite actions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0