yeref 0.24.26__py3-none-any.whl → 0.24.28__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.
yeref/yeref.py CHANGED
@@ -15536,6 +15536,7 @@ async def upd_user_data_main(data, web_app_init_data, BASE_P, BOT_TOKEN_E18B, re
15536
15536
  sql = f"SELECT USER_TID, USER_GAMES, USER_VARS, USER_LSTS FROM \"USER\" WHERE USER_TID=$1"
15537
15537
  data_user = await db_select_pg(sql, (chat_id,), BASE_P)
15538
15538
 
15539
+ # region data
15539
15540
  if len(data_user):
15540
15541
  USER_TID, USER_GAMES, USER_VARS, USER_LSTS = data_user[0]
15541
15542
  USER_GAMES = json.loads(USER_GAMES)
@@ -15543,7 +15544,6 @@ async def upd_user_data_main(data, web_app_init_data, BASE_P, BOT_TOKEN_E18B, re
15543
15544
  USER_LSTS = json.loads(USER_LSTS)
15544
15545
  if page in ['msg', 'pst']: USER_GAMES = await ch_games(USER_GAMES, 'web', True, balls)
15545
15546
 
15546
- # region lz
15547
15547
  if lc:
15548
15548
  USER_VARS['USER_LC'] = lc
15549
15549
  lz = 'en'
@@ -15562,8 +15562,19 @@ async def upd_user_data_main(data, web_app_init_data, BASE_P, BOT_TOKEN_E18B, re
15562
15562
  elif lc in ['ru', 'kz', 'kg', 'uz', 'tm', 'md', 'am', 'uk-UA', 'uk', 'kk', 'tk', 'ky']:
15563
15563
  lz = 'ru'
15564
15564
  USER_VARS['USER_LZ'] = lz
15565
- # endregion
15566
- print(f"{USER_VARS=}, {lc=}")
15565
+
15566
+ now = datetime.now(timezone.utc)
15567
+ USER_LSTS["USER_DAU"] = list(set(USER_LSTS.get("USER_DAU", []) + [now.strftime('%Y-%m-%d')]))
15568
+ USER_LSTS["USER_MAU"] = list(set(USER_LSTS.get("USER_MAU", []) + [now.strftime('%Y-%m')]))
15569
+ USER_VARS['USER_SIG'] = usr_sig
15570
+ USER_VARS['USER_ISPREMIUM'] = is_premium
15571
+ lz = USER_VARS.get('USER_LZ', 'en')
15572
+
15573
+ if USER_VARS['USER_DT'] == '':
15574
+ USER_VARS['USER_DT'] = datetime.now(timezone.utc).strftime("%d-%m-%Y_%H-%M-%S")
15575
+ # if utm != '':
15576
+ # USER_VARS['USER_UTM'] = utm
15577
+ # endregion
15567
15578
 
15568
15579
  # region tx
15569
15580
  if connectedAddress:
@@ -15618,12 +15629,6 @@ async def upd_user_data_main(data, web_app_init_data, BASE_P, BOT_TOKEN_E18B, re
15618
15629
  if extra_bot: await extra_bot.session.close()
15619
15630
  # endregion
15620
15631
 
15621
- now = datetime.now(timezone.utc)
15622
- USER_LSTS["USER_DAU"] = list(set(USER_LSTS.get("USER_DAU", []) + [now.strftime('%Y-%m-%d')]))
15623
- USER_LSTS["USER_MAU"] = list(set(USER_LSTS.get("USER_MAU", []) + [now.strftime('%Y-%m')]))
15624
- USER_VARS['USER_SIG'] = usr_sig
15625
- USER_VARS['USER_ISPREMIUM'] = is_premium
15626
-
15627
15632
  sql = f"""
15628
15633
  INSERT INTO \"USER\" (
15629
15634
  USER_TID, USER_USERNAME, USER_FULLNAME, USER_GAMES, USER_VARS, USER_LSTS
@@ -15680,7 +15685,8 @@ async def upd_user_data(ENT_TID, data, web_app_init_data, PROJECT_USERNAME, BASE
15680
15685
 
15681
15686
  sql = f"SELECT USER_TID, USER_GAMES, USER_VARS, USER_LSTS FROM {schema_name}_{tid}.USER WHERE USER_TID=$1"
15682
15687
  data_user = await db_select_pg(sql, (chat_id,), BASE_P)
15683
- print(f"{data_user=}")
15688
+
15689
+ # region data
15684
15690
  if len(data_user):
15685
15691
  USER_TID, USER_GAMES, USER_VARS, USER_LSTS = data_user[0]
15686
15692
  USER_GAMES = json.loads(USER_GAMES)
@@ -15688,7 +15694,6 @@ async def upd_user_data(ENT_TID, data, web_app_init_data, PROJECT_USERNAME, BASE
15688
15694
  USER_LSTS = json.loads(USER_LSTS)
15689
15695
  if page in ['msg', 'pst']: USER_GAMES = await ch_games(USER_GAMES, 'web', True, balls)
15690
15696
 
15691
- # region lz
15692
15697
  if lc:
15693
15698
  USER_VARS['USER_LC'] = lc
15694
15699
  lz = 'en'
@@ -15707,8 +15712,13 @@ async def upd_user_data(ENT_TID, data, web_app_init_data, PROJECT_USERNAME, BASE
15707
15712
  elif lc in ['ru', 'kz', 'kg', 'uz', 'tm', 'md', 'am', 'uk-UA', 'uk', 'kk', 'tk', 'ky']:
15708
15713
  lz = 'ru'
15709
15714
  USER_VARS['USER_LZ'] = lz
15710
- # endregion
15711
- print(f"{USER_VARS=}, {lc=}")
15715
+
15716
+ now = datetime.now(timezone.utc)
15717
+ USER_LSTS["USER_DAU"] = list(set(USER_LSTS.get("USER_DAU", []) + [now.strftime('%Y-%m-%d')]))
15718
+ USER_LSTS["USER_MAU"] = list(set(USER_LSTS.get("USER_MAU", []) + [now.strftime('%Y-%m')]))
15719
+ USER_VARS['USER_SIG'] = usr_sig
15720
+ USER_VARS['USER_ISPREMIUM'] = is_premium
15721
+ # endregion
15712
15722
 
15713
15723
  # region tx
15714
15724
  if connectedAddress:
@@ -15733,12 +15743,6 @@ async def upd_user_data(ENT_TID, data, web_app_init_data, PROJECT_USERNAME, BASE
15733
15743
  print(f"{USER_TXS=}, {USER_LSTS=}")
15734
15744
  # endregion
15735
15745
 
15736
- now = datetime.now(timezone.utc)
15737
- USER_LSTS["USER_DAU"] = list(set(USER_LSTS.get("USER_DAU", []) + [now.strftime('%Y-%m-%d')]))
15738
- USER_LSTS["USER_MAU"] = list(set(USER_LSTS.get("USER_MAU", []) + [now.strftime('%Y-%m')]))
15739
- USER_VARS['USER_SIG'] = usr_sig
15740
- USER_VARS['USER_ISPREMIUM'] = is_premium
15741
-
15742
15746
  sql = f"""
15743
15747
  INSERT INTO {schema_name}_{tid}.USER (
15744
15748
  USER_TID, USER_USERNAME, USER_FULLNAME, USER_GAMES, USER_VARS, USER_LSTS
@@ -15978,6 +15982,9 @@ async def post_save(bot, data_user, data_web, MEDIA_D, BASE_P, KEYS_JSON, PROJEC
15978
15982
  print(f"--------------------------------------------------------")
15979
15983
  print(f"after {POST_MEDIA=}")
15980
15984
 
15985
+ if PROJECT_USERNAME == 'FereyPostBot' and POST_TYPE in ['voice', 'audio'] and 'filev_id' not in POST_MEDIA[0]:
15986
+ asyncio.create_task(convert_to_vinyl(bot, chat_id, ENT_TID, MEDIA_D, EXTRA_D, POST_MEDIA))
15987
+
15981
15988
  # region pay
15982
15989
  for button in POST_BUTTONS:
15983
15990
  try:
@@ -17582,6 +17589,45 @@ async def pst_inline(chat_id, POST_TID, data_bot, BASE_P, PROJECT_USERNAME, is_m
17582
17589
  await asyncio.sleep(round(random.uniform(1, 2), 2))
17583
17590
  finally:
17584
17591
  return result
17592
+
17593
+
17594
+ async def convert_to_vinyl(bot, chat_id, ENT_TID, POST_TID, MEDIA_D, EXTRA_D, POST_MEDIA, BASE_P):
17595
+ full_file_name = os.path.join(MEDIA_D, str(ENT_TID), POST_MEDIA[0]['file_name'])
17596
+ file_name_video = full_file_name[: full_file_name.rfind('.')] + '.mp4'
17597
+ try:
17598
+ file = await bot.get_file(POST_MEDIA[0]['file_id'])
17599
+ await bot.download_file(file.file_path, full_file_name)
17600
+ print(f"{full_file_name=} dl ok..")
17601
+
17602
+ vinyl_file = os.path.join(EXTRA_D, 'vinyl.mp4')
17603
+ print(f"Итоговый путь для нового видео с заменённым звуком {file_name_video=}")
17604
+
17605
+ audio_clip = AudioFileClip(full_file_name)
17606
+ if audio_clip.duration > 59: audio_clip = audio_clip.subclipped(0, 59)
17607
+ target_duration = 59 if audio_clip.duration > 59 else audio_clip.duration
17608
+ print(f"{target_duration=}")
17609
+
17610
+ video_template = VideoFileClip(vinyl_file)
17611
+ video_template = video_template.subclipped(0, target_duration)
17612
+ video_with_audio = video_template.with_audio(audio_clip)
17613
+ video_with_audio.write_videofile(file_name_video, codec="libx264", audio_codec="aac", fps=24)
17614
+ print(f"{file_name_video=} write_videofile ok..")
17615
+
17616
+ r = await bot.send_video_note(chat_id=chat_id, video_note=types.FSInputFile(file_name_video))
17617
+ await bot.delete_message(chat_id, r.message_id)
17618
+
17619
+ if r.video_note:
17620
+ print(f"{r.video_note.file_id=}")
17621
+ POST_MEDIA[0]['filev_id'] = r.video_note.file_id
17622
+
17623
+ sql = f"UPDATE USER_{chat_id}.POST SET POST_MEDIA=$1 WHERE POST_TID=$2"
17624
+ await db_change_pg(sql, (json.dumps(POST_MEDIA, ensure_ascii=False), POST_TID,), BASE_P)
17625
+ except Exception as e:
17626
+ logger.info(log_ % str(e))
17627
+ await asyncio.sleep(round(random.uniform(1, 2), 2))
17628
+ finally:
17629
+ if os.path.exists(full_file_name): os.remove(full_file_name)
17630
+ if os.path.exists(file_name_video): os.remove(file_name_video)
17585
17631
  # endregion
17586
17632
 
17587
17633
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: yeref
3
- Version: 0.24.26
3
+ Version: 0.24.28
4
4
  Summary: desc-f
5
5
  Author: john smith
6
6
  Dynamic: author
@@ -0,0 +1,8 @@
1
+ yeref/__init__.py,sha256=Qpv3o6Xa78VdLcsSRmctGtpnYE9btpAkCekgGhgJyXM,49
2
+ yeref/l_.py,sha256=LMX_olmJwq-tgoALJCnhV_fGrL_i_43yBLkLIcEVqGo,1176743
3
+ yeref/tonweb.js,sha256=Jf6aFOQ1OIY4q7fINYz-m5LsI3seMus124M5SYYZmtE,443659
4
+ yeref/yeref.py,sha256=yGrIAWvIBhy1PuwKn5fdSKpL3GbvZ2xMzVKmgrPqWVc,1021571
5
+ yeref-0.24.28.dist-info/METADATA,sha256=4Ue09_m-KIRZZN6h5dd1qlFyhT50u0LUPjPvBnFQuDo,119
6
+ yeref-0.24.28.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
+ yeref-0.24.28.dist-info/top_level.txt,sha256=yCQKchWHbfV-3OuQPYRdi2loypD-nmbDJbtt3OuKKkY,6
8
+ yeref-0.24.28.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- yeref/__init__.py,sha256=Qpv3o6Xa78VdLcsSRmctGtpnYE9btpAkCekgGhgJyXM,49
2
- yeref/l_.py,sha256=LMX_olmJwq-tgoALJCnhV_fGrL_i_43yBLkLIcEVqGo,1176743
3
- yeref/tonweb.js,sha256=Jf6aFOQ1OIY4q7fINYz-m5LsI3seMus124M5SYYZmtE,443659
4
- yeref/yeref.py,sha256=77MykHInANF3ubzX10vZ18jpcbqBzbnmjktQj6_qtYo,1019255
5
- yeref-0.24.26.dist-info/METADATA,sha256=bFSO0qZ49MFXMV0kSK8Ol2hbtnucCIEvePIpazBTe28,119
6
- yeref-0.24.26.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
- yeref-0.24.26.dist-info/top_level.txt,sha256=yCQKchWHbfV-3OuQPYRdi2loypD-nmbDJbtt3OuKKkY,6
8
- yeref-0.24.26.dist-info/RECORD,,