Пример #1
0
    def __init__(self, options, media_source):
        self.media_source    = media_source
        self.format          = None

        filename = media_source.filename
        self.media_name = os.path.basename(filename)
        if options.debug:
            print 'Processing Subtitles file', filename

        self.size = os.path.getsize(filename)

        self.language = media_source.spec.get('+language')
        self.language_name = 'Unknown'
        if not self.language:
            self.language = 'unknown'
##
## PAC
##
        self.two_letter_language = 'und'
        if len(self.language) == 3:
            # convert to 2 char code
            # self.language = LanguageCodeMap.get(self.language, self.language)
            self.two_letter_language = LanguageCodeMap.get(self.language, self.language) ### PAC
            
        language_name = LanguageNames.get(self.two_letter_language, self.language_name)  ### PAC
        self.language_name = media_source.spec.get('+language_name', language_name)

        if media_source.format == 'ttml':
            self.parse_ttml(options)
        elif media_source.format == 'webvtt':
            self.parse_webvtt(options)

        if '+media' in media_source.spec:
            self.media_name = media_source.spec['+media']
Пример #2
0
    def __init__(self, options, media_source):
        self.media_source    = media_source
        self.format          = None

        filename = media_source.filename
        self.media_name = os.path.basename(filename)
        if options.debug:
            print 'Processing Subtitles file', filename

        self.size = os.path.getsize(filename)

        self.language = media_source.spec.get('+language')
        self.language_name = 'Unknown'
        if not self.language:
            self.language = 'unknown'

        if len(self.language) == 3:
            # convert to 2 char code
            self.language = LanguageCodeMap.get(self.language, self.language)
        language_name = LanguageNames.get(self.language, self.language_name)
        self.language_name = media_source.spec.get('+language_name', language_name)

        if media_source.format == 'ttml':
            self.parse_ttml(options)
        elif media_source.format == 'webvtt':
            self.parse_webvtt(options)

        if '+media' in media_source.spec:
            self.media_name = media_source.spec['+media']
Пример #3
0
def SelectAudioTracks(options, media_sources):
    # select tracks grouped by codec
    audio_tracks = {}
    for media_source in media_sources:

        # pre-process the track metadata
        for track in media_source.tracks:
            # track group
            track.group_id = ComputeCodecName(track.codec_family)

            # track language
            remap_language = media_source.spec.get('+language')
            if remap_language:
                track.language = remap_language
            language_name = LanguageNames.get(track.language, track.language)
            track.language_name = media_source.spec.get(
                '+language_name', language_name)

        # process audio tracks
        for track in [t for t in media_source.tracks if t.type == 'audio']:
            group_id = track.group_id
            group = audio_tracks.get(group_id, [])
            audio_tracks[group_id] = group
            if len([x for x in group if x.language == track.language]):
                continue  # only accept one track for each language per group
            group.append(track)

    return audio_tracks
Пример #4
0
    def __init__(self, options, media_source):
        self.media_source = media_source
        self.format = None

        filename = media_source.filename
        self.media_name = path.basename(filename)
        if options.debug:
            print('Processing Subtitles file', filename)

        self.size = path.getsize(filename)

        self.language = media_source.spec.get('+language')
        self.language_name = 'Unknown'
        if not self.language:
            self.language = 'unknown'

        if len(self.language) == 3:
            # convert to 2 char code
            self.language = LanguageCodeMap.get(self.language, self.language)
        language_name = LanguageNames.get(self.language, self.language_name)
        self.language_name = media_source.spec.get('+language_name',
                                                   language_name)

        if media_source.format == 'ttml':
            self.parse_ttml(options)
        elif media_source.format == 'webvtt':
            self.parse_webvtt(options)

        if '+media' in media_source.spec:
            self.media_name = media_source.spec['+media']

        # HLS options
        self.hls_default = media_source.spec.get(
            '+hls_default', None)  # None means: unspecified
        if self.hls_default is not None:
            self.hls_default = BooleanFromString(self.hls_default)
        self.hls_autoselect = BooleanFromString(
            media_source.spec.get('+hls_autoselect', 'YES'))
        self.hls_group = media_source.spec.get('+hls_group')
        self.hls_group_match = media_source.spec.get('+hls_group_match',
                                                     '*').split('&')