annotate pixivimageposter.py @ 133:0d8eabdd12ab default tip

create: write H:MM:SS timestamps, add option to fill with gaussian-blur instead of black many albums are longer than one hour so writing H:MM:SS is a necessity. if anything there will just be verbose info that isn't important for my use-case. however the gaussian-blur is simply broken. It works, and it plays locally just fine, but YouTube in particular elongates the video to fit the full width. I'm not entirely sure why it does this, but it makes it useless and ugly.
author Paper <paper@tflc.us>
date Sat, 03 Jan 2026 20:25:38 -0500
parents 2aa9614cb39a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
40
Paper <mrpapersonic@gmail.com>
parents: 24
diff changeset
1 import glob
Paper <mrpapersonic@gmail.com>
parents: 24
diff changeset
2 import random
Paper <mrpapersonic@gmail.com>
parents: 24
diff changeset
3 import discord
22
9782a1f6c1a6 Update and rename randomimageposter.py to pixivimageposter.py
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
4 from discord.ext import commands
9782a1f6c1a6 Update and rename randomimageposter.py to pixivimageposter.py
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
5
24
7eccf59ddec0 Update pixivimageposter.py
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 22
diff changeset
6 help_command = commands.DefaultHelpCommand(no_category="Commands")
40
Paper <mrpapersonic@gmail.com>
parents: 24
diff changeset
7 client = commands.Bot(command_prefix='!!', help_command=help_command)
Paper <mrpapersonic@gmail.com>
parents: 24
diff changeset
8
22
9782a1f6c1a6 Update and rename randomimageposter.py to pixivimageposter.py
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
9
9782a1f6c1a6 Update and rename randomimageposter.py to pixivimageposter.py
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
10 @client.event
9782a1f6c1a6 Update and rename randomimageposter.py to pixivimageposter.py
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
11 async def on_ready():
9782a1f6c1a6 Update and rename randomimageposter.py to pixivimageposter.py
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
12 print("Ready!")
9782a1f6c1a6 Update and rename randomimageposter.py to pixivimageposter.py
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
13
40
Paper <mrpapersonic@gmail.com>
parents: 24
diff changeset
14
Paper <mrpapersonic@gmail.com>
parents: 24
diff changeset
15 @client.command(help="Posts a random image from my pixiv bookmarks")
22
9782a1f6c1a6 Update and rename randomimageposter.py to pixivimageposter.py
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
16 async def pixiv(ctx):
9782a1f6c1a6 Update and rename randomimageposter.py to pixivimageposter.py
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
17 files = glob.glob("*.png")
9782a1f6c1a6 Update and rename randomimageposter.py to pixivimageposter.py
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
18 files.extend(glob.glob("*.jpg"))
9782a1f6c1a6 Update and rename randomimageposter.py to pixivimageposter.py
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
19 files.extend(glob.glob("*.gif"))
9782a1f6c1a6 Update and rename randomimageposter.py to pixivimageposter.py
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
20 file = random.choice(files)
9782a1f6c1a6 Update and rename randomimageposter.py to pixivimageposter.py
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
21 '''
9782a1f6c1a6 Update and rename randomimageposter.py to pixivimageposter.py
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
22 filenames are the default to pixivutil2, being
9782a1f6c1a6 Update and rename randomimageposter.py to pixivimageposter.py
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
23 "(id)_p(imgnumber) - (title).(ext)"
9782a1f6c1a6 Update and rename randomimageposter.py to pixivimageposter.py
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
24
40
Paper <mrpapersonic@gmail.com>
parents: 24
diff changeset
25 link1 takes "file" and splits it with the character "_",
Paper <mrpapersonic@gmail.com>
parents: 24
diff changeset
26 giving you the id and the rest of the file
22
9782a1f6c1a6 Update and rename randomimageposter.py to pixivimageposter.py
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
27
40
Paper <mrpapersonic@gmail.com>
parents: 24
diff changeset
28 link2 takes the rest of the file and splits it with a space,
Paper <mrpapersonic@gmail.com>
parents: 24
diff changeset
29 giving you the image number and other stuff we don't need
Paper <mrpapersonic@gmail.com>
parents: 24
diff changeset
30 it then removes "p" which just gets in the way, converts it to an integer,
Paper <mrpapersonic@gmail.com>
parents: 24
diff changeset
31 and adds 1 to it because pixivutil2 uses an initial zero in numbering
22
9782a1f6c1a6 Update and rename randomimageposter.py to pixivimageposter.py
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
32 '''
9782a1f6c1a6 Update and rename randomimageposter.py to pixivimageposter.py
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
33 link1 = file.split("_", 1)[0]
24
7eccf59ddec0 Update pixivimageposter.py
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents: 22
diff changeset
34 link2 = int(file.split("_", 1)[1].split(" ", 1)[0].replace('p', ''))+1
40
Paper <mrpapersonic@gmail.com>
parents: 24
diff changeset
35 await ctx.send(f"https://pixiv.net/member_illust.php?mode=medium&illust_id={link1}, Image {str(link2)}", file=discord.File(file))
22
9782a1f6c1a6 Update and rename randomimageposter.py to pixivimageposter.py
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
36
9782a1f6c1a6 Update and rename randomimageposter.py to pixivimageposter.py
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
37 client.run("token")