Initial commit

This commit is contained in:
2025-11-14 22:47:27 +00:00
commit 5a842158ad
50 changed files with 124762 additions and 0 deletions

29
connect_recipt.sh Executable file
View File

@@ -0,0 +1,29 @@
#!/bin/bash
# Try to find the USB Ethernet interface first
iface=$(ip -o link | awk -F': ' '/enx|enp.*u/{print $2}' | head -n 1)
# If no USB interface, fall back to eth0
if [ -z "$iface" ]; then
if ip link show eth0 &>/dev/null; then
iface="eth0"
echo "USB Ethernet not found. Using eth0."
else
echo "No suitable interface found."
exit 1
fi
else
echo "Using USB Ethernet interface: $iface"
fi
# Assign IP address (only for USB interface, skip eth0)
# if [[ $iface != "eth0" ]]; then
sudo ip addr add 192.168.192.10/24 dev "$iface" 2>/dev/null
# fi
# Bring interface up
sudo ip link set "$iface" up
# Scan port 9100 on the printer IP
nmap -p 9100 192.168.192.168

BIN
img/1757899906726394.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

BIN
img/1759866726084916.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

BIN
img/1759871018174885.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
img/1759877702701841.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 KiB

BIN
img/1759898979208952.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

BIN
img/1759903848622439.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 394 KiB

BIN
img/1759991007175624.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 292 KiB

BIN
img/1760351635793913.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 KiB

BIN
img/1760552816903909.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

BIN
img/1760563998153343.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 KiB

BIN
img/1760576399526129.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

BIN
img/1760576966573739.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 KiB

BIN
img/1760584855516694.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1022 KiB

BIN
img/1760590042040521.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
img/1760598404602842.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB

BIN
img/1760604817867211.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
img/1760607303101008.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

BIN
img/1760621651572028.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 KiB

BIN
img/1760621823010108.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 KiB

BIN
img/IMG_3391.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 KiB

BIN
img/IMG_3392.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 KiB

BIN
img/IMG_3393.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 KiB

BIN
img/screenshot-004226ce.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
img/screenshot-004226ce.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
img/screenshot-81127714.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

BIN
img/screenshot-9b84483a.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 705 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 491 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

124456
junk/t8.shakespeare.txt Normal file

File diff suppressed because it is too large Load Diff

36
junk/test.py Normal file
View File

@@ -0,0 +1,36 @@
from escpos.printer import Network
from PIL import Image
import os
def resize_image_to_fullwidth(img_src_name, target_width=580):
# Open the image
img = Image.open(img_src_name)
# Get original dimensions
width, height = img.size
# Calculate new height to maintain aspect ratio
aspect_ratio = height / width
new_height = int(target_width * aspect_ratio)
# Resize the image
resized_img = img.resize((target_width, new_height), Image.LANCZOS)
# Save the resized image
name, ext = os.path.splitext(img_src_name)
# Build destination filename
dest_name = f"{name}_fullwidth{ext}"
resized_img.save(dest_name)
return dest_name
# Replace with your printer's IP address and port
p = Network("192.168.192.168", port=9100)
# Example printing
# p.set_with_default(align='center', font='a', bold=False, width=2, height=2, custom_size=True, smooth=True)
p.textln("Thanks babes")
img_names = ["img/1754661985256965s.jpg", "img/1754658917785283.png"]
img_name = resize_image_to_fullwidth(img_names[1])
p.image(img_name, impl='graphics');
# p.image("img/" + img_names[1], impl='bitImageColumn', center=True, high_density_horizontal=False, high_density_vertical=False);
p.cut()

241
receipt.py Executable file
View File

@@ -0,0 +1,241 @@
#!/usr/bin/env python3
from escpos import *
from PIL import Image
import os
import subprocess
import time
import random
import requests
from urllib.parse import quote
OBJECT_WORDS = [
# Household
"chair", "table", "bed", "sofa", "lamp", "mirror", "clock", "rug", "curtain", "pillow",
"blanket", "mattress", "dresser", "cabinet", "cushion", "towel", "toothbrush", "toothpaste", "soap", "shampoo",
"conditioner", "bathtub", "shower", "toilet", "sink", "faucet", "bucket", "broom", "mop", "vacuum",
# Kitchen
"fridge", "freezer", "microwave", "oven", "stove", "pan", "pot", "plate", "bowl", "cup",
"mug", "glass", "spoon", "fork", "knife", "ladle", "whisk", "tongs", "grater", "peeler",
"blender", "toaster", "kettle", "cutting board", "napkin", "coaster", "measuring cup", "measuring spoon", "dishwasher", "tray",
# Office/School
"desk", "chair", "notebook", "pen", "pencil", "marker", "eraser", "ruler", "calculator", "scissors",
"glue", "paper", "folder", "binder", "clip", "tape", "stapler", "staples", "highlighter", "whiteboard",
"projector", "laptop", "computer", "mouse", "keyboard", "monitor", "printer", "cable", "router", "charger",
# Personal items
"wallet", "phone", "watch", "glasses", "sunglasses", "hat", "jacket", "scarf", "shirt", "pants",
"shorts", "shoes", "socks", "belt", "bag", "backpack", "suitcase", "umbrella", "key", "keychain",
"comb", "brush", "mirror", "lotion", "perfume", "deodorant", "nail clipper", "razor", "makeup", "lipstick",
# Electronics
"TV", "remote", "camera", "tripod", "microphone", "speaker", "headphones", "battery", "lightbulb", "fan",
"heater", "air conditioner", "thermostat", "game console", "joystick", "tablet", "smartwatch", "flash drive", "hard drive", "drone",
# Tools
"hammer", "screwdriver", "wrench", "pliers", "saw", "drill", "nail", "screw", "bolt", "nut",
"tape measure", "level", "chisel", "axe", "shovel", "ladder", "toolbox", "work gloves", "flashlight", "crowbar",
# Art/music
"paintbrush", "canvas", "palette", "easel", "crayon", "chalk", "charcoal", "ink", "violin", "guitar",
"piano", "flute", "drum", "trumpet", "microphone", "amp", "sheet music", "metronome", "pick", "tuner",
# Toys/Games
"ball", "doll", "puzzle", "board game", "card", "dice", "yo-yo", "kite", "teddy bear", "lego",
"action figure", "marble", "slingshot", "skateboard", "bike", "helmet", "scooter", "trampoline", "swing", "slide",
# Nature-related
"rock", "stick", "leaf", "flower", "tree", "shell", "feather", "pinecone", "sand", "mud",
"log", "acorn", "fruit", "apple", "banana", "orange", "grape", "pear", "mango", "watermelon",
# Misc
"trophy", "medal", "flag", "banner", "map", "globe", "calendar", "watch", "ticket", "passport",
"ID card", "coin", "bill", "envelope", "stamp", "basket", "box", "crate", "bin", "jar",
"bottle", "can", "barrel", "hose", "funnel", "net", "rope", "chain", "hook", "magnet",
# Vehicles/Transport
"car", "truck", "bus", "bicycle", "motorcycle", "train", "plane", "boat", "ship", "scooter",
"skates", "wheel", "engine", "mirror", "seatbelt", "tire", "pedal", "horn", "trunk", "helmet"
# Mammals
"dog", "cat", "horse", "cow", "pig", "goat", "sheep", "lion", "tiger", "elephant",
"monkey", "chimpanzee", "gorilla", "deer", "moose", "bear", "wolf", "fox", "rabbit", "kangaroo",
"rat", "mouse", "squirrel", "bat", "zebra", "giraffe", "leopard", "cheetah", "panther", "raccoon",
"otter", "hedgehog", "sloth", "armadillo", "koala", "beaver", "buffalo", "bison", "donkey", "reindeer",
# Birds
"sparrow", "pigeon", "crow", "eagle", "hawk", "falcon", "owl", "duck", "goose", "swan",
"penguin", "parrot", "canary", "flamingo", "peacock", "chicken", "rooster", "turkey", "vulture", "woodpecker",
"heron", "ostrich", "emu", "seagull", "albatross", "dove", "crane", "bluejay", "hummingbird", "toucan",
# Reptiles & Amphibians
"snake", "lizard", "crocodile", "alligator", "gecko", "iguana", "chameleon", "turtle", "tortoise", "frog",
"toad", "salamander", "newt", "python", "cobra", "viper", "anole", "skink", "monitor", "komodo dragon",
# Fish & Aquatic Creatures
"shark", "dolphin", "whale", "seal", "sea lion", "otter", "octopus", "squid", "jellyfish", "crab",
"lobster", "clam", "oyster", "starfish", "eel", "ray", "anchovy", "tuna", "salmon", "trout",
"bass", "catfish", "swordfish", "marlin", "anglerfish", "pufferfish", "seahorse", "guppy", "goldfish", "betta",
# Insects & Arachnids
"ant", "bee", "wasp", "hornet", "butterfly", "moth", "fly", "mosquito", "dragonfly", "grasshopper",
"cricket", "ladybug", "beetle", "firefly", "termite", "cockroach", "aphid", "spider", "scorpion", "tick",
# Farm & Domestic Animals
"cow", "horse", "pig", "goat", "sheep", "chicken", "dog", "cat", "duck", "goose",
"donkey", "rabbit", "llama", "alpaca", "turkey", "ox", "rooster", "hen", "ferret", "guinea pig",
# Jungle/Wild Animals
"tiger", "lion", "panther", "leopard", "jaguar", "monkey", "gorilla", "chimpanzee", "elephant", "rhino",
"hippopotamus", "giraffe", "zebra", "hyena", "baboon", "okapi", "aardvark", "warthog", "capybara", "tapir",
# Arctic/Antarctic Animals
"polar bear", "walrus", "seal", "penguin", "orca", "narwhal", "snowy owl", "arctic fox", "caribou", "musk ox",
# Desert Animals
"camel", "fennec fox", "meerkat", "jerboa", "scorpion", "gila monster", "horned lizard", "kudu", "oryx", "roadrunner",
]
# Return T20II printer
def get_T20II_usb():
p = printer.Usb(0x04b8, 0x0202) #, profile="TM-T20II")
# p.set_with_default(align='center', font='a', bold=False, width=2, height=2, custom_size=True, smooth=True)
return p
def get_T20II_ethernet():
p = printer.Network("192.168.192.168", port=9100)#, profile="TM-T20II")
# p.set_with_default(align='center', font='a', bold=False, width=2, height=2, custom_size=True, smooth=True)
return p
def resize_image_to_fullwidth(img_src_name, target_width=576):
# Make fullwidth dir
os.makedirs('img_fullwidth', exist_ok=True)
# Open the image
img = Image.open(img_src_name)
# Get original dimensions
width, height = img.size
# Calculate new height to maintain aspect ratio
aspect_ratio = height / width
new_height = int(target_width * aspect_ratio)
# Resize the image
resized_img = img.resize((target_width, new_height), Image.LANCZOS)
# Save the resized image
name, ext = os.path.splitext(img_src_name)
filename_no_ext = os.path.splitext(os.path.basename(img_src_name))[0]
# Build destination filename
dest_name = f"img_fullwidth/{filename_no_ext}_fullwidth{ext}"
resized_img.save(dest_name)
return dest_name
import os
import requests
import random
def get_random_bant_image():
# Create img directory if it doesn't exist
os.makedirs('img', exist_ok=True)
# Fetch the catalog JSON for /bant/
url = "https://a.4cdn.org/bant/catalog.json"
response = requests.get(url)
response.raise_for_status()
catalog = response.json()
# Flatten the list of threads from all pages
threads = [thread for page in catalog for thread in page['threads']]
# Filter threads that have images (tim and ext fields)
image_threads = [
thread for thread in threads
if 'tim' in thread and 'ext' in thread and thread['ext'].lower() not in ['.gif', '.mp4', '.webm']
]
if not image_threads:
return None # No images found
# Choose a random thread with an image
thread = random.choice(image_threads)
# Construct image URL
image_url = f"https://i.4cdn.org/bant/{thread['tim']}{thread['ext']}"
filename = f"img/{thread['tim']}{thread['ext']}"
# Download and save image
img_response = requests.get(image_url)
img_response.raise_for_status()
with open(filename, 'wb') as f:
f.write(img_response.content)
return filename
def print_random_bant_image(p, sh_file):
img = get_random_bant_image()
filename_no_ext = os.path.splitext(os.path.basename(img))[0]
p.textln(filename_no_ext)
fimg = resize_image_to_fullwidth(img)
try:
p.image(fimg, impl='bitImageColumn');
except:
subprocess.run(["bash", sh_file], check=True)
p = get_T20II_ethernet()
p.cut()
def main():
script_dir = os.path.dirname(os.path.abspath(__file__))
sh_file = os.path.join(script_dir, "connect_recipt.sh")
subprocess.run(["bash", sh_file], check=True)
p = get_T20II_ethernet()
print_random_bant_image(p, sh_file)
return
if __name__ == "__main__":
main()
def fun(p, sh_file):
#img = "screenshot-81127714.png"
#img = "screenshot-004226ce.jpg"
#img = "screenshot-004226ce.png"
#img = "screenshot-9b84483a.jpg"
#fimg = resize_image_to_fullwidth(img)
#p.image(fimg, impl='bitImageColumn');
#p.cut()
# p = get_T20II_usb()
# p.cut()
# img = "IMG_3392.jpg"
# fimg = resize_image_to_fullwidth(img)
# try:
# p.image(fimg, impl='bitImageColumn');
# except:
# subprocess.run(["bash", sh_file], check=True)
# p = get_T20II_usb()
# p.cut()
# img = "img_fullwidth/1752696013663080_fullwidth.png"
# fimg = resize_image_to_fullwidth(img)
# try:
# p.image(fimg, impl='bitImageColumn');
# except:
# subprocess.run(["bash", sh_file], check=True)
# p = get_T20II_usb()
# p.cut()
# img = "PHOTO-2025-08-21-13-21-47.jpg"
# fimg = resize_image_to_fullwidth(img)
# try:
# p.image(img, impl='graphics');
# except:
# subprocess.run(["bash", sh_file], check=True)
# p = get_T20II_usb()
# p.cut()
return 0;