mirror of
https://github.com/bombsquad-community/plugin-manager.git
synced 2025-10-08 14:54:36 +00:00
Changed the logic to print new plugins
Instead of checking the locally present plugins details. This will print the n latest plugins based on release date.
This commit is contained in:
parent
60dee789ae
commit
59b7bdbdc4
1 changed files with 22 additions and 9 deletions
|
|
@ -19,6 +19,7 @@ import hashlib
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
from typing import Union, Optional
|
from typing import Union, Optional
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
_env = _ba.env()
|
_env = _ba.env()
|
||||||
_uiscale = ba.app.ui.uiscale
|
_uiscale = ba.app.ui.uiscale
|
||||||
|
|
@ -268,18 +269,20 @@ class StartupTasks:
|
||||||
plugins_to_update.append(plugin.update())
|
plugins_to_update.append(plugin.update())
|
||||||
await asyncio.gather(*plugins_to_update)
|
await asyncio.gather(*plugins_to_update)
|
||||||
|
|
||||||
async def get_new_plugins(self):
|
async def get_new_plugins(self, new_plugin_count):
|
||||||
new_plugins = []
|
new_plugins = []
|
||||||
|
plugin_dictionary = {}
|
||||||
await self.plugin_manager.setup_index()
|
await self.plugin_manager.setup_index()
|
||||||
current_plugins = ## Need to fetch the current present plugins
|
|
||||||
all_plugins = await self.plugin_manager.categories["All"].get_plugins()
|
all_plugins = await self.plugin_manager.categories["All"].get_plugins()
|
||||||
for plugin in all_plugins:
|
for plugin in all_plugins:
|
||||||
if plugin not in current_plugins:
|
date, name = plugin.get_name_and_release_date
|
||||||
new_plugins.append(plugin)
|
plugin_dictionary[date] = name
|
||||||
plugin_count = len(new_plugins)
|
sorted_dict = dict(sorted(plugin_dictionary.items(), key=lambda x: datetime.strptime(x[0], '%d-%m-%Y'), reverse=True))
|
||||||
plugin_names = ', '.join(new_plugins)
|
for iterator, value in enumerate(sorted_dict.values()):
|
||||||
|
if iterator < new_plugin_count:
|
||||||
print_message = f"{plugin_count} new plugins ({plugin_names}) are available!"
|
new_plugins.append(value)
|
||||||
|
new_plugin_names = ', '.join(new_plugins)
|
||||||
|
print_message = f"{new_plugin_count} new plugins ({new_plugin_names}) are available!"
|
||||||
ba.screenmessage(print_message, color=(0, 1, 0))
|
ba.screenmessage(print_message, color=(0, 1, 0))
|
||||||
|
|
||||||
async def notify_new_plugins(self):
|
async def notify_new_plugins(self):
|
||||||
|
|
@ -299,7 +302,7 @@ class StartupTasks:
|
||||||
|
|
||||||
if num_of_plugins < new_num_of_plugins:
|
if num_of_plugins < new_num_of_plugins:
|
||||||
ba.screenmessage("We got new Plugins for you to try!")
|
ba.screenmessage("We got new Plugins for you to try!")
|
||||||
await self.get_new_plugins()
|
await self.get_new_plugins(new_num_of_plugins-num_of_plugins)
|
||||||
ba.app.config["Community Plugin Manager"]["Existing Number of Plugins"] = new_num_of_plugins
|
ba.app.config["Community Plugin Manager"]["Existing Number of Plugins"] = new_num_of_plugins
|
||||||
ba.app.config.commit()
|
ba.app.config.commit()
|
||||||
|
|
||||||
|
|
@ -704,10 +707,20 @@ class Plugin:
|
||||||
self._versions = None
|
self._versions = None
|
||||||
self._latest_version = None
|
self._latest_version = None
|
||||||
self._latest_compatible_version = None
|
self._latest_compatible_version = None
|
||||||
|
self._released_on = None
|
||||||
|
self._latest_plugin_key = None
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f"<Plugin({self.name})>"
|
return f"<Plugin({self.name})>"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def get_name_and_release_date(self):
|
||||||
|
if self._released_on is None:
|
||||||
|
self._latest_plugin_key = list(self.info["versions"].keys())[0]
|
||||||
|
self._released_on = self.info["versions"][self._latest_plugin_key]
|
||||||
|
# self._released_on = sorted(self._released_on, key=self._released_on["released_on"])
|
||||||
|
return self._released_on["released_on"], self.name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def view_url(self):
|
def view_url(self):
|
||||||
if self.latest_compatible_version == self.latest_version:
|
if self.latest_compatible_version == self.latest_version:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue