Pages:
Author

Topic: My journey from user, to cyborg, to maybe coding a bot. - page 2. (Read 908 times)

legendary
Activity: 3290
Merit: 16489
Thick-Skinned Gang Leader and Golden Feather 2021
I need to look into what you meant by numerical sort, in terms of possible commands.
In sort, it's this:
Code:
       -n, --numeric-sort
              compare according to string numerical value
If you're going to move your code to Linux anyway, maybe it helps.

Quote
I'm really surprised the datetime module doesn't return double digit hours, days, months, all that stuff.
Isn't that an option you can toggle?
full member
Activity: 114
Merit: 93
Fly free sweet Mango.
Okay.  Nobody told me this bloody machine can't even count.  You tell it to load numbered files in order and it goes, 1, 10, 11-19, 2, 20, 21...  Grin
Lol. Been there, done that Smiley It's not counting, it's sorting. Easy fix: use leading zeros, or numerical sort.
I need to look into what you meant by numerical sort, in terms of possible commands.  But yeah, i guess it alphabetically sorts the list, not numerically.  But when i add the leading zeros it breaks all my plugins.  Smiley  Thus is the way of progress.  I'm really surprised the datetime module doesn't return double digit hours, days, months, all that stuff.
legendary
Activity: 3290
Merit: 16489
Thick-Skinned Gang Leader and Golden Feather 2021
Okay.  Nobody told me this bloody machine can't even count.  You tell it to load numbered files in order and it goes, 1, 10, 11-19, 2, 20, 21...  Grin
Lol. Been there, done that Smiley It's not counting, it's sorting. Easy fix: use leading zeros, or numerical sort.
full member
Activity: 114
Merit: 93
Fly free sweet Mango.
Okay.  Nobody told me this bloody machine can't even count.  You tell it to load numbered files in order and it goes, 1, 10, 11-19, 2, 20, 21...  Grin Luckily I could see something was amiss.
Here's the code i finally squeezed out.  I did have to do a quick Brave search to recall the method of stating a range, and getting the length of a list.  Also some hard coding of dates that need to be fixed.  I figured the easiest way i knew to get all these images into GIMP in the right order would be to number them as they were placed in a single folder.  674 this previous month.  Then my existing GIMP gif making plugin could easily be modified, but I think i actually just ctrl-a, selected them all and then just dragged it into GIMP with the title page already loaded, use the reverse the layers plugin, export, and Bob's your uncle.
Code:
import os, shutil, time
from os import rename

#making a backup
shutil.copytree('C:/Users/Games/CB/CBuddyDaily', 'C:/Users/Games/Backup')

# set dates and variables for folders and files
# today = date.today()
# tomorrow = today + timedelta(1)
destination = "C:/Users/Games/CB/2024/2-2024/Monthly"
hour_number = 1
day_number= 1

# for 29 days this year
for i in range(1, 30):
    file_number = 1
    src = f"C:/Users/Games/CB/CBuddyDaily/2-{day_number:02d}"
    files = os.listdir(src)
    CB_daily_post_total = len(files) + 1
    os.chdir(src)
    time.sleep(1)

    for m in range(1, CB_daily_post_total):
        rename (f'C:/Users/Games/CB/CBuddyDaily/2-{day_number:02d}/download ({m}).png', f"C:/Users/Games/CB/2024/2-2024/Monthly/download ({hour_number}).png")
        print(hour_number, file_number, m)
        hour_number += 1
        file_number += 1
    day_number += 1
    print(day_number)
There might be some good error checking code in there.   If i know how many posts ChartBuddy made that day before starting the whole process, that would be helpful.

Still waiting for that perfect run, but things really went smoothly this run, only because there were exactly 24 images to download.  Gonna work on that.
1.Download Left click
2.Import  Do pushups.  Y'all hear about the 100 pushups a day till 100k btc challenge?  https://bitcointalksearch.org/topic/--5484350
3.Export  
4.Posting  I have it set to skip the Post button and tab one more time to the Preview button, for now.  This time I had to add the monthly recap to the post.
5.Archive  Here, it finally errored out.  On the penultimate command, because I didn't have a new 3-2024 folder to store the gifs in.

2_29CB.py errr 3_1CB.py EDIT: I'm so distressed i couldn't post the monthly, I don't even know what day it is.  Just like my code sometimes.  Cry
Code:
import csv, os, pyautogui, pyperclip, re, requests, shutil, time, urllib.request, webbrowser
from datetime import timedelta, date
from os import rename

startTime = time.perf_counter()

# set dates for links and new folder
today = date.today()
tomorrow = today + timedelta(1)

# name newfolder with date
directory = f"{today.month}-{today.day}"
parent_dir = "C:/Users/Games/CB/images/"
newf = os.path.join(parent_dir, directory)
os.mkdir(newf)

# get the final 20 gif layers in reverse order, starting with 24
number = 24
url4 = 'https://bitcointalk.org/index.php?action=profile;u=110685;sa=showPosts;start=0'
response = requests.get(url4)

# turn response into textfile of the source code.
source_code = response.text

# read the source code, save it, and turn it into a string.  
textfile = open('C:/Users/Games/CBSource.txt', 'a+')
textfile.write(source_code)
textfile.seek(0)
filetext = textfile.read()
textfile.close()

# find matches using regex, and for every match download the image and number it.  resorted to asking copilot for help with my regex
matches = re.findall(r'https:\/\/www\.talkimg\.com\/images\/\w{4}/\w{2}\/\w{2}\/\w{5}\.png', filetext)
for link in matches:
    print(number, link)
    urllib.request.urlretrieve(link, 'C:/Users/Games/CB/images/download ({}).png'.format(number))
    number = number - 1
    time.sleep(5)
os.remove('C:/Users/Games/CBSource.txt')

# get the first 4 images in reverse order, i copied my own code and changed the link.  Should have made a function and then fed it the links probably.
url5 = 'https://bitcointalk.org/index.php?action=profile;u=110685;sa=showPosts;start=20'
response5 = requests.get(url5)
source_code = response5.text
textfile5 = open('C:/Users/Games/CBSource2.txt', 'a+')
textfile5.write(source_code)
textfile5.seek(0)
filetext = textfile5.read()
textfile5.close()

# find matches using regex, and for first 4 matches download the image and number it
matches = re.findall(r'https:\/\/www\.talkimg\.com\/images\/\w{4}/\w{2}\/\w{2}\/\w{5}\.png', filetext)
for link in matches:
    if number >= 1:
        urllib.request.urlretrieve(link, 'C:/Users/Games/CB/images/download ({}).png'.format(number))
        print(number, link)
        number = number - 1
        time.sleep(5)
os.remove('C:/Users/Games/CBSource2.txt')

# hot keys to open gimp and then the plugin that load layers, export, scale, export gifs, quit, agree to not save
time.sleep(5)
pyautogui.click(1, 1)
time.sleep(5)
pyautogui.hotkey('ctrl', 'alt', 'g')
time.sleep(20)
pyautogui.click(820, 446)
time.sleep(20)
pyautogui.hotkey('ctrl', 'alt', 'l')
time.sleep(5)
pyautogui.hotkey('tab')
time.sleep(1)
pyautogui.hotkey('tab')
time.sleep(1)
pyautogui.hotkey('tab')
time.sleep(1)
pyautogui.hotkey('enter')
time.sleep(10)
pyautogui.hotkey('ctrl', 'q')
time.sleep(5)
pyautogui.hotkey('shift', 'tab')
time.sleep(1)
pyautogui.hotkey('enter')
time.sleep(10)

# uploading big gif and getting link to use later,
url = "https://api.imgur.com/3/image"
payload = {'name': f'b{today.month}-{today.day}'}
files=[('image',('C:/Users/Games/gif.gif',open('C:/Users/Games/gif.gif','rb'),'image/gif'))]
headers = {'Authorization': 'Bearer f0e27b94e6f8ead1480763e666c8587b73365850'}
response = requests.request("POST", url, headers=headers, data=payload, files=files)

# looking for the link
imgur_return = response.text
linkfile = open('C:/Users/Games/imgurlink.txt', 'a+')
linkfile.write(imgur_return)
linkfile.seek(0)
filetext = linkfile.read()
linkfile.close()
imgurlink = re.findall(r'https:\/\/i\.imgur\.com\/.*\.gif', filetext)

# and the following only works  i think because it's the only link in the JSON response
for imgur in imgurlink:
    imgur_big_gif = imgur
os.remove('C:/Users/Games/imgurlink.txt')

# open imgtalk to upload gif2
url3 = "https://www.talkimg.com/"
webbrowser.open(url3)
time.sleep(30)
pyautogui.click(953, 590)
time.sleep(5)
pyautogui.click(221, 479)
time.sleep(5)
pyautogui.typewrite("gif2.gif")
time.sleep(5)
pyautogui.hotkey('tab')
time.sleep(1)
pyautogui.hotkey('tab')
time.sleep(10)
pyautogui.hotkey('enter')
time.sleep(5)
pyautogui.click(949, 645)
time.sleep(5)
pyautogui.click(1276, 625)
time.sleep(5)
imgtalklink = pyperclip.paste()

# add post to clipboard for btctalk
pyperclip.copy(f"ChartBuddy's 24 hour Wall Observation recap\n[url={imgur_big_gif}].{imgtalklink}.[/url]\nAll Credit to [url=https://bitcointalk.org/index.php?topic=178336.msg10084622#msg10084622]ChartBuddy[/url]")

# can use this link for the reply button
url7 = 'https://bitcointalk.org/index.php?action=post;topic=178336.0'
webbrowser.open(url7)
time.sleep(10)
pyautogui.hotkey('tab')
time.sleep(5)
pyautogui.hotkey('tab')
time.sleep(5)
pyautogui.hotkey('ctrl', 'v')
time.sleep(5)
pyautogui.hotkey('tab')
time.sleep(5)
# we're doing it live if the next command is #ed out
pyautogui.hotkey('tab')
time.sleep(5)
pyautogui.hotkey('enter')

#runtime is calculated
stopTime = time.perf_counter()
runtime = {stopTime - startTime}

# save to csv file
f = open('C:/PyProjects/runtimes.csv', 'a', newline='')
writer = csv.writer(f)
writer.writerow(runtime)

time.sleep(20)

# prepare to store downloads
src = "C:/Users/Games/CB/images"
dest = "C:/Users/Games/CB/images/{}".format(directory)
files = os.listdir(src)
os.chdir(src)

# only move numbered png files
for file in files:
    if file.endswith(").png"):
        shutil.move(file, dest)  

# big gif is stored
rename ("C:/Users/Games/gif.gif", f"C:/Users/Games/CB/{today.year}/{today.month}-{today.year}/b{today.month}-{today.day}.gif")

# little gif is stored
rename (f"C:/Users/Games/gif2.gif", f"C:/Users/Games/CB/{today.year}/{today.month}-{today.year}/{today.month}-{today.day}.gif")

Next moves: Handling errors, exceptions, and elses.  What a save!

EDIT:  Runtime was 364.1 s of which, 220 s were sleep commands to make sure things weren't happening too fast.  Very nice.
full member
Activity: 114
Merit: 93
Fly free sweet Mango.
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process:
~
I'm going to install linux on a virtual machine, which i do have some very limited experience with, and see how things go there.
Linux will never tell you you can't move or delete a file because it's in use. It just does what you tell it to do. If you would delete a movie while it's playing, it keeps playing until the end anyway.

That would seem to solve that problem, because if i understand how things are happening, GIMP should be done with the file once GIMP is closed, but obviously not.  But here's a crazy thing.  Tonight the upload failed while the file move succeeded.  Huh  I did move the file move command to the very end of the script, but it had previously failed all day in testing with the same changes.   Huh  I need to pay closer attention to the finer details.  Oh.  Yeah.  My attempt at an auto monthly recap, resulted in... not that.  Going to try again tomorrow.  The code for the monthly recap is below, but honestly, of course I might have messed up my own code by backing up empty folders by accident. Whoops.
Whoopsie.
Code:
import os, shutil
from os import rename

#making a backup
shutil.copytree('C:/Users/Games/CB/CBuddyDaily', 'C:/Users/Games/Backup')

# set dates and variables for file numbering
# today = date.today()
# tomorrow = today + timedelta(1)
destination = "C:/Users/Games/CB/2024/2-2024/Monthly"
hour_number = 1
day_number= 1

for i in range(1, 30):
    src = f"C:/Users/Games/CB/CBuddyDaily/02-{day_number:02d}"
    files = os.listdir(src)
    os.chdir(src)
    print(src)
    for file in files:
        rename (file, f"C:/Users/Games/CB/2024/2-2024/Monthly/download ({hour_number}).png")
        hour_number += 1
        print(hour_number)
        print(day_number)
    day_number += 1
    print(day_number)

def play_game(Rocket_League)
legendary
Activity: 3290
Merit: 16489
Thick-Skinned Gang Leader and Golden Feather 2021
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process:
~
I'm going to install linux on a virtual machine, which i do have some very limited experience with, and see how things go there.
Linux will never tell you you can't move or delete a file because it's in use. It just does what you tell it to do. If you would delete a movie while it's playing, it keeps playing until the end anyway.
full member
Activity: 114
Merit: 93
Fly free sweet Mango.
Last time was another head scratcher.  I figured out the hard parts, downloading the images, making the gifs, composing and posting the post, but now one of the first things I was doing, moving files around, kept erroring out.

PermissionError: [WinError 32] The process cannot access the file because it is being used by another process:

I commented out all of the downloading below because that part of the code worked the first time, and all the file transfer parts that stopped working.  Just in time for the end of the month recap.  Brilliant.   Grin  That's what i'm having fun with now, I'm going try and figure it out just looking at snippets I've grabbed, and then I'm going to see what copilot says, without providing any of my code, only telling it what I want the script to do.  Oh, and it is probably my mistake somehow, but the copilot solution to pulling the link out of the API using JSON didn't work.  I think I imported everything required, json, and api from requests?  Can't fool around with that now, I'm sticking to what works.

Code:
import csv, os, pyautogui, pyperclip, re, requests, shutil, time, urllib.request, webbrowser
from datetime import timedelta, date
from os import rename

startTime = time.perf_counter()

# set dates for links and new folder
today = date.today()
tomorrow = today + timedelta(1)

# # get the final 20 gif layers in reverse order, starting with 24
# number = 24
# url4 = 'https://bitcointalk.org/index.php?action=profile;u=110685;sa=showPosts;start=0'
# response = requests.get(url4)

# # turn response into textfile of the source code.
# source_code = response.text

# # read the source code, save it, and turn it into a string.  
# textfile = open('C:/Users/Games/CBSource.txt', 'a+')
# textfile.write(source_code)
# textfile.seek(0)
# filetext = textfile.read()
# textfile.close()

# # find matches using regex, and for every match download the image and number it.  resorted to asking copilot for help with my regex
# matches = re.findall(r'https:\/\/www\.talkimg\.com\/images\/\w{4}/\w{2}\/\w{2}\/\w{5}\.png', filetext)
# for link in matches:
#     print(number, link)
#     urllib.request.urlretrieve(link, 'C:/Users/Games/CB/images/download ({}).png'.format(number))
#     number = number - 1
#     time.sleep(5)
# os.remove('C:/Users/Games/CBSource.txt')

# # get the first 4 images in reverse order, i copied my own code and changed the link.  Should have made a function and then fed it the links probably.
# url5 = 'https://bitcointalk.org/index.php?action=profile;u=110685;sa=showPosts;start=20'
# response5 = requests.get(url5)
# source_code = response5.text
# textfile5 = open('C:/Users/Games/CBSource2.txt', 'a+')
# textfile5.write(source_code)
# textfile5.seek(0)
# filetext = textfile5.read()
# textfile5.close()

# # find matches using regex, and for first 4 matches download the image and number it
# matches = re.findall(r'https:\/\/www\.talkimg\.com\/images\/\w{4}/\w{2}\/\w{2}\/\w{5}\.png', filetext)
# for link in matches:
#     if number >= 1:
#         urllib.request.urlretrieve(link, 'C:/Users/Games/CB/images/download ({}).png'.format(number))
#         print(number, link)
#         number = number - 1
#         time.sleep(5)
# os.remove('C:/Users/Games/CBSource2.txt')

# name newfolder with date
directory = f"{today.month}-{today.day}"
parent_dir = "C:/Users/Games/CB/images/"
newf = os.path.join(parent_dir, directory)
os.mkdir(newf)

# command for show desktop, and clicking an empty region on the proper monitor
time.sleep(5)
pyautogui.hotkey('win', 'd')
time.sleep(5)
pyautogui.click(1, 1)
time.sleep(5)

# hot keys to open gimp and then the plugin that load layers, export, scale, export gifs, quit, agree to not save
pyautogui.hotkey('ctrl', 'alt', 'g')
time.sleep(10)
pyautogui.click(820, 446)
time.sleep(5)
pyautogui.hotkey('ctrl', 'alt', 'l')
time.sleep(5)
pyautogui.hotkey('tab')
time.sleep(1)
pyautogui.hotkey('tab')
time.sleep(1)
pyautogui.hotkey('tab')
time.sleep(1)
pyautogui.hotkey('enter')
time.sleep(10)
pyautogui.hotkey('ctrl', 'q')
time.sleep(5)
pyautogui.hotkey('shift', 'tab')
time.sleep(1)
pyautogui.hotkey('enter')
time.sleep(5)
print('gif done')

# uploading big gif and getting link to use later,
url = "https://api.imgur.com/3/image"
payload = {'name': f'b{today.month}-{today.day}'}
files=[('image',('C:/Users/Games/Postman/files/gif.gif',open('C:/Users/Games/Postman/files/gif.gif','rb'),'image/gif'))]
headers = {'Authorization': 'Bearer f0e27b94e6f8ead1480763e666c8587b73365850'}
response = requests.request("POST", url, headers=headers, data=payload, files=files)

# looking for the link
imgur_return = response.text
linkfile = open('C:/Users/Games/imgurlink.txt', 'a+')
linkfile.write(imgur_return)
linkfile.seek(0)
filetext = linkfile.read()
linkfile.close()
imgurlink = re.findall(r'https:\/\/i\.imgur\.com\/.*\.gif', filetext)
# ibg = imgurlink
# print (ibg)

# if i don't do it the following way, the link comes out with ['brackets and quotes']
# that's probably because what i've been 're turned' is a list
# and the following only works because it's the only link in the JSON response
for imgur in imgurlink:
    imgur_big_gif = imgur
os.remove('C:/Users/Games/imgurlink.txt')

# big gif is stored, hmm cancelling all file movements, both these methods have worked.  I think i need to close the file or something
# PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:/Users/Games/Postman/files/gif.gif'
# src = "C:/Users/Games/Postman/files/gif.gif"
# dest = f"C:/Users/Games/CB/{today.year}/{today.month}-{today.year}/"
# shutil.move('C:/Users/Games/Postman/files/gif.gif', dest)
# rename ("C:/Users/Games/CB/2024/2-2024/gif.gif", f"C:/Users/Games/CB/{today.year}/{today.month}-{today.year}/b{today.month}-{today.day}.gif")

# OR
# look at me turning 4 lines of code into 1
# rename ("C:/Users/Games/Postman/files/gif.gif", f"C:/Users/Games/CB/{today.year}/{today.month}-{today.year}/b{today.month}-{today.day}.gif")
# rename ("C:/Users/Games/Postman/files/gif.gif", f"C:/Users/Games/CB/{today.year}/{today.month}-{today.year}/b{today.month}-{today.day}.gif")

# open imgtalk to upload gif2
url3 = "https://www.talkimg.com/"
webbrowser.open(url3)
time.sleep(10)
pyautogui.click(953, 590)
time.sleep(5)
pyautogui.click(221, 479)
time.sleep(5)
pyautogui.typewrite("gif2.gif")
time.sleep(5)
pyautogui.hotkey('tab')
time.sleep(1)
pyautogui.hotkey('tab')
time.sleep(10)
pyautogui.hotkey('enter')
time.sleep(5)
pyautogui.click(949, 645)
time.sleep(5)
pyautogui.click(1276, 625)
time.sleep(5)
imgtalklink = pyperclip.paste()

# little gif is stored
#  rename (f"C:/Users/Games/Postman/files/gif2.gif", f"C:/Users/Games/CB/{today.year}/{today.month}-{today.year}/{today.month}-{today.day}.gif")

# # prepare to store downloads
# src = "C:/Users/Games/CB/images"
# dest = "C:/Users/Games/CB/images/{}".format(directory)
# files = os.listdir(src)
# os.chdir(src)

# # only move numbered png files
# for file in files:
#     if file.endswith(").png"):
#         shutil.move(file, dest)  

# add post to clipboard for btctalk
pyperclip.copy(f"ChartBuddy's 24 hour Wall Observation recap\n[url={imgur_big_gif}].{imgtalklink}.[/url]\nAll Credit to [url=https://bitcointalk.org/index.php?topic=178336.msg10084622#msg10084622]ChartBuddy[/url]")

# can use this link for the reply button
url7 = 'https://bitcointalk.org/index.php?action=post;topic=178336.0'
webbrowser.open(url7)
time.sleep(10)
pyautogui.hotkey('tab')
time.sleep(5)
pyautogui.hotkey('tab')
time.sleep(5)
pyautogui.hotkey('ctrl', 'v')
time.sleep(5)
pyautogui.hotkey('tab')
time.sleep(5)
# we're doing it live if the next command is #ed out
pyautogui.hotkey('tab')
time.sleep(5)
pyautogui.hotkey('enter')

#runtime is calculated
stopTime = time.perf_counter()
runtime = {stopTime - startTime}

# save to csv file
f = open('C:/PyProjects/runtimes.csv', 'a', newline='')
writer = csv.writer(f)
writer.writerow(runtime)
Crash and burn again, with the permissions.  I thought changing the GIMP's exports from Postman's folder to my own folder would solve the problem.  Which it did, but apparently only one time use only.  I understand Buddy needs space, so I'm going to install linux on a virtual machine, which i do have some very limited experience with, and see how things go there.  See you on the other side.
full member
Activity: 114
Merit: 93
Fly free sweet Mango.
Fingers of lead tonight mates.  Sad  I couldn't leave well enough alone.  Not that it worked completely last night, but here's a lesson that I know, but didn't implement.  Test after each change to one's code because if one changes 10 things, and it doesn't work, which thing is the problem?  I still can't figure out what happened with the imgur API last night, and how it uploaded an old gif.  But now I can't get it to work with python at all, I can upload using the Postman desktop app, but the python script it gives me kept erroring out tonight, even though I didn't touch that part of the code.  Last night something didn't work with imgur, but my code did, somehow, stumble the rest of the way to post the talkimg hosted gif into the bct forum.   
At least I've been saving daily versions of the script, so tonight I went back a few days and had a runtime of 342.5 s.   Embarrassed
full member
Activity: 114
Merit: 93
Fly free sweet Mango.
One click! One click! One click!  No, not 3 clicks, I said One click!, but it's actually, much, much, more!  How's that you ask?  Well, in one click, sorry, in One click!, i got the post, with proper gif, posted to the WO thread.  But for reasons i can't figure out yet, the imgur.com clickable link came out using 2-23 data.  Huh  So i needed clicks to fix.  Must be something to do with testing, but the code i ran is below.  I also successfully failed, sailed,  in step 4, when the 'my way' multi step solution to a simple answer, went wrong, yet showed the way.  Went wrong in the sense that there are many parts to solving a problem, it's not just the solving part.  Effort should be put into identifying the variables, and how the variables affect the outcome.  If I had mapped out all the outcomes, I might have seen from step one, just applying my pyautogui commands to the static link i've hard coded, would've been much easier.  

1.Download
2.Import  
3.Export
I need to figure out what to do on days with less than 24 downloads.  Also I'm going to work on less file movement, just put it where is going and call it from there when needed.  Before that I should understand virtual environments better.  

4.Posting  
I'm looking forward to removing all the pyautogui, and using the command line.  But if I'm logged into BCT and imgur, everything should work with one click. Cheesy  I had a plan and i executed it, but it ain't pretty.  

I figured out my way to get the most recent page of the WO Observer thread by looking at the first page source of the thread, which is a static link, to find the link to the last page of the thread at the bottom of the page.  I had some fun with that, because of my ignorance of the finer differences between strings, and lists.  But with a little help from copilot we powered on.  I now see one could also find the link to the most current page number, on the reply page to that thread. ATTN: Code Error produced 1000 not the desired 661080 or i guess it should have been 661060, since this particular post is the first on a new page.  OR ya big doofus, that's me, just hit reply on the first page and let the forum code handle on how to post it as the most recent post.  Roll Eyes  I realized this, when my solution failed and sent me to some other page rather than the last one, but since pyautogui mindlessly went on to hit reply, everything worked out okay, for that part.  Phew, at least i was in the proper thread.  Smiley

5.Archive
I just learned that pyautogui can also click and drag, so it should be possible, for fun, to drag all the images from every day this month into GIMP.  Maybe set up another race... Smiley  It would be good practice for loops and functions maybe.  I'm seeing a function that auto double-clicks the first day's folder, at (x, y) then select all, ctrl + a.  This way, there is no need to know how many images are in each day to move.  Then click and drag into gimp, go back to previous folder and loop around with (x, y + 20) or wherever the next day's folder is.  Hmm.  

I would need to know how many folders there are, or I could change the name of the folder to include a variable number that goes up by one each time a new day is added, then just cut it out of the directory name to plug into the mouse moving function, at the end of the month.  

2-25 run code runtime = 313.0 s
Code:
import csv, os, pyautogui, pyperclip, re, requests, shutil, time, urllib.request, webbrowser
from datetime import timedelta, date
from os import rename

startTime = time.perf_counter()

# set dates for links and new folder
today = date.today()
tomorrow = today + timedelta(1)

# get the final 20 gif layers in reverse order, starting with 24
number = 24
url4 = 'https://bitcointalk.org/index.php?action=profile;u=110685;sa=showPosts;start=0'
response = requests.get(url4)

# turn response into textfile of the source code.
source_code = response.text

# read the source code, save it, and turn it into a string.  
textfile = open('C:/Users/Games/CBSource.txt', 'a+')
textfile.write(source_code)
textfile.seek(0)
filetext = textfile.read()
textfile.close()

# find matches using regex, and for every match download the image and number it.  resorted to asking copilot for help with my regex
matches = re.findall(r'https:\/\/www\.talkimg\.com\/images\/\w{4}/\w{2}\/\w{2}\/\w{5}\.png', filetext)
for link in matches:
    print(number, link)
    urllib.request.urlretrieve(link, 'download ({}).png'.format(number))
    number = number - 1
    time.sleep(5)
os.remove('C:/Users/Games/CBSource.txt')

# get the first 4 images in reverse order, i copied my own code and changed the link.  Should have made a function and then fed it the links probably.
url5 = 'https://bitcointalk.org/index.php?action=profile;u=110685;sa=showPosts;start=20'
response5 = requests.get(url5)
source_code = response5.text
textfile5 = open('C:/Users/Games/CBSource2.txt', 'a+')
textfile5.write(source_code)
textfile5.seek(0)
filetext = textfile5.read()
textfile5.close()

# find matches using regex, and for first 4 matches download the image and number it
matches = re.findall(r'https:\/\/www\.talkimg\.com\/images\/\w{4}/\w{2}\/\w{2}\/\w{5}\.png', filetext)
for link in matches:
    if number >= 1:
        urllib.request.urlretrieve(link, 'download ({}).png'.format(number))
        print(number, link)
        number = number - 1
        time.sleep(5)
os.remove('C:/Users/Games/CBSource2.txt')

# move em where they usually go, repurposing code
src = "C:/Users/Games/"
dest = "C:/Users/Games/Downloads/"
files = os.listdir(src)
os.chdir(src)

# only move numbered png files
for file in files:
    if os.path.isfile(file): # probably don't need this because of the next if?
        if file.endswith(").png"):
            shutil.move(file, dest)

# name newfolder with date
directory = f"{today.month}-{today.day}"
parent_dir = "C:/Users/Games/Downloads"
newf = os.path.join(parent_dir, directory)
os.mkdir(newf)

# make sure everything is in the right place, no need to rush.  yet :)
# command for show desktop, and clicking an empty region on the proper monitor
time.sleep(5)
pyautogui.hotkey('win', 'd')
time.sleep(5)
pyautogui.click(1, 1)
time.sleep(5)

# hot keys to open gimp and then the plugin that load layers, export, scale, export gifs, quit, agree to not save
pyautogui.hotkey('ctrl', 'alt', 'g')
time.sleep(10)
pyautogui.hotkey('ctrl', 'alt', 'l')
time.sleep(5)
pyautogui.hotkey('tab')
time.sleep(1)
pyautogui.hotkey('tab')
time.sleep(1)
pyautogui.hotkey('tab')
time.sleep(1)
pyautogui.hotkey('enter')
time.sleep(10)
pyautogui.hotkey('ctrl', 'q')
time.sleep(5)
pyautogui.hotkey('shift', 'tab')
time.sleep(1)
pyautogui.hotkey('enter')
time.sleep(5)

# uploading big gif and getting link to use later,
url = "https://api.imgur.com/3/image"
payload = {'name': f'b{today.month}-{today.day}'}
files=[('image',('gif.gif',open('gif.gif','rb'),'image/gif'))]
headers = {'Authorization': 'Bearer f0e27b94e6f8ead1480763e666c8587b73365850'}
response = requests.request("POST", url, headers=headers, data=payload, files=files)

# find imgur url from api response
imgur_return = response.text
linkfile = open('C:/Users/Games/imgurlink.txt', 'a+')
linkfile.write(imgur_return)
linkfile.seek(0)
filetext = linkfile.read()
linkfile.close()
imgurlink = re.findall(r'https:\/\/i\.imgur\.com\/.*\.gif', filetext)
# ibg = imgurlink
# print (ibg)

# if i don't do it this way, the link comes out with ['brackets and quotes']
# that's probably because what i've been 're turned' is a list
# and the following only works because it's the only link in the JSON response
for imgur in imgurlink:
    ibg = imgur
os.remove('C:/Users/Games/imgurlink.txt')

# big gif is stored
src = "C:/Users/Games/Postman/files/gif.gif"
dest = f"C:/PyProjects/GMIP/{today.year}/{today.month}-{today.year}/"
shutil.move("C:/Users/Games/Postman/files/gif.gif", dest)
rename (f"C:/PyProjects/GMIP/{today.year}/{today.month}-{today.year}/gif.gif", f"C:/PyProjects/GMIP/{today.year}/{today.month}-{today.year}/b{today.month}-{today.day}.gif")

# open imgtalk to upload gif2
url3 = "https://www.talkimg.com/"
webbrowser.open(url3)

# pyautogui to the rescue
time.sleep(10)
pyautogui.click(953, 590)
time.sleep(5)
pyautogui.click(221, 479)
time.sleep(5)
pyautogui.typewrite("gif2.gif")
time.sleep(5)
pyautogui.hotkey('tab')
time.sleep(1)
pyautogui.hotkey('tab')
time.sleep(10)
pyautogui.hotkey('enter')
time.sleep(5)
pyautogui.click(949, 645)
time.sleep(5)
pyautogui.click(1276, 625)
time.sleep(5)
imgtalklink = pyperclip.paste()

# little gif is stored
src = "C:/Users/Games/Postman/files/"
dest = f"C:/PyProjects/GMIP/{today.year}/{today.month}-{today.year}/"
shutil.move("C:/Users/Games/Postman/files/gif2.gif", dest)
rename (f"C:/PyProjects/GMIP/{today.year}/{today.month}-{today.year}/gif2.gif", f"C:/PyProjects/GMIP/{today.year}/{today.month}-{today.year}/{today.month}-{today.day}.gif")

# make a list of files in downloads folder
src = "C:/Users/Games/Downloads"
dest = "C:/Users/Games/Downloads/{}".format(directory)
files = os.listdir(src)
os.chdir(src)

# only move numbered png files
for file in files:
    if os.path.isfile(file):
        if file.endswith(").png"):
            shutil.move(file, dest)  

# add post to clipboard for btctalk
pyperclip.copy(f"ChartBuddy's 24 hour Wall Observation recap\n[url={ibg}].{imgtalklink}.[/url]\nAll Credit to [url=https://bitcointalk.org/index.php?topic=178336.msg10084622#msg10084622]ChartBuddy[/url]")

# what kind of newb posts their own post? ;)
# this is one way to get the most current wall observer page through the page source
url7 = 'https://bitcointalk.org/index.php?topic=178336.0'
response = requests.get(url7)

# turn response into textfile of the source code.
source_code = response.text

# read the source code, save it, and turn it into a string.  
textfile = open('C:/Users/Games/CBSource.txt', 'a+')
textfile.write(source_code)
textfile.seek(0)
filetext = textfile.read()
textfile.close()
os.remove('C:/Users/Games/CBSource.txt')

# look for all the links again
matches = re.findall(r'https:\/\/bitcointalk\.org\/index\.php\?topic=178336\.[0-9]+', filetext)

# start an empty list and fill it with all the links and split off the thread numbers
pages = []
for hit in matches:
    res = hit.rsplit('.', 1)[-1]
    # res2 = res[1:2:1], oh boy, i just found this comment before runtime, but i searched for res2 and this is the only instance so i'm going for it like this
    # “The Times 2/26/2024 07:24 utc DK on brink of second crash.”  let's do this
    pages.append(res)

# i knew link i wanted was 5 from the end, so start at -5 for, until -6 is hit, -1 each time
# what I figured out to do, but it was coming back [['what I want']]
theone = (pages[-5:-6:-1])

# getting tired so didn't even try, copilot said do this
theone = theone[0].strip('[]')

# I'm back!, time for more autopygui
url7 = 'https://bitcointalk.org/index.php?topic=178336.{}'.format(theone)
webbrowser.open(url7)
time.sleep(5)
pyautogui.click(1171, 347)
time.sleep(5)
pyautogui.hotkey('end')
time.sleep(5)
pyautogui.click(1627, 829)
time.sleep(5)
pyautogui.hotkey('tab')
time.sleep(5)
pyautogui.hotkey('tab')
time.sleep(5)
pyautogui.hotkey('ctrl', 'v')
time.sleep(5)
# hit post!
pyautogui.click(914, 1008)

#runtime is calculated
stopTime = time.perf_counter()
runtime = {stopTime - startTime}

# save to csv file
f = open('C:/PyProjects/runtimes.csv', 'a', newline='')
writer = csv.writer(f)
writer.writerow(runtime)

EDIT: added details about 'semicrash' circumstances
full member
Activity: 114
Merit: 93
Fly free sweet Mango.
It didn't work, it didn't work, we. didn't. work.  Big crash, BUT,  huge breakthrough, although I need more testing to make sure this even worked...but.  Huge crashing progress!  With enough pyautoguis we could take over the world!  Firstly, the 2_22 build has worked great the last 2 days with runtimes of 239.2 s, and 252.5 s.  But we need less keystrokes.   Grin

Storylog:
1.Download
Works with a click Smiley

2.Import
Son of a batch.  Gonna take the L on this one for now.  Even copilot said it should be working.  Examples follow
Code:
PATH=%PATH%;"C:\Program Files\GIMP 2\bin"
gimp-2.10 --batch-interpreter python-fu-eval --pdb-compat-mode="on" -b "pdb.python_fu_loadlay" -b pdb.file_gif_save2 (image, drawable, "C:/PyProjects/tmp/gif.gif", "C:/PyProjects/tmp/gif.gif", 0, 1, 1000, 0, 0, 0, 0)

OR

PATH=%PATH%;"C:\Program Files\GIMP 2\bin"
gimp-2.10 --batch-interpreter python-fu-eval -b "pdb.python_fu_loadlay" -b "pdb.file_gif_save2" (image, drawable, "C:/PyProjects/tmp/gif.gif", "gif.gif", 0, 1, 1000, 0, 0, 0, 0)

OR

"C:\Program Files\GIMP 2\bin\gimp-console-2.10.exe" -i --batch-interpreter python-fu-eval -b "pdb.python_fu_loadlay" -b "(gimp-quit 1)"

But with pyautogui, I could just program in the mindless tabs and clicks.  Amazing!  So that I did.
 
3.Export
See above re: pyautogui's cool factor

4.Posting  
Figured out some of imgur's API, and how to crudely hack the link out of the imgur json response, i think, to get the link after uploading.  Full disclosure, i gave up and asked copilot, and then figured out how to make 'my' way work.  Then, there is, my attempt to use pyautogui, to upload a talkimg image and collect the link with no api.  I believe it would have worked, I think,  if I had put the script to sleep for longer, before moving the created gifs.  We'll see tomorrow...
Edge's copilot way
Code:
# Assuming 'api' contains the response object
response_data = json.loads(api.text)
image_link = response_data.get('data', {}).get('link')
ibg = image_link

5.Archive
tick tock

Code with two fails follows. I believe, one is easier to spot if you check the imgur filename.  The other, which I may be wrong about, is the need for a delay before moving the created gifs.

2_24 production build:
Code:
import csv, os, pyautogui, pyperclip, re, requests, shutil, subprocess, time, urllib.request, webbrowser
from datetime import timedelta, date
from os import rename
from tkinter import Tk

# start runtimer
startTime = time.perf_counter()

# set dates for links and new folder
today = date.today()
tomorrow = today + timedelta(1)
      
# learn to scrape 24 images 1 second at a time, yatta!
# get the final 20 gif layers in reverse order, starting with 24
number = 24
url4 = 'https://bitcointalk.org/index.php?action=profile;u=110685;sa=showPosts;start=0'
response = requests.get(url4)

# turn response into textfile of the source code.
source_code = response.text

# read the source code, save it, and turn it into a string.  
textfile = open('C:/Users/Games/CBSource.txt', 'a+')
textfile.write(source_code)
textfile.seek(0)
filetext = textfile.read()
textfile.close()

# find matches using regex, and for every match download the image and number it.  resorted to asking copilot for help with my regex
matches = re.findall(r'https:\/\/www\.talkimg\.com\/images\/\w{4}/\w{2}\/\w{2}\/\w{5}\.png', filetext)
for link in matches:
    print(link)
    urllib.request.urlretrieve(link, 'download ({}).png'.format(number))
    number = number - 1
    time.sleep(3)

#delete the source code
os.remove('C:/Users/Games/CBSource.txt')

# get the first 4 images in reverse order, i copied my own code and changed the link.  Should have made a function and then fed it the links probably.
url5 = 'https://bitcointalk.org/index.php?action=profile;u=110685;sa=showPosts;start=20'
response5 = requests.get(url5)
source_code = response5.text
textfile5 = open('C:/Users/Games/CBSource2.txt', 'a+')
textfile5.write(source_code)
textfile5.seek(0)
filetext = textfile5.read()
textfile5.close()

# find matches using regex, and for first 4 matches download the image and number it
matches = re.findall(r'https:\/\/www\.talkimg\.com\/images\/\w{4}/\w{2}\/\w{2}\/\w{5}\.png', filetext)
for link in matches:
    if number >=1:
        urllib.request.urlretrieve(link, 'download ({}).png'.format(number))
        number = number - 1
        time.sleep(3)
        print(link)
    
# delete the soure code
os.remove('C:/Users/Games/CBSource2.txt')

# move em where they usually go, repurposing code
src = "C:/Users/Games/"
dest = "C:/Users/Games/Downloads/"
files = os.listdir(src)
os.chdir(src)

# only move numbered png files
for file in files:
    if os.path.isfile(file): # probably don't need this because of the next if?
        if file.endswith(").png"):
            shutil.move(file, dest)  

# name newfolder with date
directory = f"{today.month}-{today.day}"
parent_dir = "C:/Users/Games/Downloads"
newf = os.path.join(parent_dir, directory)
os.mkdir(newf)
print("Directory '%s' created" %directory)

# hot keys for confirming plugin to open, load, export, scale, export gif, gif2, quit, agree to not save
# bye, bye, batch (for now :)
pyautogui.hotkey('ctrl', 'alt', 'g')
time.sleep(10)
pyautogui.hotkey('ctrl', 'alt', 'l')
time.sleep(5)
pyautogui.hotkey('tab')
time.sleep(1)
pyautogui.hotkey('tab')
time.sleep(1)
pyautogui.hotkey('tab')
time.sleep(1)
pyautogui.hotkey('enter')
time.sleep(10)
pyautogui.hotkey('ctrl', 'q')
time.sleep(5)
pyautogui.hotkey('shift', 'tab')
time.sleep(1)
pyautogui.hotkey('enter')

# uploading big gif and getting link to use later,
url = "https://api.imgur.com/3/image"
payload = {'name': 'b{today.month}-{today.day}'}
files=[('image',('gif.gif',open('gif.gif','rb'),'image/gif'))]
headers = {'Authorization': 'Bearer f0e27b94e6f8ead1480763e666c8587b73365850'}
response = requests.request("POST", url, headers=headers, data=payload, files=files)

# repurposing some code, that means define a function, right?
# find imgur url from api response
imgur_return = response.text
linkfile = open('C:/Users/Games/imgurlink.txt', 'a+')
linkfile.write(imgur_return)
linkfile.seek(0)
filetext = linkfile.read()
linkfile.close()

# delete the link.txt
os.remove('C:/Users/Games/imgurlink.txt')

imgurlink = re.findall(r'https:\/\/i\.imgur\.com\/.*\.gif', filetext)
# ibg = imgurlink
# print (ibg)

# if i don't do it this way the link comes out with ['brackets and quotes']
for imgur in imgurlink:
    ibg = imgur

# big gif is moved
src = "C:/Users/Games/Postman/files/gif.gif"
dest = "C:/PyProjects/GMIP/2024/2-2024/"
shutil.move("C:/Users/Games/Postman/files/gif.gif", dest)
rename ("C:/PyProjects/GMIP/2024/2-2024/gif.gif", f"C:/PyProjects/GMIP/2024/2-2024/b{today.month}-{today.day}.gif")

# little gif is moved
src = "C:/Users/Games/Postman/files/"
dest = "C:/PyProjects/GMIP/2024/2-2024/"
shutil.move("C:/Users/Games/Postman/files/gif2.gif", dest)
rename ("C:/PyProjects/GMIP/2024/2-2024/gif2.gif", f"C:/PyProjects/GMIP/2024/2-2024/{today.month}-{today.day}.gif")

# ID files
src = "C:/Users/Games/Downloads"
dest = "C:/Users/Games/Downloads/{}".format(directory)
files = os.listdir(src)
os.chdir(src)

# only move numbered png files
for file in files:
    if os.path.isfile(file):
        if file.endswith(").png"):
            shutil.move(file, dest)  

# open websites to upload gifs
url3 = "https://www.talkimg.com/"
webbrowser.open(url3)

# pyautogui to the rescue
time.sleep(5)

# click start uploading
pyautogui.click(953, 590)
time.sleep(5)

# click file enter box
pyautogui.click(221, 479)
time.sleep(5)

# type name of small gif
pyautogui.typewrite("gif2.gif")
time.sleep(5)

# move selection to save
pyautogui.hotkey('tab')
time.sleep(1)
pyautogui.hotkey('tab')
time.sleep(1)
pyautogui.hotkey('enter')
time.sleep(5)
pyautogui.click(949, 645)
time.sleep(5)

# click mouse to copy the talkimg link
pyautogui.click(1276, 625)

imgtalklink = pyperclip.paste()

# add post to clipboard for btctalk
r = Tk()
r.withdraw()
r.clipboard_clear()
r.clipboard_append(f"ChartBuddy's 24 hour Wall Observation recap\n[url={ibg}].{imgtalklink}.[/url]\nAll Credit to [url=https://bitcointalk.org/index.php?topic=178336.msg10084622#msg10084622]ChartBuddy[/url]")
r.update()

#this holds the post on the clipboard until posted
print("All done?")
input()

#runtime is calculated
stopTime = time.perf_counter()
runtime = {stopTime - startTime}

# save to csv file
f = open('C:/PyProjects/runtimes.csv', 'a', newline='')
writer = csv.writer(f)
writer.writerow(runtime)

EDIT: added comments to code about talkimg, pyautogui.  phrasing
full member
Activity: 114
Merit: 93
Fly free sweet Mango.
It worked, it worked, we worked! Man and machine in harmony, like the ending of...well I don't want to spoil that one.   Wink The runtime was a surprisingly high at 288.3 s, which I guess I have no reason to doubt, but I should manually test the accuracy of my method.  I did set a delay of 5 seconds between downloads, when manually it was probably in the 2-3 second range between downloads.   But the real savings is in key strokes.  Let's see...graciously estimating
1. Scroll through the day and download each ChartBuddy post.  Scrolling through usually around 4 pages to, right click, left click, enter 24 times, which would be (3*24)+3
2. Drag each downloaded image into GIMP as a new layer Click and drag 24 images, i hope i only did that a few times , 2*24 more actions
3. Export full size gif to imgur for the clickable link, and export optimized gif for the in-thread talkimg hosted one Oh boy, lets remember, export as, 2 clicks, type the name.gif, 5, timing the frames, 4 actions, click scale and choose size, 5 actions, export again, (2+5+4+5)*2
4. Put together the post and post  Let's not count the typing, clicking on 2 bookmarks, 2 click and drags, 6
5. Archive images for later use in a monthly replay  creating a new folder and naming it by date, 7 clicks and keystrokes and a click and drag, 9 = 168 total
168 actions.

And this time it was.  
1.Download: Click run, sit back and relax, 1
2.Import: loading, ctrl-alt-l, 3 tabs, enter, 7
3.Export: ctrl-alt-b, 2 tabs, enter, ctrl-alt-s, 2 tabs, enter, enter to script, 13
4.Post: same, 6
5.Archive: 0
27 actions, most of them mindless clicking through GIMP which I believe can do everything I need it to, all from the command line.  Exciting stuff!

Changelog:
1.Download Wow.  I am now auto downloading the images from BCT, and naming them in the process.

3.Export  I changed the GIMP gif saving plugin, by adding the resize of the gif in the same plugin.  So instead of save, resize, save (which all have keyboard shortcuts), it's now just save, save2.  I've duplicated the GIMP gif saving plugin so I don't have to wait to move the big gif, called, gif.gif before the small gif is exported, which was also called gif.gif.  The small gif is now gif2.gif. Which also means I get to get rid of 2 user inputs, which were only there to stop the code, waiting for me to tell it to proceed. Well, it still has to wait once I guess, but it will be so much faster, one less keystroke for sure. Smiley  

Working on.
2.Import Work in Progress:  I've got a code example of using the command line to start a Python script, that calls GIMP plug ins.  I'm trying to modify it for this purpose.
4.Post I guess I should have been working on that runtime posting bot after all.  Smiley
5.Archive  Blessed with an extra day this month to figure the code for the monthly recap.  

Current Code:
Code:
from datetime import timedelta, date
import time
import shutil
import os
from os import rename
import webbrowser
import subprocess
from tkinter import Tk
import csv
import re
import urllib.request
import requests

# start runtimer
startTime = time.perf_counter()

# set dates for links and new folder
today = date.today()
tomorrow = today + timedelta(1)
      
# open websites to upload gifs
url2 = "https://imgur.com/upload"
url3 = "https://www.talkimg.com/"
webbrowser.open(url2)
webbrowser.open(url3)

# get the final 20 gif layers in reverse order, starting with 24
number = 24
url4 = 'https://bitcointalk.org/index.php?action=profile;u=110685;sa=showPosts;start=0'
response = requests.get(url4)

# turn response into textfile of the source code.
source_code = response.text

# read the source code, save it, and turn it into a string.  
textfile = open('C:/Users/Games/CBSource.txt', 'a+')
textfile.write(source_code)
textfile.seek(0)
filetext = textfile.read()
textfile.close()

# find matches using regex, and for every match download the image and number it.  resorted to asking copilot for help with my regex
matches = re.findall(r'https:\/\/www\.talkimg\.com\/images\/\w{4}/\w{2}\/\w{2}\/\w{5}\.png', filetext)
for link in matches:
    print(link)
    urllib.request.urlretrieve(link, 'download ({}).png'.format(number))
    number = number - 1
    time.sleep(5)

#delete the source code
os.remove('C:/Users/Games/CBSource.txt')

# get the first 4 images in reverse order, i copied my own code and changed the link.  Should have made a function and then fed it the links probably.
url5 = 'https://bitcointalk.org/index.php?action=profile;u=110685;sa=showPosts;start=20'
response5 = requests.get(url5)
source_code = response5.text
textfile5 = open('C:/Users/Games/CBSource2.txt', 'a+')
textfile5.write(source_code)
textfile5.seek(0)
filetext = textfile5.read()
textfile5.close()

# find matches using regex, and for first 4 matches download the image and number it
matches = re.findall(r'https:\/\/www\.talkimg\.com\/images\/\w{4}/\w{2}\/\w{2}\/\w{5}\.png', filetext)
for link in matches:
    if number >=1:
        urllib.request.urlretrieve(link, 'download ({}).png'.format(number))
        number = number - 1
        time.sleep(5)
        print(link)
    
# delete the soure code
os.remove('C:/Users/Games/CBSource2.txt')

# move em where they usually go, repurposing code
src = "C:/Users/Games/"
dest = "C:/Users/Games/Downloads/"
files = os.listdir(src)
os.chdir(src)

# only move numbered png files
for file in files:
    if os.path.isfile(file): # probably don't need this because of the next if?
        if file.endswith(").png"):
            shutil.move(file, dest)  

# name newfolder with date
directory = f"{today.month}-{today.day}"
parent_dir = "C:/Users/Games/Downloads"
newf = os.path.join(parent_dir, directory)
os.mkdir(newf)
print("Directory '%s' created" %directory)

# learn to scrape 24 images 1 second at a time, yatta!
# else manually download each file

# automatically open gimp, then filter to load all images
subprocess.Popen([r'C:/Program Files/GIMP 2/bin/gimp-2.10.exe'])

# export gifs press the any key then enter
print("Are the gifs exported?")
input()
print("Movin' on...")

# big gif is moved
src = "C:/PyProjects/tmp/"
dest = "C:/PyProjects/GMIP/2024/2-2024/"
shutil.move("C:/PyProjects/tmp/gif.gif", dest)
rename ("C:/PyProjects/GMIP/2024/2-2024/gif.gif", f"C:/PyProjects/GMIP/2024/2-2024/b{today.month}-{today.day}.gif")

# little gif is moved
src = "C:/PyProjects/tmp/"
dest = "C:/PyProjects/GMIP/2024/2-2024/"
shutil.move("C:/PyProjects/tmp/gif2.gif", dest)
rename ("C:/PyProjects/GMIP/2024/2-2024/gif2.gif", f"C:/PyProjects/GMIP/2024/2-2024/{today.month}-{today.day}.gif")

# ID files
src = "C:/Users/Games/Downloads"
dest = "C:/Users/Games/Downloads/{}".format(directory)
files = os.listdir(src)
os.chdir(src)

# only move numbered png files
for file in files:
    if os.path.isfile(file):
        if file.endswith(").png"):
            shutil.move(file, dest)  

# upload to two sites, gather links to input into console
ibg = input("imgur big gif link here")
imgtalk = input("imgtalk little gif link here")

# add post to clipboard for btctalk
r = Tk()
r.withdraw()
r.clipboard_clear()
r.clipboard_append(f"ChartBuddy's 24 hour Wall Observation recap\n[url={ibg}].{imgtalk}.[/url]\nAll Credit to [url=https://bitcointalk.org/index.php?topic=178336.msg10084622#msg10084622]ChartBuddy[/url]")
r.update()

#this holds the post on the clipboard until posted
print("All done?")
input()

#runtime is calculated
stopTime = time.perf_counter()
runtime = {stopTime - startTime}

# save to csv file
f = open('C:/PyProjects/runtimes.csv', 'a', newline='')
writer = csv.writer(f)
writer.writerow(runtime)
full member
Activity: 114
Merit: 93
Fly free sweet Mango.
It was the best of times, it was the worst of times.
Three days with no runtimes.  The first two were because I knew the code would fail.  I have no error handling for what happens if ChartBuddy decides to take an hour off, to maybe go out for a pizza.  So I didn't even try.  

But now!  Such progress!  I found the pages on bitcointalk.org that have ChartBuddy's last 20 posts , and I have the auto download code, and it worked!  It's not the best way or the fastest way probably, and i needed copilot's help, but it is definitely my way. Smiley Because it then crashed.  Huh  But, here is the relevant new code, and with no BeautifulSoup, i only needed the page source to grab the links.  I knew the links would be in the form of https://www.talkimg.com/images/(4 digit year)/(2 digit month)/(2 digit date)/*****.png, where only the last 5 bits of the file would be different.  I tried and tried, but had to resort to copilot to get my regex correct.
Code:
# get the last 20 images in reverse order, starting with 24, ChartBuddy is user 110685
url = 'https://bitcointalk.org/index.php?action=profile;u=110685;sa=showPosts;start=0'

# send a get request and get the response object
response = requests.get(url)

# turn response into textfile of the source code, not sure if needed, what else did I request?
source_code = response.text

# read the source code, save it, and turn it into a string.  Why am i saving it if I'm going to delete it, can probably skip this instruction, but it might help with error handling?  
textfile = open('C:/Users/Games/CBSource.txt', 'a+')
textfile.write(source_code)
textfile.seek(0)
filetext = textfile.read()
textfile.close()

number = 24

# find matches using regex, and for every match download the image, and number it.  i resorted to asking copilot for help with my regex
matches = re.findall(r'https:\/\/www\.talkimg\.com\/images\/\w{4}/\w{2}\/\w{2}\/\w{5}\.png', filetext)
for link in matches:
    print(link)
    urllib.request.urlretrieve(link, 'download({}).png'.format(number))
    number = number - 1
    time.sleep(5)

#delete the source code
os.remove('C:/Users/Games/CBSource.txt')

One thing i'm still ignorant of, which is okay, is why i can sometimes pass variables directly, sometime one has to use curly brackets, and other times empty curly brackets with defining at the end, but learning is living.

Here is the full script i ran today, which I know is going to work tomorrow, after making a tiny change.  Or maybe it won't. Cheesy  If it does I am going to try and work on error handling. .  
If you can see why this script crashed you are an awesome debugger!  (hint: it happens early  Grin)
Code:
from datetime import timedelta, date
import time
import shutil
import os
from os import rename
import webbrowser
import subprocess
from tkinter import Tk
import csv
import re
import urllib.request
import requests

# start runtimer
startTime = time.perf_counter()

#set dates for links and new folder
today = date.today()
tomorrow = today + timedelta(1)
      
# open links to download and upload images if only I could get out of the way
# url1 = f"https://injastic.space/search?after_date={today.strftime("%Y")}-{today.strftime("%m")}-{today.strftime("%d")}T07%3A55%3A00&author=ChartBuddy&before_date={tomorrow.strftime("%Y")}-{tomorrow.strftime("%m")}-{tomorrow.strftime("%d")}T07%3A55%3A00"
url2 = "https://imgur.com/upload"
url3 = "https://www.talkimg.com/"
webbrowser.open(url1)
webbrowser.open(url2)
webbrowser.open(url3)

# holy cow is this going to work all together on the first try
# get the last 20 images in reverse order, starting with 24
# set the file numbering start
number = 24

# get the last 20 images in reverse order, starting with 24
url = 'https://bitcointalk.org/index.php?action=profile;u=110685;sa=showPosts;start=0'

# Send a get request and get the response object
response = requests.get(url)

# turn response into textfile of the source code, not sure if needed, what else did I request?
source_code = response.text

# read the source code, save it, and turn it into a string.  Why am i saving it if I'm going to delete it?  
textfile = open('C:/Users/Games/CBSource.txt', 'a+')
textfile.write(source_code)
textfile.seek(0)
filetext = textfile.read()
textfile.close()

# find matches using regex, and for every match download the image and number it.  resorted to asking copilot for help with my regex
matches = re.findall(r'https:\/\/www\.talkimg\.com\/images\/\w{4}/\w{2}\/\w{2}\/\w{5}\.png', filetext)
for link in matches:
    print(link)
    urllib.request.urlretrieve(link, 'download({}).png'.format(number))
    number = number - 1
    time.sleep(5)

#delete the source code
os.remove('C:/Users/Games/CBSource.txt')

# get the first 4 images in reverse order, i copied my own code and changed the link.  Should have made a function and then fed it the links probably.
# i renamed everything here with 2, i'm not sure i needed to, but I think I did it correctly
url2 = 'https://bitcointalk.org/index.php?action=profile;u=110685;sa=showPosts;start=20'

# Send a GET request and get the response object
response2 = requests.get(url2)

# turn response into textfile of source
source_code = response2.text

# read the source code and turn it into a string
textfile2 = open('C:/Users/Games/CBSource2.txt', 'a+')
textfile2.write(source_code)
textfile2.seek(0)
filetext = textfile2.read()
textfile2.close()

# find matches using regex, and for first 4 matches download the image and number it
# tried using finditer i think it was to set a limit for the first four results, but i was getting another string, so this seemed like a workaround
matches = re.findall(r'https:\/\/www\.talkimg\.com\/images\/\w{4}/\w{2}\/\w{2}\/\w{5}\.png', filetext)
for link in matches:
    if number >=1:
        urllib.request.urlretrieve(link, 'download({}).png'.format(number))
        number = number - 1
        time.sleep(5)
        print(link)
    
# delete the soure code
os.remove('C:/Users/Games/CBSource2.txt')

# move em where they usually repurposing code
# ID files
src = "C:/Users/Games/"
dest = "C:/Users/Games/Downloads/"
files = os.listdir(src)
os.chdir(src)

# i have named the new downloads to look like the old manual downloads
# only move numbered png files
for file in files:
    if os.path.isfile(file): # probably don't need this because of the next if?
        if file.endswith(").png"):
            shutil.move(file, dest)  

#back to the old code
# name newfolder with date
directory = f"{today.month}-{today.day}"
parent_dir = "C:/Users/Games/Downloads"
newf = os.path.join(parent_dir, directory)
os.mkdir(newf)
print("Directory '%s' created" %directory)

# learn to scrape 24 images 1 second at a time,
# else manually download each file

# automatically open gimp, then filter to load all images
subprocess.Popen([r'C:/Program Files/GIMP 2/bin/gimp-2.10.exe'])

# export big gif press the any key then enter
print("Is big gif exported?")
input()
print("Movin' on...")

# big gif is moved
src = "C:/PyProjects/tmp/"
dest = "C:/PyProjects/GMIP/2024/2-2024/"
shutil.move("C:/PyProjects/tmp/gif.gif", dest)
rename ("C:/PyProjects/GMIP/2024/2-2024/gif.gif", f"C:/PyProjects/GMIP/2024/2-2024/b{today.month}-{today.day}.gif")

# scale image and export little gif
print("Is little gif exported?")
input()
print("Movin' on...")

# little gif is moved
src = "C:/PyProjects/tmp/"
dest = "C:/PyProjects/GMIP/2024/2-2024/"
shutil.move("C:/PyProjects/tmp/gif.gif", dest)
rename ("C:/PyProjects/GMIP/2024/2-2024/gif.gif", f"C:/PyProjects/GMIP/2024/2-2024/{today.month}-{today.day}.gif")

# ID files
src = "C:/Users/Games/Downloads"
dest = "C:/Users/Games/Downloads/{}".format(directory)
files = os.listdir(src)
os.chdir(src)

# i have a dummy file present so new downloads look like download(*).png
# only move numbered png files
for file in files:
    if os.path.isfile(file):
        if file.endswith(").png"):
            shutil.move(file, dest)  

# upload to two sites, gather links to input into console
ibg = input("imgur big gif link here")
imgtalk = input("imgtalk little gif link here")

# add post to clipboard for btctalk
r = Tk()
r.withdraw()
r.clipboard_clear()
r.clipboard_append(f"ChartBuddy's 24 hour Wall Observation recap\n[url={ibg}].{imgtalk}.[/url]\nAll Credit to [url=https://bitcointalk.org/index.php?topic=178336.msg10084622#msg10084622]ChartBuddy[/url]")
r.update()

#this holds the post on the clipboard until posted
print("All done?")
input()

#runtime is calculated
stopTime = time.perf_counter()
runtime = {stopTime - startTime}

# save to csv file
f = open('C:/PyProjects/runtimes.csv', 'a', newline='')
writer = csv.writer(f)
writer.writerow(runtime)

EDIT: added details about regex, added a line of code defining number to first snippet, changelog soon Smiley  
full member
Activity: 114
Merit: 93
Fly free sweet Mango.
I've decided that unless the man himself, Richy_T, says so, I'm not going to alter the images posted.  Back to more faux-ding I guess.  Grin

But I did come up with some prototypes for our perusal. I'd love to post the recap at midnight UTC, but for that we would need full bot mode, I presume.

First up is what I call barlay, for the progress bar and importing the layers together.
Code:
https://imgur.com/a/r1LloJI
https://imgur.com/a/r1LloJI

Next is barlaytouch, which was an accident, but I thought it looked cool.
Code:
https://imgur.com/a/J8b9mQM
https://imgur.com/a/J8b9mQM

Datelay is a prototype only, getting the spacing right on different days would be a lot of ifs to deal with variable kerning. Smiley
Code:
https://imgur.com/a/MwSiujF
https://imgur.com/a/MwSiujF

Then we have the fun ccbarlay, for color changing.  Took me awhile to figure out the the RGB values switched on me from 0-255 to 0-1.0  
Code:
https://imgur.com/a/9Ijom6U
https://imgur.com/a/9Ijom6U

Code:
import sys, os, re, traceback
from collections import namedtuple
from gimpfu import *
import gimpcolor
# personal use of font thanks to https://chequered.ink/font-license/

def plugin_ccbarlay(image, drawable):
    
    image = pdb.gimp_file_load("C:/Users/Games/Downloads/download (0).xcf", "/download (0).xcf")
    display = pdb.gimp_display_new(image)
    colr = 0.0
    colg = 0.75

    

    for items in range(1,25):
        xlength = items * 15
        pdb.gimp_context_set_foreground(gimpcolor.RGB(colr, colg, 0))
        location = r"C:/Users/Games/Downloads/download ({}).png".format(items)
        layer = pdb.gimp_file_load_layer(image, location)
        pdb.gimp_image_insert_layer(image, layer, None, -1)
        pdb.gimp_image_select_rectangle(image, 2, 220, 25, xlength, 20)
        pdb.gimp_drawable_edit_bucket_fill(layer, 0, 340, 10)
        layer = pdb.gimp_text_fontname (image, None, 315, 40, "0:00 UTC ^", 0, True, 30, PIXELS, "Withheld Data")
        pdb.gimp_image_merge_down(image, layer, 1)
        colr = colr + 0.03
        colg = colg - 0.03
        
register(
        "python-fu-ccbarlay",
        "This loads layers with a progress bar",
        "Very specific use case",
        "author: DK",
        "copyright: probably not",
        "date: 2024",
        "/Filters/ccbarlay",
        "",
        [
            

        ],
        [],
        plugin_ccbarlay)

main()

And saving the best for last, imo, what I call daylay.  This one has the full dark earth at midnight utc.  It was a fun challenge figuring out how to cycle through the 'letters'.
Code:
https://imgur.com/a/XY5vjts
https://imgur.com/a/XY5vjts

Code:
from gimpfu import *
import gimpcolor
# personal use of font called moon_phases.ttf thanks to Curtis Clark

def plugin_daylay(image, drawable):
    
    image = pdb.gimp_file_load("C:/Users/Games/Downloads/download (0).xcf", "/download (0).xcf")
    display = pdb.gimp_display_new(image)
    pdb.gimp_context_set_foreground(gimpcolor.RGB(58, 118, 222))
  
    # loads layers and prints moondings u - t skipping z and a, so that the m full moonding happens at 0:00 utc
    for items in range(1,25):
        location = r"C:/Users/Games/Downloads/download ({}).png".format(items)
        layer = pdb.gimp_file_load_layer(image, location)
        pdb.gimp_image_insert_layer(image, layer, None, -1)
        
        #these ifs use the proper fudge factor for the layer number conversion to ascii number
        if items <= 5:
            i = items + 116
            alpha = chr(i)
            layer = pdb.gimp_text_fontname (image, None, 365, 0, alpha, 0, True, 80, PIXELS, "day Phases")
            pdb.gimp_image_merge_down(image, layer, 1)
        
        if items >= 6:
            i = items + 92
            alpha = chr(i)
            layer = pdb.gimp_text_fontname (image, None, 365, 0, alpha, 0, True, 80, PIXELS, "day Phases")
            pdb.gimp_image_merge_down(image, layer, 1)
      

register(
        "python-fu-daylay",
        "This loads layers with a progress bar",
        "Very specific use case",
        "author: DK",
        "copyright: probably not",
        "date: 2024",
        "/Filters/daylay",
        "",
        [
            

        ],
        [],
        plugin_daylay)

main()

So while I had a lot of fun today, and know more about GIMP now, I think the biggest thing I realized is it looks like it's time to learn more about ImageMagick. Smiley
But I have the scripts if anyone has a cool font or color you think I might like.  

Latest runtime: 279.1 seconds, and I had to put back the plug in I really wanted, and restart GIMP so that's around 15 seconds...Edit: spelling
full member
Activity: 114
Merit: 93
Fly free sweet Mango.
I'm so excited, I figured out how to code a progress bar in GIMP!

I tied the length of the rectangle I was selecting to be paint bucketed, to the frame layer of the gif.

Keep this under your hat, I'm gonna cosplay as a graphic designer tomorrow and see what i can do with this.  My goal is to show when UTC 0:00 is relative to the progress bar.
Code:
https://imgur.com/a/ZC95ndv

https://imgur.com/a/ZC95ndv

Code:
import sys, os, re, traceback
from collections import namedtuple
from gimpfu import *

def plugin_textlay(image, drawable):
   
#load base layer with custom frametime
    image = pdb.gimp_file_load("C:/Users/Games/Downloads/download (0).xcf", "/download (0).xcf")
    display = pdb.gimp_display_new(image)

#load additional layers growing the status bar
    for items in range(1,25):
        xlength = items * 15
        location = r"C:/Users/Games/Downloads/download ({}).png".format(items)
        layer = pdb.gimp_file_load_layer(image, location)
        pdb.gimp_image_insert_layer(image, layer, None, -1)
        pdb.gimp_image_select_rectangle(image, 2, 220, 25, xlength, 30)
        pdb.gimp_drawable_edit_bucket_fill(layer, 0, 340, 10)
       
register(
        "python-fu-textlay",
        "This loads layers and bar",
        "Very specific use case",
        "author: DK",
        "copyright: probably not",
        "date: 2024",
        "/Filters/textlay",
        "",
        [
           

        ],
        [],
        plugin_textlay)

main()

I'm sure it's the same, but different with how other code works, but I enjoy using Python and being able to define a variable, and then being able to just plug it in here and there.

Latest runtime: 270.9 seconds

legendary
Activity: 3290
Merit: 16489
Thick-Skinned Gang Leader and Golden Feather 2021
Wouldn't ImageMagick be easier to automate things than The GIMP?
Possibly.  For which step in particular?
I can't tell, I've never used The GIMP for automating anything, but I use ImageMagick a lot. I mentioned it because it may be worth looking into.

Wow, that seems like quite the tool!  I'm not sure I need all the power it provides, so I'm going to stick to GIMP for now.  Thank you though!
You're welcome Smiley Having more options is always good Smiley
full member
Activity: 114
Merit: 93
Fly free sweet Mango.
I messed up again, but it was my fault.  Exploring imgur's api i got logged out, so when I was dragging the gif into imgur i kept getting an error.  I incorrectly attributed this error to imgur being too busy at the moment, which was a message i frequently received when trying to set up postman, but it turns out i wasn't logged in to imgur.  After logging in everything else went according to plan.  Runtime = 335.2 seconds.

Wouldn't ImageMagick be easier to automate things than The GIMP?

Wow, that seems like quite the tool!  I'm not sure I need all the power it provides, so I'm going to stick to GIMP for now.  Thank you though!

Changelog:
GIMP script now autoresizes the big gif into the imgtalk size gif, after exporting.  So I just have to hit Ctrl-Alt-S, click enter in VS, Ctrl-Alt-S again, click enter in VS and feed in the links
full member
Activity: 114
Merit: 93
Fly free sweet Mango.
Oh wow.  It worked!  Cool  I stopped midway to reread the script and make sure I knew where the first gif was going.  Didn't want a file to already be there.
Plus I always watch the gifs before posting to make sure everything is in order, but that is just a minute or so.   These are definitely rookie numbers: 369.8 seconds

I think with this code, trusting it, getting better at the keyboard shortcuts, and having the right folder open to drag images to the image hosting sites we could get that down to under 60 seconds.  But I know we can automate more, mainly on the downloading the images, and the GIMP processing going unattended.  Heh, I should code a bot to post the nightly runtimes...actually, I won't spam the place up, but that might be good practice, but first things first.

EDIT:
No hiccups 2 days in a row.  Grin  Runtime was 251.3 seconds.  Wasn't in any particular rush, enjoying all the pictures.   Smiley

Next steps:  learn to link gimp plug-ins using scripts running unattended, keep messing around with web scraping, streamline the current script, and I better start working on the script to make the monthly gif.  I should be able to modify the current gimp plugin that loads each day's 24 images, to be a loop inside of a loop.  We'll see. 
full member
Activity: 114
Merit: 93
Fly free sweet Mango.
Wouldn't ImageMagick be easier to automate things than The GIMP?

Possibly.  For which step in particular?  I do have prior experience with GIMP and am pleased with how my learning Python is tying in with it.  I'll look into it!

Okay.  I'm sure everyone sees the problem and y'all shouldn't have to wait.  We have two many changing variables.  Wink  Let's make the strftime work with random dates as well.

if statements, with random date:  26.7698 ms per link created,
strftime, with random date:          26.9713 ms per link created

Pretty close there, both have nice results within them, but probably too close to tell without more data.  What if we import the date for both?
lookup today ifs:   0.003934090 ms per link created
strftime lookup:    0.015847180 ms per link created

Seems like the ifs are conclusively faster, but today's date leads to less if statements being tested against, if i understand things, than if it was a 'change of month or year date' link being made.  So I ran those as well, these times are in ms to make one link using the date provided.  Goal: fix this once i figure out tables.  i tried

all numbers are how long it took in milliseconds for each link to be created (ms/link)
lookup today ifs      set date ifs        if new month         if new year        if test rand        strftime lookup      strftime rand
0.00393409               0.00279952       0.00279952         0.002679110             26.7699           0.0158472              26.9713
0.00479044               0.00304908        0.00309240         0.00295039               29.5539           0.0154960              28.9656

But it seems, for now, the 'if' submission will lead to a higher score in time completion, while the 'strftime' will lead to a higher score in the line length competition.  Don't let perfect be the enemy of good.  Keep calm and make mistakes.

Here's all the different code
Code:
>>>...>>>...>>>lookup today ifs
import datetime
from datetime import timedelta
from datetime import date
import time
import shutil
import os
from os import rename
import webbrowser
import subprocess
from tkinter import Tk
import csv
from faker import Faker

# start range
for i in range(0, 10000):
  
    # start runtimer
    tsubi = time.perf_counter()

    # set dates for link range and newf
    tod = date.today()
    tom = tod + timedelta(days = 1)

    # check dates and create link
    if tod.day < 9 and tod.month <= 9:
        # create link for days 1-8 and month 1-9
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-0{tod.month}-0{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-0{tod.month}-0{tom.day}T07%3A55%3A00"
            return link

    if tod.day < 9 and tod.month >= 10:
        # create link for days 1-8 and month 10,11,12
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-{tod.month}-0{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-{tod.month}-0{tom.day}T07%3A55%3A00"
            return link

    if tod.day == 9 and tod.month <= 9:
        # create link for day 9 with tommorow 10 and month 1-9
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-0{tod.month}-0{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-0{tod.month}-{tom.day}T07%3A55%3A00"
            return link

    if tod.day == 9 and tod.month >= 10:
        # create link for day 9 with tommorow 10 and month 10,11,12
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-{tod.month}-0{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-{tod.month}-{tom.day}T07%3A55%3A00"
            return link
        
    if tod.day > 9 and tod.month <= 9 and tod.month == tom.month:
        # create link for days 1-8 and month 1-9
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-0{tod.month}-{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-0{tod.month}-{tom.day}T07%3A55%3A00"
            return link

    if tod.day > 9 and tod.month >= 10 and tod.month == tom.month:
        # create link for days 1-8 and month 10,11,12
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-{tod.month}-{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-{tod.month}-{tom.day}T07%3A55%3A00"
            return link

    if tod.month <= 8 and tod.month != tom.month:
        # create link for last day of months 1-8
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-0{tod.month}-{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-0{tom.month}-0{tom.day}T07%3A55%3A00"
            return link
        
    if tod.month == 9 and tod.month != tom.month:
        # create link for last day of month 9
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-0{tod.month}-{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-{tom.month}-0{tom.day}T07%3A55%3A00"
            return link
        
    if (tod.month == 10 or tod.month == 11) and tod.month != tom.month:
        # create link for last day of month 10,11
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-{tod.month}-{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-{tom.month}-0{tom.day}T07%3A55%3A00"
            return link
        
    if tod.year != tom.year:
        # create link for last day of the year
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-{tod.month}-{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tom.year}-0{tom.month}-0{tom.day}T07%3A55%3A00"
            return link
        
    #runtime is calculated and printed
    tsubf = time.perf_counter()
  
    # calculate and save to csv file
    runtime = {tsubf-tsubi}    
    f = open('C:/PyProjects/tmp/if_test_nonew.csv', 'a', newline='')
    writer = csv.writer(f)
    writer.writerow(runtime)

>>>...>>>...>>>set date ifs
import datetime
from datetime import timedelta
from datetime import date
import time
import shutil
import os
from os import rename
import webbrowser
import subprocess
from tkinter import Tk
import csv
from faker import Faker

# start range
for i in range(0, 10000):
  
    # start runtimer
    tsubi = time.perf_counter()

    # set dates for link range and newf
    tod = datetime.datetime(2024, 1, 29)
    tom = tod + timedelta(days = 1)

    # check dates and create link
    if tod.day < 9 and tod.month <= 9:
        # create link for days 1-8 and month 1-9
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-0{tod.month}-0{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-0{tod.month}-0{tom.day}T07%3A55%3A00"
            return link

    if tod.day < 9 and tod.month >= 10:
        # create link for days 1-8 and month 10,11,12
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-{tod.month}-0{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-{tod.month}-0{tom.day}T07%3A55%3A00"
            return link

    if tod.day == 9 and tod.month <= 9:
        # create link for day 9 with tommorow 10 and month 1-9
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-0{tod.month}-0{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-0{tod.month}-{tom.day}T07%3A55%3A00"
            return link

    if tod.day == 9 and tod.month >= 10:
        # create link for day 9 with tommorow 10 and month 10,11,12
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-{tod.month}-0{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-{tod.month}-{tom.day}T07%3A55%3A00"
            return link
        
    if tod.day > 9 and tod.month <= 9 and tod.month == tom.month:
        # create link for days 1-8 and month 1-9
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-0{tod.month}-{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-0{tod.month}-{tom.day}T07%3A55%3A00"
            return link

    if tod.day > 9 and tod.month >= 10 and tod.month == tom.month:
        # create link for days 1-8 and month 10,11,12
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-{tod.month}-{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-{tod.month}-{tom.day}T07%3A55%3A00"
            return link

    if tod.month <= 8 and tod.month != tom.month:
        # create link for last day of months 1-8
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-0{tod.month}-{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-0{tom.month}-0{tom.day}T07%3A55%3A00"
            return link
        
    if tod.month == 9 and tod.month != tom.month:
        # create link for last day of month 9
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-0{tod.month}-{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-{tom.month}-0{tom.day}T07%3A55%3A00"
            return link
        
    if (tod.month == 10 or tod.month == 11) and tod.month != tom.month:
        # create link for last day of month 10,11
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-{tod.month}-{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-{tom.month}-0{tom.day}T07%3A55%3A00"
            return link
        
    if tod.year != tom.year:
        # create link for last day of the year
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-{tod.month}-{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tom.year}-0{tom.month}-0{tom.day}T07%3A55%3A00"
            return link
        
    #runtime is calculated and printed
    tsubf = time.perf_counter()
  
    # calculate and save to csv file
    runtime = {tsubf-tsubi}    
    f = open('C:/PyProjects/tmp/if_test_setdate.csv', 'a', newline='')
    writer = csv.writer(f)
    writer.writerow(runtime)

>>>...>>>...>>>if new month
import datetime
from datetime import timedelta
from datetime import date
import time
import shutil
import os
from os import rename
import webbrowser
import subprocess
from tkinter import Tk
import csv
from faker import Faker

# start range
for i in range(0, 10000):
  
    # start runtimer
    tsubi = time.perf_counter()

    # set dates for link range and newf
    tod = datetime.datetime(2024, 2, 29)
    tom = tod + timedelta(days = 1)

    # check dates and create link
    if tod.day < 9 and tod.month <= 9:
        # create link for days 1-8 and month 1-9
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-0{tod.month}-0{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-0{tod.month}-0{tom.day}T07%3A55%3A00"
            return link

    if tod.day < 9 and tod.month >= 10:
        # create link for days 1-8 and month 10,11,12
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-{tod.month}-0{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-{tod.month}-0{tom.day}T07%3A55%3A00"
            return link

    if tod.day == 9 and tod.month <= 9:
        # create link for day 9 with tommorow 10 and month 1-9
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-0{tod.month}-0{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-0{tod.month}-{tom.day}T07%3A55%3A00"
            return link

    if tod.day == 9 and tod.month >= 10:
        # create link for day 9 with tommorow 10 and month 10,11,12
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-{tod.month}-0{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-{tod.month}-{tom.day}T07%3A55%3A00"
            return link
        
    if tod.day > 9 and tod.month <= 9 and tod.month == tom.month:
        # create link for days 1-8 and month 1-9
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-0{tod.month}-{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-0{tod.month}-{tom.day}T07%3A55%3A00"
            return link

    if tod.day > 9 and tod.month >= 10 and tod.month == tom.month:
        # create link for days 1-8 and month 10,11,12
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-{tod.month}-{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-{tod.month}-{tom.day}T07%3A55%3A00"
            return link

    if tod.month <= 8 and tod.month != tom.month:
        # create link for last day of months 1-8
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-0{tod.month}-{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-0{tom.month}-0{tom.day}T07%3A55%3A00"
            return link
        
    if tod.month == 9 and tod.month != tom.month:
        # create link for last day of month 9
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-0{tod.month}-{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-{tom.month}-0{tom.day}T07%3A55%3A00"
            return link
        
    if (tod.month == 10 or tod.month == 11) and tod.month != tom.month:
        # create link for last day of month 10,11
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-{tod.month}-{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-{tom.month}-0{tom.day}T07%3A55%3A00"
            return link
        
    if tod.year != tom.year:
        # create link for last day of the year
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-{tod.month}-{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tom.year}-0{tom.month}-0{tom.day}T07%3A55%3A00"
            return link
        
    #runtime is calculated and printed
    tsubf = time.perf_counter()
  
    # calculate and save to csv file
    runtime = {tsubf-tsubi}    
    f = open('C:/PyProjects/tmp/if_test_newmonth.csv', 'a', newline='')
    writer = csv.writer(f)
    writer.writerow(runtime)

>>>...>>>...>>>if new year
import datetime
from datetime import timedelta
from datetime import date
import time
import shutil
import os
from os import rename
import webbrowser
import subprocess
from tkinter import Tk
import csv
from faker import Faker

# start range
for i in range(0, 10000):
  
    # start runtimer
    tsubi = time.perf_counter()

    # set dates for link range and newf
    tod = datetime.datetime(2001, 12, 31)
    tom = tod + timedelta(days = 1)

    # check dates and create link
    if tod.day < 9 and tod.month <= 9:
        # create link for days 1-8 and month 1-9
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-0{tod.month}-0{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-0{tod.month}-0{tom.day}T07%3A55%3A00"
            return link

    if tod.day < 9 and tod.month >= 10:
        # create link for days 1-8 and month 10,11,12
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-{tod.month}-0{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-{tod.month}-0{tom.day}T07%3A55%3A00"
            return link

    if tod.day == 9 and tod.month <= 9:
        # create link for day 9 with tommorow 10 and month 1-9
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-0{tod.month}-0{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-0{tod.month}-{tom.day}T07%3A55%3A00"
            return link

    if tod.day == 9 and tod.month >= 10:
        # create link for day 9 with tommorow 10 and month 10,11,12
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-{tod.month}-0{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-{tod.month}-{tom.day}T07%3A55%3A00"
            return link
        
    if tod.day > 9 and tod.month <= 9 and tod.month == tom.month:
        # create link for days 1-8 and month 1-9
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-0{tod.month}-{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-0{tod.month}-{tom.day}T07%3A55%3A00"
            return link

    if tod.day > 9 and tod.month >= 10 and tod.month == tom.month:
        # create link for days 1-8 and month 10,11,12
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-{tod.month}-{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-{tod.month}-{tom.day}T07%3A55%3A00"
            return link

    if tod.month <= 8 and tod.month != tom.month:
        # create link for last day of months 1-8
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-0{tod.month}-{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-0{tom.month}-0{tom.day}T07%3A55%3A00"
            return link
        
    if tod.month == 9 and tod.month != tom.month:
        # create link for last day of month 9
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-0{tod.month}-{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-{tom.month}-0{tom.day}T07%3A55%3A00"
            return link
        
    if (tod.month == 10 or tod.month == 11) and tod.month != tom.month:
        # create link for last day of month 10,11
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-{tod.month}-{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-{tom.month}-0{tom.day}T07%3A55%3A00"
            return link
        
    if tod.year != tom.year:
        # create link for last day of the year
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-{tod.month}-{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tom.year}-0{tom.month}-0{tom.day}T07%3A55%3A00"
            return link
        
    #runtime is calculated and printed
    tsubf = time.perf_counter()
  
    # calculate and save to csv file
    runtime = {tsubf-tsubi}    
    f = open('C:/PyProjects/tmp/if_test_newyear.csv', 'a', newline='')
    writer = csv.writer(f)
    writer.writerow(runtime)


>>>...>>>...>>>if test rand
import datetime
from datetime import timedelta
from datetime import date
import time
import shutil
import os
from os import rename
import webbrowser
import subprocess
from tkinter import Tk
import csv
from faker import Faker

# start range
for i in range(0, 10000):

    # start runtimer
    tsubi = time.perf_counter()

    # make fake datetime
    fake = Faker()
    tod = fake.future_datetime('+50y', None)
    tom = tod + timedelta(days = 1)

    # check dates and create link
    if tod.day < 9 and tod.month <= 9:
        # create link for days 1-8 and month 1-9
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-0{tod.month}-0{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-0{tod.month}-0{tom.day}T07%3A55%3A00"
            return link

    if tod.day < 9 and tod.month >= 10:
        # create link for days 1-8 and month 10,11,12
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-{tod.month}-0{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-{tod.month}-0{tom.day}T07%3A55%3A00"
            return link

    if tod.day == 9 and tod.month <= 9:
        # create link for day 9 with tommorow 10 and month 1-9
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-0{tod.month}-0{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-0{tod.month}-{tom.day}T07%3A55%3A00"
            return link

    if tod.day == 9 and tod.month >= 10:
        # create link for day 9 with tommorow 10 and month 10,11,12
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-{tod.month}-0{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-{tod.month}-{tom.day}T07%3A55%3A00"
            return link
        
    if tod.day > 9 and tod.month <= 9 and tod.month == tom.month:
        # create link for days 1-8 and month 1-9
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-0{tod.month}-{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-0{tod.month}-{tom.day}T07%3A55%3A00"
            return link

    if tod.day > 9 and tod.month >= 10 and tod.month == tom.month:
        # create link for days 1-8 and month 10,11,12
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-{tod.month}-{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-{tod.month}-{tom.day}T07%3A55%3A00"
            return link

    if tod.month <= 8 and tod.month != tom.month:
        # create link for last day of months 1-8
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-0{tod.month}-{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-0{tom.month}-0{tom.day}T07%3A55%3A00"
            return link
        
    if tod.month == 9 and tod.month != tom.month:
        # create link for last day of month 9
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-0{tod.month}-{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-{tom.month}-0{tom.day}T07%3A55%3A00"
            return link
        
    if (tod.month == 10 or tod.month == 11) and tod.month != tom.month:
        # create link for last day of month 10,11
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-{tod.month}-{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tod.year}-{tom.month}-0{tom.day}T07%3A55%3A00"
            return link
        
    if tod.year != tom.year:
        # create link for last day of the year
        def CBuddy():
            link = f"https://jastic.space/search?after_date={tod.year}-{tod.month}-{tod.day}T07%3A55%3A00&author=ChartBuddy&before_date={tom.year}-0{tom.month}-0{tom.day}T07%3A55%3A00"
            return link
        
    #runtime is calculated and printed
    tsubf = time.perf_counter()
  
    # calculate and save to csv file
    runtime = {tsubf-tsubi}    
    f = open('C:/PyProjects/tmp/if_test_random.csv', 'a', newline='')
    writer = csv.writer(f)
    writer.writerow(runtime)

>>>...>>>...>>>strftime lookup
import datetime
from datetime import timedelta
from datetime import date
import time
import shutil
import os
from os import rename
import webbrowser
import subprocess
from tkinter import Tk
import csv
from faker import Faker

# start range
for i in range(0, 10000):

    # start runtimer
    tsubi = time.perf_counter()

    #set dates for links and new folder
    today = date.today()
    tomorrow = today + timedelta(1)

    # open links to download and upload images if only I could get out of the way
    url1 = f"https://jastic.space/search?after_date={today.strftime("%Y")}-{today.strftime("%m")}-{today.strftime("%d")}T07%3A55%3A00&author=ChartBuddy&before_date={tomorrow.strftime("%Y")}-{tomorrow.strftime("%m")}-{tomorrow.strftime("%d")}T07%3A55%3A00"

    tsubf = time.perf_counter()
  
    # calculate and save to csv file
    runtime = {tsubf-tsubi}    
    f = open('C:/PyProjects/tmp/strftime_test.csv', 'a', newline='')
    writer = csv.writer(f)
    writer.writerow(runtime)

>>>...>>>...>>>strftime rand
import datetime
from datetime import timedelta
from datetime import date
import time
import shutil
import os
from os import rename
import webbrowser
import subprocess
from tkinter import Tk
import csv
from faker import Faker

# start range
for i in range(0, 10000):

    # start runtimer
    tsubi = time.perf_counter()

    # make fake datetime
    fake = Faker()
    today = fake.future_datetime('+50y', None)
    tomorrow = today + timedelta(days = 1)

    # open links to download and upload images if only I could get out of the way
    url1 = f"https://jastic.space/search?after_date={today.strftime("%Y")}-{today.strftime("%m")}-{today.strftime("%d")}T07%3A55%3A00&author=ChartBuddy&before_date={tomorrow.strftime("%Y")}-{tomorrow.strftime("%m")}-{tomorrow.strftime("%d")}T07%3A55%3A00"

    tsubf = time.perf_counter()
  
    # calculate and save to csv file
    runtime = {tsubf-tsubi}    
    f = open('C:/PyProjects/tmp/strftime_withR_test.csv', 'a', newline='')
    writer = csv.writer(f)
    writer.writerow(runtime)

Edit: fixed incorrect savefile in set date ifs, response, added another run of data, I must have messed something up with the first run, getting the identical results?  Still pretty close, though, the second run. I put everything into one code box.  I would like to check the code and rerun the tests, and try tables again.

legendary
Activity: 3290
Merit: 16489
Thick-Skinned Gang Leader and Golden Feather 2021
Wouldn't ImageMagick be easier to automate things than The GIMP?
full member
Activity: 114
Merit: 93
Fly free sweet Mango.
Last night was another crash and burn, but this one was again my fault.  What happened was that I first started learning with Anaconda and Jupyter, and when I started trying Visual Studio I couldn't import 'requests' like I could in Jupyter.  So after more research, I decided to start over with PowerShell 7 and VisualStudio and Python, not from the Microsoft store.  So I created new paths, but then forgot to update the code before runtime.  See, not my fault.  Smiley  All right.  Now we're having fun.  No more untested code, and more testing!

Storylog: 
1.Download No more link making using if statements, for now, more on that later.  I figured out how to use 'strftime' to format the days and months as always two digits, in a lot less lines.

2.Import 3.Export New path names.  Goal:  Start whole setup over after mastering virtual environments

5.Archive Daily runtimes are now being calculated using perf_counter and added to a csv file for later performance review.

Here is I  my production code for today:
Code:
from datetime import timedelta, date
import time
import shutil
import os
from os import rename
import webbrowser
import subprocess
from tkinter import Tk
import csv

# start runtimer
tsubi = time.perf_counter()

#set dates for links and new folder
today = date.today()
tomorrow = today + timedelta(1)

# open links to download and upload images if only I could get out of the way
url1 = f"https://jastic.space/search?after_date={today.strftime("%Y")}-{today.strftime("%m")}-{today.strftime("%d")}T07%3A55%3A00&author=ChartBuddy&before_date={tomorrow.strftime("%Y")}-{tomorrow.strftime("%m")}-{tomorrow.strftime("%d")}T07%3A55%3A00"
url2 = "https://mgur.com/upload"
url3 = "https://www.alkimg.com/"
webbrowser.open(url1)
webbrowser.open(url2)
webbrowser.open(url3)

# name newfolder with date
directory = f"{today.month}-{today.day}"
parent_dir = "C:/Users/Games/Downloads"
newf = os.path.join(parent_dir, directory)
os.mkdir(newf)
print("Directory '%s' created" %directory)

# learn to scrape 24 images 1 second at a time,
# else manually download each file

# automatically open gimp, then filter to load all images
subprocess.Popen([r'C:/Program Files/GIMP 2/bin/gimp-2.10.exe'])

# export big gif press the any key then enter
print("Is big gif exported?")
input()
print("Movin' on...")

# big gif is moved
src = "C:/PyProjects/tmp/"
dest = "C:/PyProjects/GMIP/2024/2-2024/"
shutil.move("C:/PyProjects/tmp/gif.gif", dest)
rename ("C:/PyProjects/GMIP/2024/2-2024/gif.gif", f"C:/PyProjects/GMIP/2024/2-2024/b{today.month}-{today.day}.gif")

# scale image and export little gif
print("Is little gif exported?")
input()
print("Movin' on...")

# little gif is moved
src = "C:/PyProjects/tmp/"
dest = "C:/PyProjects/GMIP/2024/2-2024/"
shutil.move("C:/PyProjects/tmp/gif.gif", dest)
rename ("C:/PyProjects/GMIP/2024/2-2024/gif.gif", f"C:/PyProjects/GMIP/2024/2-2024/{today.month}-{today.day}.gif")

# ID files
src = "C:/Users/Games/Downloads"
dest = "C:/Users/Games/Downloads/{}".format(directory)
files = os.listdir(src)
os.chdir(src)

# i have a dummy file present so new downloads look like download(*).png
# only move numbered png files
for file in files:
    if os.path.isfile(file):
        if file.endswith(").png"):
            shutil.move(file, dest) 

# upload to two sites, gather links to input into console
ibg = input("imgur big gif link here")
imgtalk = input("imgtalk little gif link here")

# add post to clipboard for btctalk
r = Tk()
r.withdraw()
r.clipboard_clear()
r.clipboard_append(f"ChartBuddy's 24 hour Wall Observation recap\n[url={ibg}].{imgtalk}.[/url]\nAll Credit to [url=https://bitcointalk.org/index.php?topic=178336.msg10084622#msg10084622]ChartBuddy[/url]")
r.update()

#this holds the post on the clipboard until posted
print("All done?")
input()

#runtime is calculated
tsubf = time.perf_counter()
runtime = {tsubf - tsubi}

# save to csv file
f = open('C:/PyProjects/runtimes.csv', 'a', newline='')
writer = csv.writer(f)
writer.writerow(runtime)

So what was I talking about earlier?  How using strftime uses a lot less lines as stringing the if statements together.  But after figuring out how to do runtimes, I figured we could do some science!

So I made 10000 links using following methods.   I figured out, finally, how to feed a fake date and run it through using mostly the following
Code:
# start range
for i in range(0, 10000):

    # start runtimer
    tsubi = time.perf_counter()

    # make fake datetime
    fake = Faker()
    tod = fake.future_datetime('+50y', None)
    tom = tod + timedelta(days = 1)
I'd love to share the rest if anyone wants them. So now I could get a sampling of dates that are going through various levels of if statements.  So here are the results:

if statements, with random date:  26.7698 ms per link created
strftime, with imported date: 0.0158472 ms per link created

Wow, total destruction for the if method.  Or is it?  We might need more data.

Hold on I'm going to go run this code, and then I'll post the runtime. 

Sweet the runtime was: crash and burn, okay, okay, but for real this time it was all my fault.  See, when you try to test your code you need dummy files to be moved around, and if those dummy files don't get deleted before the next run then python says, "Hey dummy, since your dummy files are there it would be quite rude of me to just copy over them so I'm going to set this bird down as gently as possible."  It would have worked, I know this because I did delete the dummy files, change the web addresses to avoid reloading those, re ran the script with the already downloaded files and away we went.  Let's see what that unofficial runtime was, well I also forget to click the last enter to stop the timer so it came out to 600.84 s.  Seems to be working though.   Sweet.  Till next time, same python time, same python channel.

Pages:
Jump to: