Skip to content

Commit

Permalink
Merge release/1.4.0 into master
Browse files Browse the repository at this point in the history
Merge release/1.4.0 into master
Merge pull request #29 from chrisism/release/1.4.0
  • Loading branch information
chrisism authored May 17, 2023
2 parents 6f9408a + 72976e5 commit acb3ef0
Show file tree
Hide file tree
Showing 28 changed files with 1,428 additions and 575 deletions.
2 changes: 1 addition & 1 deletion addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.program.akl" name="Advanced Kodi Launcher" version="1.0.0-rc39" provider-name="chrisism">
<addon id="plugin.program.akl" name="Advanced Kodi Launcher" version="1.0.4-rc0" provider-name="chrisism">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
<import addon="script.module.routing" version="0.2.3"/>
Expand Down
21 changes: 9 additions & 12 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
## Current
- Search term mode applicable for multi ROM scraping
- Refactoring of default asset mapping
- Added setting to disable view rendering notifications
- Changed database migrations system
- Added 'edit platform' to ROMs
- Changed platform can be applied to all ROMs in a collection

## Previous
- Custom skin view for View ROM
- More details about addon plugins
- Fixed linking assets to wrong directory
- Fixed category rendering
- Added rebuild views option in settings dialog

## Previous
- Added support for PEGI rating
- Fixed bug deleting collections
- Proper icon/thumb mapping for virtual collections
- Virtual categories now render items from database
- Add and execute single instance ROMs or Games
- Added an overview option with installed plugins
- Fix adding tags to ROMs
- Minor bugfixes
- Updated dependency
- Fixed virtual collections (Favs, Most recent ..)
- Fixed scraping ROM assets only
- Fixed bug deleting collections
69 changes: 68 additions & 1 deletion resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ msgctxt "#40416"
msgid "Launch ROM directly by default on item action"
msgstr "settings.xml"

msgctxt "#40417"
msgid "Hide rendering notifications"
msgstr "settings.xml"

############################
# Setting options - Paths
############################
Expand Down Expand Up @@ -296,6 +300,69 @@ msgctxt "#40856"
msgid "Rebuild all views"
msgstr ""

msgctxt "#40857"
msgid "Run database migrations"
msgstr ""

msgctxt "#40858"
msgid "Reset database (warning!)"
msgstr ""

msgctxt "#40859"
msgid "Choose default Assets/Artwork"
msgstr ""

msgctxt "#40860"
msgid "Category status:"
msgstr ""

msgctxt "#40861"
msgid "Export Category XML configuration"
msgstr ""

msgctxt "#40862"
msgid "Delete Category"
msgstr ""

msgctxt "#40863"
msgid "Edit Title"
msgstr ""

msgctxt "#40864"
msgid "Edit Platform"
msgstr ""

msgctxt "#40865"
msgid "Edit Release Year"
msgstr ""

############################
# Headers and texts / notifications
############################
msgctxt "#40950"
msgid "Select action for Category"
msgstr ""

msgctxt "#40951"
msgid "Invalid parameters supplied."
msgstr ""

msgctxt "#40952"
msgid "Is it a directly launchable file/executable?\nChoose no if you want to assign a separate launcher afterwards."
msgstr ""

msgctxt "#40953"
msgid "Select file"
msgstr ""

msgctxt "#40954"
msgid "Failure while doing database migration."
msgstr ""

msgctxt "#40955"
msgid "Should new platform be applied to existing ROMs in this collection?"
msgstr ""

############################
# Scraping settings
############################
Expand Down Expand Up @@ -343,7 +410,7 @@ msgid "Clones"
msgstr "settings.xml"

############################
# Advaced Enum values
# Advanced Enum values
############################

msgctxt "#30911"
Expand Down
20 changes: 10 additions & 10 deletions resources/lib/commands/category_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def cmd_edit_category(args):

if category_id is None:
logger.warning('cmd_add_category(): No category id supplied.')
kodi.notify_warn("Invalid parameters supplied.")
kodi.notify_warn(kodi.translate(40951))
return

selected_option = None
Expand All @@ -80,23 +80,23 @@ def cmd_edit_category(args):
category = repository.find_category(category_id)

options = collections.OrderedDict()
options['CATEGORY_EDIT_METADATA'] = 'Edit Metadata ...'
options['CATEGORY_EDIT_ASSETS'] = 'Edit Assets/Artwork ...'
options['CATEGORY_EDIT_DEFAULT_ASSETS'] = 'Choose default Assets/Artwork ...'
options['CATEGORY_STATUS'] = 'Category status: {0}'.format(category.get_finished_str())
options['EXPORT_CATEGORY_XML'] = 'Export Category XML configuration ...'
options['DELETE_CATEGORY'] = 'Delete Category'
options['CATEGORY_EDIT_METADATA'] = kodi.translate(40853)
options['CATEGORY_EDIT_ASSETS'] = kodi.translate(40854)
options['CATEGORY_EDIT_DEFAULT_ASSETS'] = kodi.translate(40859)
options['CATEGORY_STATUS'] = f'{kodi.translate(40859)} {category.get_finished_str()}'
options['EXPORT_CATEGORY_XML'] = kodi.translate(40861)
options['DELETE_CATEGORY'] = kodi.translate(40862)

s = 'Select action for Category "{0}"'.format(category.get_name())
s = f'{kodi.translate(40950)} "{category.get_name}"'
selected_option = kodi.OrdDictionaryDialog().select(s, options)

if selected_option is None:
# >> Exits context menu
logger.debug('EDIT_CATEGORY: cmd_edit_category() Selected None. Closing context menu')
logger.debug('EDIT_CATEGORY: Selected None. Closing context menu')
return

# >> Execute subcommand. May be atomic, maybe a submenu.
logger.debug('EDIT_CATEGORY: cmd_edit_category() Selected {}'.format(selected_option))
logger.debug(f'EDIT_CATEGORY: Selected {selected_option}')
AppMediator.sync_cmd(selected_option, args)

# --- Submenu command ---
Expand Down
51 changes: 49 additions & 2 deletions resources/lib/commands/misc_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@

import logging
import typing
import collections

from datetime import datetime
from xml.etree import cElementTree as ET
from xml.dom import minidom
from distutils.version import LooseVersion

from akl.utils import kodi, io
from akl import constants
Expand Down Expand Up @@ -152,7 +154,7 @@ def cmd_export_to_xml(args):
ET.SubElement(category_xml,'plot').text = category.get_plot()
ET.SubElement(category_xml,'Asset_Prefix').text = category.get_custom_attribute('Asset_Prefix')
for asset in category.get_assets():
ET.SubElement(category_xml,asset.get_asset_info().key).text = asset.get_path()
ET.SubElement(category_xml, f"s_{asset.get_asset_info().id}").text = asset.get_path()

# --- Export Launchers and add XML tail ---
# Data which is not string must be converted to string
Expand Down Expand Up @@ -199,7 +201,7 @@ def cmd_export_to_xml(args):
ET.SubElement(launcher_xml, path.get_asset_info().path_key).text = path.get_path()

for asset in collection.get_assets():
ET.SubElement(launcher_xml,asset.get_asset_info().key).text = asset.get_path()
ET.SubElement(launcher_xml, f"s_{asset.get_asset_info().id}").text = asset.get_path()

result_xml = ET.tostring(root, 'utf-8')
parsed_xml = minidom.parseString(result_xml)
Expand All @@ -222,6 +224,51 @@ def cmd_execute_reset_db(args):
AppMediator.async_cmd('SCAN_FOR_ADDONS')
kodi.notify('Finished resetting the database')

@AppMediator.register('RUN_DB_MIGRATIONS')
def cmd_execute_migrations(args):
uow = UnitOfWork(globals.g_PATHS.DATABASE_FILE_PATH)

db_version = LooseVersion(uow.get_database_version())
migrations_in_database = uow.get_migrations_history()

options = collections.OrderedDict()
migrations_files_available = uow.get_migration_files(LooseVersion("0.0.0"))

for migration_file in migrations_files_available:
file_name = migration_file.getBase()
existing_migration = next((m for m in migrations_in_database if m["migration_file"] == file_name), None)
state = "NEW" if existing_migration is None else ("DONE" if existing_migration["applied"] else "FAILED")
options[migration_file.getPath()] = f"{migration_file.getBase()} [{state}]"

dialog = kodi.OrdDictionaryDialog()
selected_file = dialog.select(f"Select migrations to execute (Current version {db_version})", options)

if selected_file is None:
return

migration_file = io.FileName(selected_file)
version_to_store = LooseVersion(globals.addon_version)
file_version = uow.get_version_from_migration_file(migration_file)
if file_version > version_to_store:
version_to_store = file_version
if db_version > version_to_store:
version_to_store = db_version

dialog = kodi.ListDialog()
selected_index = dialog.select(f"Migration {migration_file.getBaseNoExt()}",[
"Run migration",
"Mark as executed without running"
])
if not selected_index:
return

if selected_index == 0:
if not kodi.dialog_yesno(f"Run migration {migration_file.getBaseNoExt()}?"):
return

uow.migrate_database([migration_file], version_to_store, selected_index==1)
kodi.notify('Done running migrations on the database')

@AppMediator.register('CHECK_DUPLICATE_ASSET_DIRS')
def cmd_check_duplicate_asset_dirs(args):
romcollection_id:str = args['romcollection_id'] if 'romcollection_id' in args else None
Expand Down
33 changes: 25 additions & 8 deletions resources/lib/commands/rom_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import logging
import collections

from akl import constants
from akl import constants, platforms
from akl.utils import kodi, text, io

from resources.lib.commands.mediator import AppMediator
Expand Down Expand Up @@ -52,9 +52,9 @@ def cmd_edit_rom(args):
rom = repository.find_rom(rom_id)

options = collections.OrderedDict()
options['ROM_EDIT_METADATA'] = f'{kodi.translate(40853)} ...'
options['ROM_EDIT_ASSETS'] = f'{kodi.translate(40854)} ...'
# options['ROM_EDIT_DEFAULT_ASSETS'] = 'Choose default Assets/Artwork ...'
options['ROM_EDIT_METADATA'] = kodi.translate(40853)
options['ROM_EDIT_ASSETS'] = kodi.translate(40854)
options['ROM_EDIT_DEFAULT_ASSETS'] = kodi.translate(40859)
options['EDIT_ROM_STATUS'] = f'ROM status: {rom.get_finished_str()}'
if rom.has_launchers():
options['EDIT_ROM_LAUNCHERS'] = 'Manage associated launchers'
Expand Down Expand Up @@ -90,8 +90,9 @@ def cmd_rom_metadata(args):
NFO_found_str = 'NFO found' if NFO_FileName and NFO_FileName.exists() else 'NFO not found'

options = collections.OrderedDict()
options['ROM_EDIT_METADATA_TITLE'] = "Edit Title: '{}'".format(rom.get_name())
options['ROM_EDIT_METADATA_RELEASEYEAR'] = "Edit Release Year: {}".format(rom.get_releaseyear())
options['ROM_EDIT_METADATA_TITLE'] = f"{kodi.translate(40863)}: '{rom.get_name()}'"
options['ROM_EDIT_METADATA_PLATFORM'] = f"{kodi.translate(40864)}: {rom.get_platform()}"
options['ROM_EDIT_METADATA_RELEASEYEAR'] = f"{kodi.translate(40865)}: {rom.get_releaseyear()}"
options['ROM_EDIT_METADATA_GENRE'] = "Edit Genre: '{}'".format(rom.get_genre())
options['ROM_EDIT_METADATA_DEVELOPER'] = "Edit Developer: '{}'".format(rom.get_developer())
options['ROM_EDIT_METADATA_NPLAYERS'] = "Edit NPlayers: '{}'".format(rom.get_number_of_players())
Expand Down Expand Up @@ -238,6 +239,22 @@ def cmd_rom_metadata_title(args):

AppMediator.sync_cmd('ROM_EDIT_METADATA', args)

@AppMediator.register('ROM_EDIT_METADATA_PLATFORM')
def cmd_rom_metadata_platform(args):
rom_id = args['rom_id'] if 'rom_id' in args else None
uow = UnitOfWork(globals.g_PATHS.DATABASE_FILE_PATH)
with uow:
repository = ROMsRepository(uow)
rom = repository.find_rom(rom_id)

if editors.edit_field_by_list(rom, 'Platform', platforms.AKL_platform_list,
rom.get_platform, rom.set_platform):
repository.update_rom(rom)
uow.commit()
AppMediator.async_cmd('RENDER_ROM_VIEWS', {'rom_id': rom.get_id()})

AppMediator.sync_cmd('ROM_EDIT_METADATA', args)

@AppMediator.register('ROM_EDIT_METADATA_ESRB')
def cmd_rom_metadata_esrb(args):
rom_id = args['rom_id'] if 'rom_id' in args else None
Expand Down Expand Up @@ -713,10 +730,10 @@ def cmd_add_rom(args):
parent_category = grand_parent_category

rom_name = ""
is_file_based = kodi.dialog_yesno("Is it a file based ROM/executable?")
is_file_based = kodi.dialog_yesno(kodi.translate(40952))
file_path = None
if is_file_based:
file_path = kodi.dialog_get_file("Select file")
file_path = kodi.dialog_get_file(kodi.translate(40953))
if file_path is not None:
path = io.FileName(file_path)
rom_name = path.getBaseNoExt()
Expand Down
5 changes: 3 additions & 2 deletions resources/lib/commands/rom_launcher_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ def cmd_execute_rom_with_launcher(args):
return

logger.info('Automatic fallback to Retroplayer as launcher applied.')
retroplayer_addon = addon_repository.find_by_addon_id(constants.RETROPLAYER_LAUNCHER_APP_NAME, constants.AddonType.LAUNCHER)
retroplayer_addon = addon_repository.find_by_addon_id(constants.RETROPLAYER_LAUNCHER_APP_NAME, constants.AddonType.LAUNCHER)
retroplayer_launcher = ROMLauncherAddonFactory.create(retroplayer_addon, {})
launchers.append(retroplayer_launcher)

Expand All @@ -425,7 +425,8 @@ def cmd_execute_rom_with_launcher(args):
dialog = kodi.OrdDictionaryDialog()
selected_launcher = dialog.select('Choose launcher', launcher_options,preselect=preselected)

if selected_launcher is None: return
if selected_launcher is None:
return

selected_launcher.launch(rom)
AppMediator.async_cmd('ROM_WAS_LAUNCHED', args)
1 change: 1 addition & 0 deletions resources/lib/commands/rom_scraper_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def cmd_scrape_roms_in_romcollection(args):
options = collections.OrderedDict()
options['SCRAPER_METADATA_POLICY'] = 'Metadata scan policy: "{}"'.format(kodi.translate(scraper_settings.scrape_metadata_policy))
options['SCRAPER_ASSET_POLICY'] = 'Asset scan policy: "{}"'.format(kodi.translate(scraper_settings.scrape_assets_policy))
options['SCRAPER_SEARCH_TERM_MODE'] = f'Search term mode: "{kodi.translate(scraper_settings.search_term_mode)}"'
options['SCRAPER_GAME_SELECTION_MODE'] = 'Game selection mode: "{}"'.format(kodi.translate(scraper_settings.game_selection_mode))
options['SCRAPER_ASSET_SELECTION_MODE'] = 'Asset selection mode: "{}"'.format(kodi.translate(scraper_settings.asset_selection_mode))
options['SCRAPER_META_TO_SCRAPE'] = 'Metadata to scrape: "{}"'.format(', '.join(metadata_to_scrape))
Expand Down
Loading

0 comments on commit acb3ef0

Please sign in to comment.