laggykiller / sticker-convert

Convert (animated) stickers to/from WhatsApp, Telegram, Signal, Line, Kakao, Viber, Discord, iMessage. Written in Python.
GNU General Public License v2.0
283 stars 16 forks source link

Colab Error #153

Closed carmenchui closed 5 months ago

carmenchui commented 5 months ago

Line Sticker: 30629 https://store.line.me/stickershop/product/30629/en?utm_source=gnsh_stickerDetail

Getting the following error:

##### EXCEPTION #####
Function: <function DownloadLine.start at 0x7ca574b79d00>
Arguments: ['30629', PosixPath('/content/drive/MyDrive/stickers_input'), 'CredOption(REDACTED)']
Traceback (most recent call last):
  File "/tmp/.mount_stickeXSv4GN/usr/src/sticker_convert/job.py", line 119, in worker
    results = work_func(*work_args, cb_queue, cb_return)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/.mount_stickeXSv4GN/usr/src/sticker_convert/downloaders/download_line.py", line 472, in start
    return downloader.download_stickers_line()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/.mount_stickeXSv4GN/usr/src/sticker_convert/downloaders/download_line.py", line 458, in download_stickers_line
    self.download_multiple_files(custom_sticker_text_urls, headers=self.headers)
  File "/tmp/.mount_stickeXSv4GN/usr/src/sticker_convert/downloaders/download_base.py", line 32, in download_multiple_files
    anyio.run(self.download_multiple_files_async, targets, retries, **kwargs)
TypeError: run() got an unexpected keyword argument 'headers'
#####################
laggykiller commented 5 months ago

Please retry now

carmenchui commented 5 months ago

@laggykiller It is stuck on "Compressing" and has not moved for a few minutes:

SCR-20240522-nxyp-2
laggykiller commented 5 months ago

What compression settings are you using?

carmenchui commented 5 months ago

I am using "auto".. I usually do not adjust the compression settings when I use the Colab notebook.

laggykiller commented 5 months ago

What other settings did you set? Are you exporting to Signal (Which is default on colab)?

I cannot reproduce the problem you are facing on my side...

carmenchui commented 5 months ago

Exporting to WhatsApp and it's stuck with compressing; I use the default presets and only just change the input type (line) and output (.wastickers).

SCR-20240522-spwh

SCR-20240522-spyz

It gets stuck on compressing and doesn't stop at any point until the host runtime times out.

Runtime: SCR-20240522-srmv

Input:

#@title 4. Fill in your options and run { display-mode: "form" }
import subprocess
from typing import Any, List

%cd /content

#@markdown # Input
#@markdown ### Input source
input_option = "Download from Line" #@param ["Download (Auto detect)", "Download from Signal", "Download from Telegram", "Download from Line", "Download from Kakao", "Download from Viber", "From Google Drive directory"]
#@markdown ### Input URL (If applicable)
input_url = "30629" #@param {type:"string"}
#@markdown ### Input directory
input_dir = "/content/drive/MyDrive/stickers_input" #@param {type:"string"}
#@markdown ---

#@markdown # Compression options
#@markdown ## Preset
compression_preset = "auto" #@param ["auto", "signal", "telegram", "telegram_emoji", "whatsapp", "line", "kakao", "viber", "imessage_small", "imessage_medium", "imessage_large", "custom"]
#@markdown ## No compression
no_compression = False #@param {type:"boolean"}
#@markdown ## *Use below for overriding preset*
#@markdown ### Output FPS (Minimum)
fps_min = -1 #@param {type:"integer"}
#@markdown ### Output FPS (Maximum)
fps_max = -1 #@param {type:"integer"}
#@markdown ### Output resolution (Width) (Minimum)
res_w_min = -1 #@param {type:"integer"}
#@markdown ### Output resolution (Width) (Maximum)
res_w_max = -1 #@param {type:"integer"}
#@markdown ### Output resolution (Height) (Minimum)
res_h_min = -1 #@param {type:"integer"}
#@markdown ### Output resolution (Height) (Maximum)
res_h_max = -1 #@param {type:"integer"}
#@markdown ### Output quality (0-100) (Minimum)
quality_min = -1 #@param {type:"integer"}
#@markdown ### Output quality (0-100) (Maximum)
quality_max = -1 #@param {type:"integer"}
#@markdown ### Colors (0-256) [png/apng only] (Minimum)
color_min = -1 #@param {type:"integer"}
#@markdown ### Colors (0-256) [png/apng only] (Maximum)
color_max = -1 #@param {type:"integer"}
#@markdown ### Duration (Miliseconds) (Minimum)
duration_min = -1 #@param {type:"integer"}
#@markdown ### Duration (Miliseconds) (Maximum)
duration_max = -1 #@param {type:"integer"}
#@markdown ### Background color
bg_color = "" #@param {type:"string"}
#@markdown ### Maximum file size (bytes) (Static)
img_size_max = -1 #@param {type:"integer"}
#@markdown ### Maximum file size (bytes) (Animated)
vid_size_max = -1 #@param {type:"integer"}
#@markdown ### File format (Static)
img_format = "" #@param {type:"string"}
#@markdown ### File format (Animated)
vid_format = "" #@param {type:"string"}
#@markdown ### Power ("Importance") of FPS (At least -1. Power lower = More importance)
fps_power = 0.0 #@param {type:"number"}
#@markdown ### Power ("Importance") of resolution (At least -1. Power lower = More importance)
res_power = 0.0 #@param {type:"number"}
#@markdown ### Power ("Importance") of quality (At least -1. Power lower = More importance)
quality_power = 0.0 #@param {type:"number"}
#@markdown ### Power ("Importance") of color (At least -1. Power lower = More importance)
color_power = 0.0 #@param {type:"number"}
#@markdown ### Percentage of space used as padding
padding_percent = 0 #@param {type:"integer"}
#@markdown ## Convert (faking) image to video
fake_vid = True #@param {type:"boolean"}
#@markdown ## Set scale filter (nearest, bilinear, bicubic, lanczos)
scale_filter = "bicubic" #@param ["nearest", "box", "bilinear", "hamming", "bicubic", "lanczos"]
#@markdown ## Set method for quantizing image (imagequant, fastoctree, none)
quantize_method = "imagequant" #@param ["imagequant", "fastoctree", "none"]
#@markdown ### Default emoji
default_emoji = "" #@param {type:"string"}
#@markdown ### Number of steps (Higher = Slower but closer to target size)
steps = -1 #@param {type:"integer"}
#@markdown ### Number of processses (Higher = Compress faster but consume more resources)
processes = -1 #@param {type:"integer"}
#@markdown ---

#@markdown # Output
#@markdown ### Output options
output_option = "Compress to .wastickers (WhatsApp)" #@param ["Upload to Telegram", "Upload to Telegram (Custom emoji)", "Upload to Signal", "Compress to .wastickers (WhatsApp)", "Create Xcode project (iMessage)", "Save to Google Drive directory only"]
#@markdown ### Output directory
output_dir = "/content/drive/MyDrive/stickers_output" #@param {type:"string"}
#@markdown ### Title
title = "LINE FRIENDS Stickers for Arranging" #@param {type:"string"}
#@markdown ### Author
author = "LINE FRIENDS Stickers for Arranging" #@param {type:"string"}
#@markdown ---

#@markdown # Credentials
#@markdown ### Signal uuid
signal_uuid = "" #@param {type:"string"}
#@markdown ### Signal password
signal_password = "" #@param {type:"string"}
#@markdown ### Telegram token
telegram_token = "" #@param {type:"string"}
#@markdown ### Telegram user_id
telegram_userid = "" #@param {type:"string"}
#@markdown ### Kakao auth_token
kakao_auth_token = "" #@param {type:"string"}
#@markdown ### Kakao generate auth_token
kakao_gen_auth_token = False #@param {type:"boolean"}
#@markdown ### Kakao username (For generating auth_token)
kakao_username = "" #@param {type:"string"}
#@markdown ### Kakao password (For generating auth_token)
kakao_password = "" #@param {type:"string"}
#@markdown ### Kakao country code (For generating auth_token)
kakao_country_code = "" #@param {type:"string"}
#@markdown ### Kakao phone number (For generating auth_token)
kakao_phone_number = "" #@param {type:"string"}

params: List[Any] = []

if input_dir != "": # type: ignore
  params.append("--input-dir")
  params.append(input_dir)

if input_option == "Download (Auto detect)":
  params.append("--download-auto")
  params.append(input_url)
elif input_option == "Download from Signal":
  params.append("--download-signal")
  params.append(input_url)
elif input_option == "Download from Telegram":
  params.append("--download-telegram")
  params.append(input_url)
  if telegram_token == "":
    print("ERROR: Telegram token required for uploading and downloading telegram stickers")
    exit()
elif input_option == "Download from Line":
  params.append("--download-line")
  params.append(input_url)
elif input_option == "Download from Kakao":
  params.append("--download-kakao")
  params.append(input_url)
elif input_option == "Download from Viber":
  params.append("--download-viber")
  params.append(input_url)

if output_dir != "": # type: ignore
  params.append("--output-dir")
  params.append(output_dir)

if output_option == "Upload to Telegram": # type: ignore
  params.append("--export-telegram")
  if telegram_token == "":
    print("ERROR: Telegram token required for uploading and downloading telegram stickers")
    exit()
  if telegram_userid == "":
    print("ERROR: Telegram user_id required for uploading telegram stickers")
    exit()
elif output_option == "Upload to Signal":
  params.append("--export-signal")
  if signal_uuid == "":
    print("ERROR: Signal uuid required for uploading signal stickers")
    exit()
  if signal_password == "":
    print("ERROR: Signal password required for uploading signal stickers")
    exit()
elif output_option == "Compress to .wastickers (WhatsApp)":
  params.append("--export-whatsapp")
elif output_option == "Create Xcode project (iMessage)":
  params.append("--export-imessage")

if compression_preset != "": # type: ignore
  params.append("--preset")
  params.append(compression_preset)

if no_compression:
  params.append("--no-compress")

if fps_min != -1:
  params.append("--fps-min")
  params.append(str(fps_min))
if fps_max != -1:
  params.append("--fps-max")
  params.append(str(fps_max))
if res_w_min != -1:
  params.append("--res-w-min")
  params.append(str(res_w_min))
if res_w_max != -1:
  params.append("--res-w-max")
  params.append(str(res_w_max))
if res_h_min != -1:
  params.append("--res-h-min")
  params.append(str(res_h_min))
if res_h_max != -1:
  params.append("--res-h-max")
  params.append(str(res_h_max))
if quality_min != -1:
  params.append("--quality-min")
  params.append(str(quality_min))
if quality_max != -1:
  params.append("--quality-max")
  params.append(str(quality_max))
if color_min != -1:
  params.append("--color-min")
  params.append(str(color_min))
if color_max != -1:
  params.append("--color-max")
  params.append(str(color_max))
if duration_min != -1:
  params.append("--duration-min")
  params.append(str(duration_min))
if duration_max != -1:
  params.append("--duration-max")
  params.append(str(duration_max))
if bg_color != "":
  params.append("--bg-color")
  params.append(str(bg_color))
if img_size_max != -1:
  params.append("--img-size-max")
  params.append(str(img_size_max))
if vid_size_max != -1:
  params.append("--vid-size-max")
  params.append(str(vid_size_max))
if img_format != "":
  params.append("--img-format")
  params.append(str(img_format))
if vid_format != "":
  params.append("--vid-format")
  params.append(str(vid_format))
if fps_power != 0:
  params.append("--fps-power")
  params.append(str(fps_power))
if res_power != 0:
  params.append("--res-power")
  params.append(str(res_power))
if quality_power != 0:
  params.append("--quality-power")
  params.append(str(quality_power))
if color_power != 0:
  params.append("--color-power")
  params.append(str(color_power))
if padding_percent != 0:
  params.append("--padding-percent")
  params.append(str(padding_percent))
if scale_filter:
  params.append("--scale-filter")
  params.append(str(scale_filter))
if quantize_method:
  params.append("--quantize-method")
  params.append(str(quantize_method))
if default_emoji != "":
  params.append("--default-emoji")
  params.append(str(default_emoji))
if steps != -1:
  params.append("--steps")
  params.append(str(steps))
if processes != -1:
  params.append("--processes")
  params.append(str(processes))
if title != "":
  params.append("--title")
  params.append(str(title))
if title != "":
  params.append("--author")
  params.append(str(author))
if signal_uuid != "":
  params.append("--signal-uuid")
  params.append(str(signal_uuid))
if signal_password != "":
  params.append("--signal-password")
  params.append(str(signal_password))
if telegram_token != "":
  params.append("--telegram-token")
  params.append(str(telegram_token))
if telegram_userid != "":
  params.append("--telegram-userid")
  params.append(str(telegram_userid))
if kakao_gen_auth_token is True:
  params.append("--kakao-gen-auth-token")
if kakao_auth_token != "":
  params.append("--kakao-auth-token")
  params.append(str(kakao_auth_token))
if kakao_username != "":
  params.append("--kakao-username")
  params.append(str(kakao_username))
if kakao_password != "":
  params.append("--kakao-password")
  params.append(str(kakao_password))
if kakao_country_code != "":
  params.append("--kakao-country-code")
  params.append(str(kakao_country_code))
if kakao_phone_number != "":
  params.append("--kakao-phone-number")
  params.append(str(kakao_phone_number))

cmds = ["/content/sticker-convert", "--no-confirm"]

cmds += params

print(cmds)

process = subprocess.Popen(cmds, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
for line in process.stdout: # type: ignore
    print(line.decode(), end="")

Log:

/content
['/content/sticker-convert', '--no-confirm', '--input-dir', '/content/drive/MyDrive/stickers_input', '--download-line', '30629', '--output-dir', '/content/drive/MyDrive/stickers_output', '--export-whatsapp', '--preset', 'auto', '--scale-filter', 'bicubic', '--quantize-method', 'imagequant', '--title', 'LINE FRIENDS Stickers for Arranging', '--author', 'LINE FRIENDS Stickers for Arranging']
sticker-convert 2.8.8
Auto compression option set to whatsapp
Moving old files in input directory to /content/drive/MyDrive/stickers_input/archive_2024-23-05_04-24-31 as input source is not local
Moving old files in output directory to /content/drive/MyDrive/stickers_output/archive_2024-23-05_04-24-31
Downloading...
Downloading https://stickershop.line-scdn.net/stickershop/v1/product/30629/iphone/stickerpack@2x.zip
50it [00:00, 111.27it/s]
Downloaded https://stickershop.line-scdn.net/stickershop/v1/product/30629/iphone/stickerpack@2x.zip
Unzipping...
Read animation@2x/674966486@2x.png
Read animation@2x/674966487@2x.png
Read animation@2x/674966488@2x.png
Read animation@2x/674966489@2x.png
Read animation@2x/674966490@2x.png
Read animation@2x/674966491@2x.png
Read animation@2x/674966492@2x.png
Read animation@2x/674966493@2x.png
Read animation@2x/674966494@2x.png
Read animation@2x/674966495@2x.png
Read animation@2x/674966496@2x.png
Read animation@2x/674966497@2x.png
Read animation@2x/674966498@2x.png
Read animation@2x/674966499@2x.png
Read animation@2x/674966500@2x.png
Read animation@2x/674966501@2x.png
Read animation@2x/674966502@2x.png
Read animation@2x/674966503@2x.png
Read animation@2x/674966504@2x.png
Read animation@2x/674966505@2x.png
Read animation@2x/674966506@2x.png
Read animation@2x/674966507@2x.png
Read animation@2x/674966508@2x.png
Read animation@2x/674966509@2x.png
Compressing...
laggykiller commented 5 months ago

Please retry now

carmenchui commented 5 months ago

Hi, it works now. Thank you for fixing!