4 from .base
import importer
5 from ..parsers.baseporter
import ExtraOption
6 from ..parsers.tgs
import parse_tgs
7 from ..objects
import Animation, assets
10 @importer("dotLottie Archive", ["lottie"], [
ExtraOption("id", help="ID of the animation to extract", default=None)
13 with zipfile.ZipFile(file)
as zf:
14 with zf.open(
"manifest.json")
as manifest:
15 meta = json.load(manifest)
18 id = meta[
"animations"][0][
"id"]
20 info = zf.getinfo(
"animations/%s.json" % id)
22 with zf.open(info)
as animfile:
23 an = Animation.load(json.load(animfile))
25 for asset
in an.assets:
26 if isinstance(asset, assets.Image)
and not asset.is_embedded:
27 fname = asset.image_path + asset.image
28 if fname
in zf.namelist():
29 with zf.open(fname)
as imgfile:
32 def import_dotlottie(file, id=None)