warp-beacon 2.2.34__py3-none-any.whl → 2.2.36__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- __version__ = "2.2.34"
1
+ __version__ = "2.2.36"
2
2
 
@@ -4,7 +4,6 @@ import json
4
4
  import re
5
5
 
6
6
  import multiprocessing
7
- from itertools import islice, cycle
8
7
 
9
8
  from warp_beacon.jobs import Origin
10
9
 
@@ -12,26 +11,24 @@ import logging
12
11
 
13
12
  class AccountSelector(object):
14
13
  accounts = []
15
- acc_pools = {}
16
14
  current = None
17
15
  current_module_name = None
18
- index = None
19
16
  accounts_meta_data = None
20
17
  session_dir = "/var/warp_beacon"
21
18
  manager = None
19
+ account_index = {}
22
20
 
23
21
  def __init__(self, manager: multiprocessing.managers.SyncManager, acc_file_path: str) -> None:
24
22
  self.manager = manager
25
- self.index = self.manager.Value('i', 0)
26
23
  self.accounts_meta_data = self.manager.dict()
27
24
  if os.path.exists(acc_file_path):
28
25
  with open(acc_file_path, 'r', encoding="utf-8") as f:
29
26
  self.accounts = json.loads(f.read())
30
27
  if self.accounts:
31
28
  self.__init_meta_data()
32
- self.load_yt_sessions()
29
+ #self.load_yt_sessions()
33
30
  for acc_type, _ in self.accounts.items():
34
- self.acc_pools[acc_type] = cycle(self.accounts[acc_type])
31
+ self.account_index[acc_type] = self.manager.Value('i', 0)
35
32
  else:
36
33
  raise ValueError("Accounts file not found")
37
34
 
@@ -42,7 +39,8 @@ class AccountSelector(object):
42
39
  # for k, v in self.accounts.items():
43
40
 
44
41
  def load_yt_sessions(self) -> None:
45
- self.accounts["youtube"] = []
42
+ if "youtube" not in self.accounts:
43
+ self.accounts["youtube"] = []
46
44
  for f in os.listdir(self.session_dir):
47
45
  if "yt_session" in f and ".json" in f:
48
46
  match = re.search(r'\d+', f)
@@ -64,27 +62,29 @@ class AccountSelector(object):
64
62
  module_name = 'youtube' if next((s for s in ("yt", "youtube", "youtu_be") if s in module_origin.value), None) else 'instagram'
65
63
  self.current_module_name = module_name
66
64
  if self.current is None:
67
- self.current = self.accounts[self.current_module_name][self.index.value]
68
- #self.acc_pools[self.current_module_name] = next(islice(self.acc_pools[self.current_module_name], self.index.value, None))
65
+ self.current = self.accounts[self.current_module_name][self.account_index[self.current_module_name].value]
69
66
 
70
67
  def next(self) -> dict:
71
- self.current = next(self.acc_pools[self.current_module_name])
72
- self.index.value = self.accounts[self.current_module_name].index(self.current)
73
- logging.info("Selected account index is '%d'", self.index.value)
68
+ idx = self.account_index[self.current_module_name].value + 1
69
+ if idx > len(self.accounts[self.current_module_name]):
70
+ idx = 0
71
+ self.current = self.accounts[self.current_module_name][idx]
72
+ self.account_index[self.current_module_name].value = idx
73
+ logging.info("Selected account index is '%d'", idx)
74
74
  return self.current
75
75
 
76
76
  def bump_acc_fail(self, key: str, amount: int = 1) -> int:
77
- self.accounts_meta_data[self.index.value][key] += amount
78
- return self.accounts_meta_data[self.index.value][key]
77
+ self.accounts_meta_data[self.account_index[self.current_module_name].value][key] += amount
78
+ return self.accounts_meta_data[self.account_index[self.current_module_name].value][key]
79
79
 
80
80
  def how_much(self, key: str) -> int:
81
- return self.accounts_meta_data[self.current_module_name][self.index.value][key]
81
+ return self.accounts_meta_data[self.current_module_name][self.account_index[self.current_module_name].value][key]
82
82
 
83
83
  def get_current(self) -> tuple:
84
- return (self.index.value, self.current)
84
+ return (self.account_index[self.current_module_name].value, self.current)
85
85
 
86
86
  def get_meta_data(self) -> dict:
87
- return self.accounts_meta_data[self.current_module_name][self.index.value]
87
+ return self.accounts_meta_data[self.current_module_name][self.account_index[self.current_module_name].value]
88
88
 
89
89
  def count_service_accounts(self, mod_name: Origin) -> int:
90
90
  module_name = 'youtube' if next((s for s in ("yt", "youtube", "youtu_be") if s in mod_name.value), None) else 'instagram'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: warp_beacon
3
- Version: 2.2.34
3
+ Version: 2.2.36
4
4
  Summary: Telegram bot for expanding external media links
5
5
  Home-page: https://github.com/sb0y/warp_beacon
6
6
  Author: Andrey Bagrintsev
@@ -3,7 +3,7 @@ lib/systemd/system/warp_beacon.service,sha256=lPmHqLqcI2eIV7nwHS0qcALQrznixqJuww
3
3
  var/warp_beacon/accounts.json,sha256=2QQMS9N_Z-TnfZq4U1vSUe4IKyZGmTFdgo8BoF4hQ7E,1710
4
4
  var/warp_beacon/placeholder.gif,sha256=cE5CGJVaop4Sx21zx6j4AyoHU0ncmvQuS2o6hJfEH88,6064
5
5
  warp_beacon/__init__.py,sha256=_rThNODmz0nDp_n4mWo_HKaNFE5jk1_7cRhHyYaencI,163
6
- warp_beacon/__version__.py,sha256=oYqTWRUbR0yBNg1Ucm85He64XgsCurjGgTv4ct-G_S0,24
6
+ warp_beacon/__version__.py,sha256=VrKs5E5SeGI4N9fYl4L9vngIM8ORIydBeuAwozQZqPE,24
7
7
  warp_beacon/warp_beacon.py,sha256=7KEtZDj-pdhtl6m-zFLsSojs1ZR4o7L0xbqtdmYPvfE,342
8
8
  warp_beacon/compress/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  warp_beacon/compress/video.py,sha256=_PDMVYCyzLYxHv1uZmmzGcG_8rjaZr7BTXsXTTy_oS4,2846
@@ -21,7 +21,7 @@ warp_beacon/scheduler/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3h
21
21
  warp_beacon/scheduler/scheduler.py,sha256=oKuDP3RqUQmNYBorKxnhz9QqA-eLTJHVTinWbsYB530,2585
22
22
  warp_beacon/scraper/__init__.py,sha256=tkl7UyfqFcvPlxomVPB9GpWQvAoADaM6jGb_bmx1zRY,15229
23
23
  warp_beacon/scraper/abstract.py,sha256=aNZ9ypF9B8BjflcIwi-7wEzIqF-XPeF0xvfX9CP_iIw,2708
24
- warp_beacon/scraper/account_selector.py,sha256=jkf8sWncNj37YAK0_KT-5XZ7aHSpSz8Y4LIzb4LXnRE,3387
24
+ warp_beacon/scraper/account_selector.py,sha256=lX9l2RwMbPKhSjmEvWLKTuo-6-QI8kA52eoPMKSCo7o,3510
25
25
  warp_beacon/scraper/exceptions.py,sha256=lHsPrYy5iYnHsIdUHqRxZmzlqrkNj_TS4TkiTJfWhTs,1326
26
26
  warp_beacon/scraper/instagram/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
27
  warp_beacon/scraper/instagram/instagram.py,sha256=D_r6Kdpe4iBjCeGv-vVIodiVnZps6ZyBbaY0JC7mGWI,13782
@@ -37,9 +37,9 @@ warp_beacon/telegram/handlers.py,sha256=xSNG_v4D4FaA5q1_5wXvJkjcDUhy5GaQnfpijJZp
37
37
  warp_beacon/telegram/placeholder_message.py,sha256=32U-R_IMPRJd-S5UwlpemLkArJOxCmO7whcynduSbMA,6418
38
38
  warp_beacon/telegram/utils.py,sha256=CeWXMwyzv2l4Af6I-wW2ySU490c-5k82sBhkjabv0n4,2452
39
39
  warp_beacon/uploader/__init__.py,sha256=rsUkzzmtaeQY-kNkcIiPsrayS9idFKY3hBC71mR19XE,4743
40
- warp_beacon-2.2.34.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
41
- warp_beacon-2.2.34.dist-info/METADATA,sha256=-i1V1OCyRp7_knj7oPpmyLARLn1BV1nUzGRuzXECGwQ,21251
42
- warp_beacon-2.2.34.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
43
- warp_beacon-2.2.34.dist-info/entry_points.txt,sha256=eSB61Rb89d56WY0O-vEIQwkn18J-4CMrJcLA_R_8h3g,119
44
- warp_beacon-2.2.34.dist-info/top_level.txt,sha256=ALb_Ft_eG-OY4_m0TWUifNUOZsrx483L-zw7G7vqXoc,971
45
- warp_beacon-2.2.34.dist-info/RECORD,,
40
+ warp_beacon-2.2.36.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
41
+ warp_beacon-2.2.36.dist-info/METADATA,sha256=TmWY6ey4APMBelOZVDrgNY9MM4wEsnCkiznCz-OmcOQ,21251
42
+ warp_beacon-2.2.36.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
43
+ warp_beacon-2.2.36.dist-info/entry_points.txt,sha256=eSB61Rb89d56WY0O-vEIQwkn18J-4CMrJcLA_R_8h3g,119
44
+ warp_beacon-2.2.36.dist-info/top_level.txt,sha256=ALb_Ft_eG-OY4_m0TWUifNUOZsrx483L-zw7G7vqXoc,971
45
+ warp_beacon-2.2.36.dist-info/RECORD,,