from manifest_edit.plugin.m3u8_main 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 1: to remove the iframe playlists from a HLS master playlist:
        #manifest.iFrameStreams.clear()

        # Example 2: to change the NAME tag of the German subtitles to "Deutsch":
        #for media in manifest.medias:
        #    if media.type == 'SUBTITLES' and media.name == 'German':
        #        media.name = 'Deutsch'
