this post was submitted on 22 Feb 2024
23 points (96.0% liked)

Linux

8095 readers
39 users here now

Welcome to c/linux!

Welcome to our thriving Linux community! Whether you're a seasoned Linux enthusiast or just starting your journey, we're excited to have you here. Explore, learn, and collaborate with like-minded individuals who share a passion for open-source software and the endless possibilities it offers. Together, let's dive into the world of Linux and embrace the power of freedom, customization, and innovation. Enjoy your stay and feel free to join the vibrant discussions that await you!

Rules:

  1. Stay on topic: Posts and discussions should be related to Linux, open source software, and related technologies.

  2. Be respectful: Treat fellow community members with respect and courtesy.

  3. Quality over quantity: Share informative and thought-provoking content.

  4. No spam or self-promotion: Avoid excessive self-promotion or spamming.

  5. No NSFW adult content

  6. Follow general lemmy guidelines.

founded 1 year ago
MODERATORS
 

I make a lot of OC videos to post here on Lemmy. I'm on Nobara, which is currently on Fedora 39. I'm like an intermediate Linux user and mostly have experience with Debian. All of that being said, I'm up at odd hours.

If someone can help me figure out how to make a script to post a video to Lemmy when people are actually awake, that would be fantastic. It could be a lot, I know. I have no idea how to start here. It'd likely need a giant script, and API access along with possible sudo permissions.

I haven't been a developer since ~2002 and even then it was only Java web stuff. So, while I might understand things with some guidance I can no longer really get things like this running by myself.

If anyone has info or guidance on how to get this done, I would greatly appreciate it. I'm trying to get automatic uploads to at least catbox.moe, and if possible YouTube (though I know that is unlikely).

I know this is an odd one, but I know you all (if anyone) have the technical set to help me out here. I'll answer any questions I can!

top 22 comments
sorted by: hot top controversial new old
[–] [email protected] 4 points 8 months ago (1 children)

sounds like a fun challenge. My thought process is the control flow. To that end:

  1. script runs

handled by cron

  1. Script selects files to upload, community to upload to and titles for them.

These are the hardest parts, because it will be the only variable parts. It basically requires user input. I'm thinking perhaps parsing a text file where you input the file name, the community, and the title.

  1. Script authenticates with lemmy API

I found this really handy "unofficial" API documentation, which includes examples in many different languages, through the official docs.

Unfortunately, it looks like it's going to require a hardcoded password to get the appropriate authorization token.

  1. script posts to lemmy

We can use the api documentation above to figure out this part too


For other sites like youtube, you can expand on this script and have parts for youtube as well, but you're basically doubling its size and complexity. Personally, I would go for the KISS method instead and just have a separate script & info file.

After work today, I'll see if I can slam out a quick proof of concept in Python

[–] [email protected] 2 points 8 months ago (2 children)

@[email protected]

here's the script

I wasn't able to implement catbox nor youtube uploads for a few reasons:

  1. neither are FOSS services, and I sneer at those in my moral superiority (disregard the above usage of github)
  2. I'm lazy
  3. This script isn't for me and I will likely never use it
  4. I've already spent over 2 hours on this
  5. catbox.moe is a small site, with little-to-no API documentation. I didn't want to hammer them with 100 API POST requests with blank files while I test the script and figure out their API through trial and error
  6. youtube requires an API key via oauth... I really don't have time to work that fustercluck out

I left in some helpful comments anyway.

All in all a fun exercise that brought me and lemmy closer together, and that's what really matters. Turns out the real API docs were the friends we made along the way

[–] [email protected] 2 points 8 months ago (1 children)

I got this script to work! Yeah, I apologize for the lack of FOSS hosting for videos specifically, but there really aren't great options out there unless I run and maintain my own PeerTube instance, which I'm not prepared to do technically or financially. I managed to get it working, so I really thank you for the hours of work you put in! I was able to do two test posts that worked well once I had oauth stuff sorted.

[–] [email protected] 1 points 8 months ago

That's great news! I hope my contributions didn't require major overhauls on your part, and I'd love to see the end result (scrubbed of any private info of course) if you care to share.

No worries about the FOSS stuff, I was just fishing for excuses to absolve myself of guilt for not finishing it 😬

[–] [email protected] 2 points 8 months ago

I really do appreciate the effort! I will take a look at this when I'm next able.

[–] [email protected] 3 points 8 months ago (1 children)

I could possibly help you with all this. If you wanna DM me, we can set up time to work on this.

[–] [email protected] 2 points 8 months ago

!https://lemmy.sdf.org/post/12609431

[–] [email protected] 3 points 8 months ago (2 children)

Out of interest, why do the videos need to be posted at a specific time? As the world rotates, different people are awake all the time. Are they specific to your local area?

[–] [email protected] 5 points 8 months ago (1 children)

The land, and thus the population of the earth aren't distrubuted equally across the globe. This causes a day-night cycle for online communities, despite being international, just due to the fact that the majority of humans live somewhat close together on a global scale.

[–] [email protected] 1 points 8 months ago* (last edited 8 months ago) (1 children)

That's true, I hadn't thought of that. So the optimal time to get the most people waking up to your content is about 01:30 UTC for India waking up from 7am (UTC+5:30), or 23:00 UTC for China at UTC+8!

https://distributionofthings.com/world-population-by-time-zone/

[–] [email protected] 1 points 8 months ago (1 children)

If there really is an equal distribution of users across the globe, yes. But you also need to consider that most users here are probably from Europe or north america, but I'm not sure about that.

[–] [email protected] 1 points 8 months ago (1 children)

Yeah, and there's no way to know.

[–] [email protected] 1 points 8 months ago

Not without asking all instances to pile together the IPs that access them, I suppose. But there are ways to make educated guesses, like using polls and interpolating that data.

[–] [email protected] 4 points 8 months ago

It is entirely me wanting people to see them. Many sort by new, hot, top x hours etc. I'd just like to make people happy by posting stuff at an optimized time.

[–] [email protected] 2 points 8 months ago (1 children)

This Lemmy community has a great set of intro Linux lessons to get you started:

https://programming.dev/c/linuxupskillchallenge

The scheduling command for a one-time future run is the "at" command.

[–] [email protected] 1 points 8 months ago

Hi there! Looks like you linked to a Lemmy community using a URL instead of its name, which doesn't work well for people on different instances. Try fixing it like this: [email protected]

[–] [email protected] 2 points 8 months ago

If you can figure out some way to upload it to your desired destination and get a link to it, maybe this bot can help you post on lemmy at a specific time of the week/day.

[–] [email protected] 2 points 8 months ago

I've actually fully automated my uploads to youtube. It's been over 10 years since I set it up, but I can tell you I use youtube_upload from pip and I'm pretty sure I had to make an app password. I wrote a little bash script to make sure it's only done in the middle of the night. I'm not a dev either so if my dumb ass can figure it out, I'm sure you can too :)

[–] [email protected] 2 points 8 months ago

There's probably something than can be done with a curl command through the API.

[–] [email protected] 0 points 8 months ago (1 children)

Have you tried leveraging a LLM ai with prompts matching your needs? I've heard it can be quite effective, especially for someone with some programming background. E.g. "write me a python script that..."

[–] [email protected] 2 points 8 months ago (1 children)

Said LLM would need to know how to use the Lemmy API. And none of them do.

[–] [email protected] 1 points 8 months ago

Unless it used something applicable in its training maybe?