A python client for memobird printer
Python 3.4+
pip install pymobird
from pymobird import SimplePymobird
# init client
bird = SimplePymobird(ak='your_memobird_ak', device_id='your_device_id_by_press_twice')
# print text
bird.print_text("hello pymobird!")
# print image
image_file_path = "./Hello.jpg"
bird.print_image(image_file)
# or
image_fp = open("./hello.jpg")
bird.print_image(image_fp)
image.close()
# print html by url
bird.print_url("http://example.com/a.html")
# print multi part content
from pymobird import Content
content = Content()
content.add_image(image_fp)
content.add_text("test text")
bird.print_multi_part_content(content)
# check content print status
content_id = bird.print_text("hello pymobird!") # print and get content_id
# wait one second, then
is_printed = bird.check_printed(content_id)
print(is_printed)
# "offline usage" consists in sending the data directly
# to the printer:
#
# scenario 1:
# - connect your computer to the printer local wifi
#
# NOTE: when you connect via to the printer local
# wifi, this should be the printer default IP:
# default_offline_printer_ip = "192.168.10.1"
#
# scenario 2:
# - you already have your printer connected to your local
# network. find the right printer ip address and pass it
# to the SimpleOfflinePymobird instance:
#
# NOTE:
# * bird.check_printed()
# this method won't work with SimpleOfflinePymobird.
#
# * the "content_id" for SimpleOfflinePymobird is simply a timestamp
# of when the content was sent.
from pymobird import SimpleOfflinePymobird
bird = SimpleOfflinePymobird(ip=default_offline_printer_ip)
image_file_path = "./image.jpg"
bird.print_image(image_file_path)
content = Content()
content.add_image(image_file_path)
content.add_text("test text")
bird.print_multi_part_content(content)
Besides, using Pymobird
class directly for advanced usage.