-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for uploading Viber stickers
- Loading branch information
1 parent
b0e02aa
commit 9dacb5a
Showing
20 changed files
with
647 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,22 @@ | ||
# Downloading Viber stickers | ||
sticker-convert supports downloading viber stickers from share link of sticker pack. | ||
|
||
sticker-convert can also convert images to png with 490x490 for uploading to viber manually. | ||
It should be noted that Viber is able to resize images for you, so it may not be necessary | ||
to use sticker-convert for creating Viber sticker pack. | ||
# Uploading Viber stickers | ||
Viber authentication data required for uploading Viber stickers, which could be fetched | ||
from Viber Desktop application automatically: | ||
1. Install Viber Desktop | ||
2. Login to Viber Desktop | ||
3. In sticker-convert, press `Generate` button (In GUI) or `--viber-get-auth` (In CLI) | ||
|
||
Notice: | ||
- Viber Desktop would be closed, launched and closed again when getting auth data. | ||
- It may take a minute to get auth data. | ||
- On macOS, you need to disable SIP and will be asked for user password. | ||
- For atypical installation of Viber Desktop, you may specify Viber Desktop application | ||
location by using `--viber-bin-path`. | ||
- `m_token`, `m_ts` and `member_id` are required. | ||
- `m_ts` is the unix timestamp when `m_token` is generated. | ||
- `m_token` expires after 13800 seconds (230 minutes). | ||
|
||
# References | ||
For more info, please refer to https://help.viber.com/hc/en-us/articles/9204828903837-Use-and-create-stickers-on-Rakuten-Viber |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
types-beautifulsoup4 | ||
types-psutil | ||
types-Pillow | ||
types-requests | ||
types-tqdm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
143 changes: 143 additions & 0 deletions
143
src/sticker_convert/gui_components/windows/viber_get_auth_window.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
#!/usr/bin/env python3 | ||
import platform | ||
from functools import partial | ||
from pathlib import Path | ||
from subprocess import Popen | ||
from tkinter import filedialog | ||
from typing import Any | ||
|
||
from ttkbootstrap import Button, Entry, Frame, Label # type: ignore | ||
|
||
from sticker_convert.gui_components.gui_utils import GUIUtils | ||
from sticker_convert.gui_components.windows.base_window import BaseWindow | ||
from sticker_convert.utils.auth.get_viber_auth import GetViberAuth | ||
|
||
|
||
class ViberGetAuthWindow(BaseWindow): | ||
def __init__(self, *args: Any, **kwargs: Any) -> None: | ||
super().__init__(*args, **kwargs) | ||
|
||
self.title("Get Viber auth data") | ||
|
||
self.cb_msg_block_viber = partial(self.gui.cb_msg_block, parent=self) | ||
self.cb_ask_str_viber = partial(self.gui.cb_ask_str, parent=self) | ||
|
||
self.frame_info = Frame(self.scrollable_frame) | ||
self.frame_btns = Frame(self.scrollable_frame) | ||
self.frame_config = Frame(self.scrollable_frame) | ||
|
||
self.frame_info.grid(column=0, row=0, sticky="news", padx=3, pady=3) | ||
self.frame_btns.grid(column=0, row=1, sticky="news", padx=3, pady=3) | ||
self.frame_config.grid(column=0, row=2, sticky="news", padx=3, pady=3) | ||
|
||
# Info frame | ||
self.explanation_lbl0 = Label( | ||
self.frame_info, | ||
text="Please install Viber Desktop and login first.", | ||
justify="left", | ||
anchor="w", | ||
) | ||
self.explanation_lbl1 = Label( | ||
self.frame_info, | ||
text="It may take a minute to get auth data.", | ||
justify="left", | ||
anchor="w", | ||
) | ||
self.explanation_lbl2 = None | ||
if platform.system() == "Darwin": | ||
self.explanation_lbl2 = Label( | ||
self.frame_info, | ||
text="You need to disable SIP and will be asked for user password.", | ||
justify="left", | ||
anchor="w", | ||
) | ||
|
||
self.explanation_lbl0.grid(column=0, row=0, sticky="w", padx=3, pady=3) | ||
self.explanation_lbl1.grid(column=0, row=1, sticky="w", padx=3, pady=3) | ||
if self.explanation_lbl2 is not None: | ||
self.explanation_lbl2.grid(column=0, row=2, sticky="w", padx=3, pady=3) | ||
|
||
# Start button frame | ||
self.launch_btn = Button( | ||
self.frame_btns, | ||
text="Launch Viber Desktop", | ||
command=self.cb_launch_viber, | ||
bootstyle="secondary", # type: ignore | ||
) | ||
|
||
self.get_cred_btn = Button( | ||
self.frame_btns, | ||
text="Get auth data", | ||
command=self.cb_get_cred, | ||
bootstyle="default", # type: ignore | ||
) | ||
|
||
self.launch_btn.pack() | ||
self.get_cred_btn.pack() | ||
|
||
# Config frame | ||
self.setdir_lbl = Label( | ||
self.frame_config, | ||
text=self.gui.help["cred"]["viber_bin_path"], | ||
justify="left", | ||
anchor="w", | ||
) | ||
|
||
self.setdir_entry = Entry( | ||
self.frame_config, | ||
textvariable=self.gui.viber_bin_path_var, | ||
width=32, | ||
) | ||
self.setdir_btn = Button( | ||
self.frame_config, | ||
text="Choose", | ||
command=self.cb_setdir, | ||
width=8, | ||
bootstyle="secondary", # type: ignore | ||
) | ||
|
||
self.setdir_lbl.grid(column=0, row=0, columnspan=2, sticky="w", padx=3, pady=3) | ||
self.setdir_entry.grid(column=0, row=1, sticky="w", padx=3, pady=3) | ||
self.setdir_btn.grid(column=1, row=1, sticky="e", padx=3, pady=3) | ||
|
||
GUIUtils.finalize_window(self) | ||
|
||
def cb_get_cred(self) -> None: | ||
m = GetViberAuth() | ||
|
||
viber_bin_path = None | ||
if self.gui.viber_bin_path_var.get(): | ||
viber_bin_path = self.gui.viber_bin_path_var.get() | ||
|
||
viber_auth, msg = m.get_cred(viber_bin_path) | ||
|
||
if viber_auth: | ||
if not self.gui.creds.get("viber"): | ||
self.gui.creds["viber"] = {} | ||
self.gui.creds["viber"]["auth"] = viber_auth | ||
self.gui.viber_auth_var.set(viber_auth) | ||
|
||
self.gui.save_creds() | ||
self.gui.highlight_fields() | ||
|
||
self.cb_msg_block_viber(msg) | ||
|
||
def cb_launch_viber(self) -> None: | ||
m = GetViberAuth() | ||
viber_bin_path = m.get_viber_desktop() | ||
|
||
if self.gui.viber_auth_var.get(): | ||
viber_bin_path = self.gui.viber_auth_var.get() | ||
|
||
if viber_bin_path: | ||
Popen([viber_bin_path]) | ||
else: | ||
self.cb_msg_block_viber("Error: Viber Desktop not installed.") | ||
|
||
def cb_setdir(self) -> None: | ||
orig_input_dir = self.gui.viber_bin_path_var.get() | ||
if not Path(orig_input_dir).is_dir(): | ||
orig_input_dir = "" | ||
input_dir = filedialog.askdirectory(initialdir=orig_input_dir) | ||
if input_dir: | ||
self.gui.viber_bin_path_var.set(input_dir) |
Oops, something went wrong.