from manifest_edit.plugin.mpd import BasePlugin
from schema import Schema
from manifest_edit.context import Context


class Plugin(BasePlugin):
    """
    custom plugin.

    By default, this plugin has no specified behaviour except leaving the
    manifest as-is. You can customize the handling of the manifest in any way
    that you want, by editing the process() function below.
    """

    _name = __name__

    def schema(self):
        return Schema({})

    def process(self, manifest, storage):
        Context.log_debug('custom plugin processing start')

        # Add python statements that modify 'manifest' here.

        # Example: to modify the codecs attribute for text (subtitle) tracks
        # from "stpp.ttml.im1t" to "stpp":
        #for period in manifest.periods:
        #    for adaptation_set in period.adaptationSets:
        #        if adaptation_set.common.codecs == 'stpp.ttml.im1t':
        #            adaptation_set.common.codecs = 'stpp'
