Bitcoin Forum
May 08, 2024, 10:55:15 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
  Home Help Search Login Register More  
  Show Posts
Pages: [1]
1  Other / Beginners & Help / My journey from user, to cyborg, to maybe coding a bot. on: February 05, 2024, 02:24:13 AM
Backstory:  In the Wall Observation Thread there is a great bot, ChartBuddy, coded by Richy_T that posts the bitcoin bid and ask walls from the bitstamp exchange, on an hourly basis.  A few months ago, a WO regular, OgNasty, asked "Has anybody created some sort of animated gif using the latest chart buddy images? It might be funny to use the last 24 images on a rolling basis to give you a feel for how the last day has gone. Or maybe grab 24 images once a day and then be able to show each day’s movement. Seems like something one of you fellas would enjoy creating."

Having previously made animated GIF files from image layers in GIMP, I knew I was up for at least the second request.
Here are the steps I iterated each day at the beginning.

1. Scroll through the day and download each ChartBuddy post.  
2. Drag each downloaded image into GIMP as a new layer
3. Export full size gif to imgur for the clickable link, and export optimized gif for the in-thread talkimg hosted one
4. Put together the post and post
5. Archive images for later use in a monthly replay

Even though it was only taking about 5-10 minutes, after a few days i desired to automate, or at least streamline, some of those steps.  I've done some 'fake' programming in games like, TIS100, SpaceChem, and Human Resource Machine.  Well I do have some experience with BASIC and LOGO from back in the day, but now I wanted to learn a little Python.  The first process I wanted to automate was the downloading of the previous day's ChartBuddy images.  Off to YouTube to do some research!  It turns out to be one of the last things it seems like i'm going to be able to do.  These dang electric winged minions keep bringing back bowls of soup and I want downloads.  More on that later.

The first streamline I learned rather quickly was that I could drag all 24 images in GIMP at once, and they would stay in order.  That was a nice one to find first.  Also helpful how Windows appends numbers to identically named files as you download them.  Then I figured out that if I have a 'dummy' download.png file present, the downloads would be perfectly numbered from 1 to 24.  Sweet.

I'm posting this to possibly provide a chuckle from my mistakes, and maybe even encourage other people to learn how to code.  I've been having some frustration, but it's been a ton of fun along the way. It has to be fun if they make fun games about it, right?   Full disclosure: I have typed snippets of a lot of other people's code, never copy and pasted other's code, and generally done a bunch of problem solving.  Along the way I've started to learn a little about Python.  The little game I've been playing is I get more points for getting the answer by searching from Brave browser, medium points for going to Google, and then the least points from asking Copilot.  What an amazing resource that Copilot is. Here's my current status mostly chronologically marking my progress. All the while, I keep giving BeautifulSoup another go.  I think the furthest I've gotten on that front is to have it return all the links on a thread page, and I can see ChartBuddy's user id number, but can't figure out how to sift through it with code, yet.  

1.Download  I've discovered Ninjastic Space and how I can get all of ChartBuddy's posts from the last 24 hours on one page, and more easily right click save them.  I made sure it was okay with TryNinja the site operator to do so.  
   Then, knowing that the search parameters were in the ninjastic space website address for the returned results page, i could just make the link myself each day, by editing a few numbers using notepad
Code:
https://ninjastic.space/search?after_date=2024-01-27T07%3A55%3A00&author=ChartBuddy&before_date=2024-01-28T07%3A55%3A00
  See the user, date and time in there?
   My next progress is where I first used python, to make the link for me for that day. An example of a problem that i still need to work on: The ninjastic space website puts zeros in front of single digit days and months in the search result's url which isn't how I'm getting them from datetime in python.  So I've been manually putting the zero in the code when needed.  I know there is a bunch of ways to format the time, but I'm looking to maybe use this problem as an 'if else' learning exercise for now.

5.Archive I learned how to have python make a folder, named after the date, and move all of that days images into it, no more download(25).pngs for me after forgetting to move yesterday's images.  I strung together the link making code and folder making code, and put an input in the middle so it waits for me to make the gifs before archiving the layers.   What a world!

4.Post  Before I knew about ninjastic space, to speed up inputting the actual post, I would go to the first image for that day's gif, in the WO Observation thread, duplicate that tab.  I would use one tab so I could reply to my last gif, delete the quote code, and then just copy in the new urls, after using the other tab to scroll through the day downloading each ChartBuddy post as I went.  I currently use the draft feature to get the post, but now I see how I can have python write the post for me. I wonder if it can put the post directly on the clipboard for me?

At this point, the process takes about 5-10 minutes, but let's keep going

3.Export  This one took awhile, spending a few days on trying to wrap my head around GIMP plugins to save a gif, this one I had to go to Microsoft Copilot and it calmly told me that the plugin text from the GIMP python console was wrong about file_gif_sav2, and it gave me the correct, newer Parameters to use.  Incredible, what a time to be alive!

Next goals:  Auto importing the layers into GIMP, especially for the monthly version, and having python write the post, accepting the links as inputs.  Let me know if you have any questions I might be able to answer.  Smiley

EDIT: added details about search parameters being in the webaddress, grammar, typo, changed a few to 5-10
Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!