Skip to content
This repository has been archived by the owner on Sep 19, 2023. It is now read-only.

Commit

Permalink
Merge pull request #21 from RaenonX-DL/dev
Browse files Browse the repository at this point in the history
v1.0.0 Release
  • Loading branch information
RaenonX authored Sep 20, 2021
2 parents 428ff02 + f86c8a2 commit c1d512d
Show file tree
Hide file tree
Showing 68 changed files with 2,204 additions and 49 deletions.
5 changes: 4 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ count = True

ignore =
# As of PEP 8, W503 is yielded in old-style
W503
W503,
# Let `pylint` check this because `pyflake` (used by `flake8`) checks
# if the items in `__init__.py` are listed as `__all__` or not
F401

max-complexity = 10

Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ venv/
# Cache
.mypy_cache
.pytest_cache
__pycache__

# Project files
.idea/

# Test files
config-temp.yaml

# Misc
.wakatime-project
.exclude/
25 changes: 12 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# dragalia-asset-downloader-2

[![downloader-ci]][downloader-ci-link]
[![downloader-cq-badge]][downloader-cq-link]
[![downloader-lgtm-alert-badge]][downloader-lgtm-alert-link]
[![downloader-lgtm-quality-badge]][downloader-lgtm-quality-link]
[![downloader-lgtm-loc-badge]][downloader-lgtm-quality-link]
[![downloader-time-badge]][downloader-time-link]

Main | Dev
:---: | :---:
[![downloader-cq-badge-main]][downloader-cq-link-main] | [![downloader-cq-badge-dev]][downloader-cq-link-dev]

Python scripts for downloading and pre-processing Dragalia Lost game assets.

Replaces [dragalia-asset-downloader].
Expand All @@ -15,6 +18,10 @@ Replaces [dragalia-asset-downloader].

- Python 3.9

- .NET Core 3.1+
- Download here: https://dotnet.microsoft.com/download/dotnet-core/3.1.
- Run `dotnet` to ensure it's working.

- Dependencies listed in `requirements.txt`
- Run `pip install -r requirements.txt` to install required dependencies.
- Run `pip install -r requirements-dev.txt` to install required and development dependencies.
Expand All @@ -26,23 +33,15 @@ Replaces [dragalia-asset-downloader].
[dragalia-asset-downloader]: https://github.com/RaenonX-DL/dragalia-asset-downloader

[downloader-ci]: https://github.com/RaenonX-DL/dragalia-asset-downloader-2/workflows/CI/badge.svg

[downloader-ci-link]: https://github.com/RaenonX-DL/dragalia-asset-downloader-2/actions?query=workflow%3ACI

[downloader-cq-badge]: https://app.codacy.com/project/badge/Grade/455468d9c9184f88af1249e82cb2c4ad

[downloader-cq-link]: https://www.codacy.com/gh/RaenonX-DL/dragalia-asset-downloader-2/dashboard

[downloader-cq-badge-main]: https://app.codacy.com/project/badge/Grade/455468d9c9184f88af1249e82cb2c4ad?branch=main
[downloader-cq-badge-dev]: https://app.codacy.com/project/badge/Grade/455468d9c9184f88af1249e82cb2c4ad?branch=dev
[downloader-cq-link-main]: https://www.codacy.com/gh/RaenonX-DL/dragalia-asset-downloader-2/dashboard?branch=main
[downloader-cq-link-dev]: https://www.codacy.com/gh/RaenonX-DL/dragalia-asset-downloader-2/dashboard?branch=dev
[downloader-time-badge]: https://wakatime.com/badge/github/RaenonX-DL/dragalia-asset-downloader-2.svg

[downloader-time-link]: https://wakatime.com/badge/github/RaenonX-DL/dragalia-asset-downloader-2

[downloader-lgtm-alert-badge]: https://img.shields.io/lgtm/alerts/g/RaenonX-DL/dragalia-asset-downloader-2.svg?logo=lgtm&logoWidth=18

[downloader-lgtm-alert-link]: https://lgtm.com/projects/g/RaenonX-DL/dragalia-asset-downloader-2/alerts/

[downloader-lgtm-quality-badge]: https://img.shields.io/lgtm/grade/python/g/RaenonX-DL/dragalia-asset-downloader-2.svg?logo=lgtm&logoWidth=18

[downloader-lgtm-quality-link]: https://lgtm.com/projects/g/RaenonX-DL/dragalia-asset-downloader-2/context:python

[downloader-lgtm-loc-badge]: https://badgen.net/lgtm/lines/g/RaenonX-DL/dragalia-asset-downloader-2
159 changes: 159 additions & 0 deletions config.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://raw.githubusercontent.com/RaenonX-DL/dragalia-asset-downloader-2/main/config.schema.json",
"title": "Dragalia Lost Asset Downloader Config Schema",
"description": "JSON Schema for the asset downloader config.",
"type": "object",
"properties": {
"paths": {
"type": "object",
"description": "Various I/O paths.",
"properties": {
"downloaded": {
"type": "string",
"description": "Root directory for storing the downloaded/unextracted assets."
},
"lib": {
"type": "string",
"description": "Root directory for the external libraries."
},
"export": {
"type": "string",
"description": "Root directory for the exported files."
},
"index": {
"type": "string",
"description": "Root directory for the indexing files."
},
"log": {
"type": "string",
"description": "Root directory for the log files."
}
},
"required": [
"downloaded",
"lib",
"export",
"index",
"log"
],
"additionalProperties": false
},
"assets": {
"type": "array",
"description": "Asset exporting tasks.",
"items": {
"type": "object",
"description": "A single asset exporting task. Note that the objects will be exported only if it pass all the regex tests in its task.",
"properties": {
"task": {
"type": "string",
"description": "Name of the asset exporting task."
},
"name": {
"type": "string",
"description": "Regex of the asset name to export. This has to be a full match. Note that the dependency assets of a main asset selected by a task always pass this test."
},
"type": {
"type": "string",
"description": "Type of the export task.",
"enum": [
"MonoBehaviour",
"GameObject",
"AnimatorController",
"AnimatorOverrideController",
"Texture2D",
"Texture2D-Alpha",
"Texture2D-Story",
"Sprite"
]
},
"filter": {
"type": "array",
"description": "Export the objects that pass one of these filters and all the conditions of a filter. Note that these filters are only apply to the main asset. Dependency assets always pass the tests unless it is selected as main assets.",
"items": {
"type": "object",
"description": "A single filter. Objects that pass all conditions of a filter will be exported.",
"properties": {
"container": {
"type": "string",
"description": "Regex test for the container name. This can be a partial match."
},
"name": {
"type": "string",
"description": "Regex test for the object name. This can be a partial match."
}
},
"required": [
"container"
],
"additionalProperties": false
},
"minItems": 1,
"uniqueItems": true
},
"isMultiLocale": {
"type": "boolean",
"description": "If true, the task will perform on all locale. Otherwise, the task only perform on the master (JP) locale.",
"default": false
},
"suppressWarnings": {
"type": "array",
"description": "Types of warning message to suppress.",
"items": {
"type": "string",
"description": "Warning message type to suppress.",
"enum": [
"nothingToExport",
"noMainTexture"
]
}
}
},
"required": [
"task",
"name",
"type",
"filter"
],
"additionalProperties": false
},
"uniqueItems": true
},
"raw": {
"type": "array",
"description": "Raw asset exporting tasks.",
"items": {
"type": "object",
"description": "A single raw asset exporting task. Note that the objects will be exported only if it pass all the regex tests in its task.",
"properties": {
"task": {
"type": "string",
"description": "Name of the raw asset exporting task."
},
"name": {
"type": "string",
"description": "Regex of the asset name to export. This has to be a full match."
},
"isMultiLocale": {
"type": "boolean",
"description": "If true, the task will perform on all locale. Otherwise, the task only perform on the master (JP) locale.",
"default": false
}
},
"required": [
"task",
"name"
],
"additionalProperties": false
},
"uniqueItems": true
}
},
"required": [
"paths",
"assets",
"raw"
],
"additionalProperties": false
}
82 changes: 82 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
paths:
downloaded: .exclude/downloaded
lib: lib
export: .exclude/media
index: .exclude/index
log: .exclude/logs

assets:
- task: Master Assets (all)
name: master
type: MonoBehaviour
filter:
- container: /resources/master/

- task: Master Assets (text label)
name: master
type: MonoBehaviour
filter:
- container: /resources/master/textlabel
isMultiLocale: true

- task: Action Scripts
name: actions
type: GameObject
filter:
- container: /resources/actions/

- task: Action Parts List
name: actions
type: MonoBehaviour
filter:
- container: /resources/actions/actionpartslist

- task: Animation Data (Base Controller)
name: ((characters|dragon)/motion/|meshes/dragon)
type: AnimatorController
filter:
- container: /resources/characters/motion/(.*)\.controller
suppressWarnings:
- nothingToExport

- task: Animation Data (Override Controller)
name: ((characters|dragon)/motion/|meshes/dragon)
type: AnimatorOverrideController
filter:
- container: /resources/characters/motion/(.*)\.overridecontroller
suppressWarnings:
- nothingToExport

- task: UI Sprites
name: images/ingame/ui
type: Sprite
filter:
- container: /resources/images/ingame/ui/atlas/ui
isMultiLocale: true

- task: Icons
name: images/icon/
type: Texture2D-Alpha
filter:
- container: /resources/images/icon/
isMultiLocale: true

- task: Unit Image
name: images/outgame/unitdetail/(amulet|chara|dragon)
type: Texture2D
filter:
- container: /resources/images/outgame/unitdetail

- task: Story Image
name: emotion/story
type: Texture2D-Story
filter:
- container: /resources/emotion/story

- task: Story Content
name: story/(unit|castle|quest)story/
type: MonoBehaviour
filter:
- container: /resources/story

raw: [ ]
3 changes: 0 additions & 3 deletions dlasset/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
"""Implementations to download and pre-process the assets."""
from .dummy import workflow

__all__ = ("workflow",)
3 changes: 3 additions & 0 deletions dlasset/config/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""Implementations for the downloader config."""
from .load import load_config
from .model import * # noqa
30 changes: 30 additions & 0 deletions dlasset/config/load.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""Implementations to load the config file."""
import json
from typing import Any, cast

import yaml
from jsonschema import ValidationError, validate

from .model import Config

__all__ = ("load_config",)


def load_config(path: str) -> Config:
"""
Load and validate the config.
Raises :class:`ValueError` if the config schema doesn't match.
"""
with open(path, encoding="utf-8") as f:
config = cast(dict[Any, Any], yaml.safe_load(f))

with open("config.schema.json", encoding="utf-8") as f:
schema = cast(dict[Any, Any], json.load(f))

try:
validate(instance=config, schema=schema)
except ValidationError as ex:
raise ValueError("Config validation failed") from ex

return Config(config)
4 changes: 4 additions & 0 deletions dlasset/config/model/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"""Config data model classes."""
from .main import Config
from .task import AssetRawTask, AssetTask, AssetTaskFilter
from .types import ExportType, UnityType
13 changes: 13 additions & 0 deletions dlasset/config/model/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""Base config object class."""
from abc import ABC
from dataclasses import dataclass

from dlasset.model import JsonModel

__all__ = ("ConfigBase",)


# https://github.com/python/mypy/issues/5374
@dataclass # type: ignore
class ConfigBase(JsonModel, ABC):
"""Base class of a config data."""
Loading

0 comments on commit c1d512d

Please sign in to comment.