code:
from __future__ import unicode_literals

import os
import re
import subprocess
import time

from .common import FileDownloader
from ..compat import compat_str
from ..utils import (
    check_executable,
    encodeFilename,
    encodeArgument,
    get_exe_version,
)

def rtmpdump_version():
    return get_exe_version(
        'rtmpdump', ['--help'], r'(?i)RTMPDump\s*v?([0-9a-zA-Z._-]+)')

class RtmpFD(FileDownloader):
    def real_download(self, filename, info_dict):
        def run_rtmpdump(args):
            start = time.time()
            resume_percent = None
            resume_downloaded_data_len = None
            proc = subprocess.Popen(args, stderr=subprocess.PIPE)
            cursor_in_new_line = True
            proc_stderr_closed = False
            try:
                while not proc_stderr_closed:
                    # read line from stderr
                    line = ''
                    while True:
                        char = proc.stderr.read(1)
                        if not char:
                            proc_stderr_closed = True
                            break
                        if char in [b'\r', b'\n']:
                            break
                        line += char.decode('ascii', 'replace')
                    if not line:
                        # proc_stderr_closed is True
                        continue
                    mobj = re.search(r'([0-9]+\.[0-9]{3}) kB / [0-9]+\.[0-9]{2} sec \(([0-9]{1,2}\.[0-9])%\)', line)
                    if mobj:
                        downloaded_data_len = int(float(mobj.group(1)) * 1024)
                        percent = float(mobj.group(2))
                        if not resume_percent:
                            resume_percent = percent
                            resume_downloaded_data_len = downloaded_data_len
                        time_now = time.time()
                        eta = self.calc_eta(start, time_now, 100 - resume_percent, percent - resume_percent)
                        speed = self.calc_speed(start, time_now, downloaded_data_len - resume_downloaded_data_len)
                        data_len = None
                        if percent > 0:
                            data_len = int(downloaded_data_len * 100 / percent)
                        self._hook_progress({
                            'status': 'downloading',
                            'downloaded_bytes': downloaded_data_len,
                            'total_bytes_estimate': data_len,
                            'tmpfilename': tmpfilename,
                            'filename': filename,
                            'eta': eta,
                            'elapsed': time_now - start,
                            'speed': speed,
                        })
                        cursor_in_new_line = False
                    else:
                        # no percent for live streams
                        mobj = re.search(r'([0-9]+\.[0-9]{3}) kB / [0-9]+\.[0-9]{2} sec', line)
                        if mobj:
                            downloaded_data_len = int(float(mobj.group(1)) * 1024)
                            time_now = time.time()
                            speed = self.calc_speed(start, time_now, downloaded_data_len)
                            self._hook_progress({
                                'downloaded_bytes': downloaded_data_len,
                                'tmpfilename': tmpfilename,
                                'filename': filename,
                                'status': 'downloading',
                                'elapsed': time_now - start,
                                'speed': speed,
                            })
                            cursor_in_new_line = False
                        elif self.params.get('verbose', False):
                            if not cursor_in_new_line:
                                self.to_screen('')
                            cursor_in_new_line = True
                            self.to_screen('[rtmpdump] ' + line)
            finally:
                proc.wait()
            if not cursor_in_new_line:
                self.to_screen('')
            return proc.returncode

        url = info_dict['url']
        player_url = info_dict.get('player_url')
        page_url = info_dict.get('page_url')
        app = info_dict.get('app')
        play_path = info_dict.get('play_path')
        tc_url = info_dict.get('tc_url')
        flash_version = info_dict.get('flash_version')
        live = info_dict.get('rtmp_live', False)
        conn = info_dict.get('rtmp_conn')
        protocol = info_dict.get('rtmp_protocol')
        real_time = info_dict.get('rtmp_real_time', False)
        no_resume = info_dict.get('no_resume', False)
        continue_dl = self.params.get('continuedl', True)

        self.report_destination(filename)
        tmpfilename = self.temp_name(filename)
        test = self.params.get('test', False)

        # Check for rtmpdump first
        if not check_executable('rtmpdump', ['-h']):
            self.report_error('RTMP download detected but "rtmpdump" could not be run. Please install it.')
            return False

        # Download using rtmpdump. rtmpdump returns exit code 2 when
        # the connection was interrupted and resuming appears to be
        # possible. This is part of rtmpdump's normal usage, AFAIK.
        basic_args = [
            'rtmpdump', '--verbose', '-r', url,
            '-o', tmpfilename]
        if player_url is not None:
            basic_args += ['--swfVfy', player_url]
        if page_url is not None:
            basic_args += ['--pageUrl', page_url]
        if app is not None:
            basic_args += ['--app', app]
        if play_path is not None:
            basic_args += ['--playpath', play_path]
        if tc_url is not None:
            basic_args += ['--tcUrl', tc_url]
        if test:
            basic_args += ['--stop', '1']
        if flash_version is not None:
            basic_args += ['--flashVer', flash_version]
        if live:
            basic_args += ['--live']
        if isinstance(conn, list):
            for entry in conn:
                basic_args += ['--conn', entry]
        elif isinstance(conn, compat_str):
            basic_args += ['--conn', conn]
        if protocol is not None:
            basic_args += ['--protocol', protocol]
        if real_time:
            basic_args += ['--realtime']

        args = basic_args
        if not no_resume and continue_dl and not live:
            args += ['--resume']
        if not live and continue_dl:
            args += ['--skip', '1']

        args = [encodeArgument(a) for a in args]

        self._debug_cmd(args, exe='rtmpdump')

        RD_SUCCESS = 0
        RD_FAILED = 1
        RD_INCOMPLETE = 2
        RD_NO_CONNECT = 3

        started = time.time()

        try:
            retval = run_rtmpdump(args)
        except KeyboardInterrupt:
            if not info_dict.get('is_live'):
                raise
            retval = RD_SUCCESS
            self.to_screen('\n[rtmpdump] Interrupted by user')

        if retval == RD_NO_CONNECT:
            self.report_error('[rtmpdump] Could not connect to RTMP server.')
            return False

        while retval in (RD_INCOMPLETE, RD_FAILED) and not test and not live:
            prevsize = os.path.getsize(encodeFilename(tmpfilename))
            self.to_screen('[rtmpdump] Downloaded %s bytes' % prevsize)
            time.sleep(5.0)  # This seems to be needed
            args = basic_args + ['--resume']
            if retval == RD_FAILED:
                args += ['--skip', '1']
            args = [encodeArgument(a) for a in args]
            retval = run_rtmpdump(args)
            cursize = os.path.getsize(encodeFilename(tmpfilename))
            if prevsize == cursize and retval == RD_FAILED:
                break
            # Some rtmp streams seem abort after ~ 99.8%. Don't complain for those
            if prevsize == cursize and retval == RD_INCOMPLETE and cursize > 1024:
                self.to_screen('[rtmpdump] Could not download the whole video. This can happen for some advertisements.')
                retval = RD_SUCCESS
                break
        if retval == RD_SUCCESS or (test and retval == RD_INCOMPLETE):
            fsize = os.path.getsize(encodeFilename(tmpfilename))
            self.to_screen('[rtmpdump] Downloaded %s bytes' % fsize)
            self.try_rename(tmpfilename, filename)
            self._hook_progress({
                'downloaded_bytes': fsize,
                'total_bytes': fsize,
                'filename': filename,
                'status': 'finished',
                'elapsed': time.time() - started,
            })
            return True
        else:
            self.to_stderr('\n')
            self.report_error('rtmpdump exited with code %d' % retval)
            return False


code:
from __future__ import unicode_literals

import os
import subprocess

from .common import FileDownloader
from ..utils import (
    check_executable,
    encodeFilename,
)

class RtspFD(FileDownloader):
    def real_download(self, filename, info_dict):
        url = info_dict['url']
        self.report_destination(filename)
        tmpfilename = self.temp_name(filename)

        if check_executable('mplayer', ['-h']):
            args = [
                'mplayer', '-really-quiet', '-vo', 'null', '-vc', 'dummy',
                '-dumpstream', '-dumpfile', tmpfilename, url]
        elif check_executable('mpv', ['-h']):
            args = [
                'mpv', '-really-quiet', '--vo=null', '--stream-dump=' + tmpfilename, url]
        else:
            self.report_error('MMS or RTSP download detected but neither "mplayer" nor "mpv" could be run. Please install any.')
            return False

        self._debug_cmd(args)

        retval = subprocess.call(args)
        if retval == 0:
            fsize = os.path.getsize(encodeFilename(tmpfilename))
            self.to_screen('\r[%s] %s bytes' % (args[0], fsize))
            self.try_rename(tmpfilename, filename)
            self._hook_progress({
                'downloaded_bytes': fsize,
                'total_bytes': fsize,
                'filename': filename,
                'status': 'finished',
            })
            return True
        else:
            self.to_stderr('\n')
            self.report_error('%s exited with code %d' % (args[0], retval))
            return False

repo_name: rrosajp/youtube


code:
from __future__ import unicode_literals

try:
    from .lazy_extractors import *
    from .lazy_extractors import _ALL_CLASSES
    _LAZY_LOADER = True
except ImportError:
    _LAZY_LOADER = False
    from .extractors import *

    _ALL_CLASSES = [
        klass
        for name, klass in globals().items()
        if name.endswith('IE') and name != 'GenericIE'
    ]
    _ALL_CLASSES.append(GenericIE)

def gen_extractor_classes():
    """ Return a list of supported extractors.
    The order does matter; the first extractor matched is the one handling the URL.
    """
    return _ALL_CLASSES

def gen_extractors():
    """ Return a list of an instance of every supported extractor.
    The order does matter; the first extractor matched is the one handling the URL.
    """
    return [klass() for klass in gen_extractor_classes()]

def list_extractors(age_limit):
    """
    Return a list of extractors that are suitable for the given age,
    sorted by extractor ID.
    """

    return sorted(
        filter(lambda ie: ie.is_suitable(age_limit), gen_extractors()),
        key=lambda ie: ie.IE_NAME.lower())

def get_info_extractor(ie_name):
    """Returns the info extractor class with the given ie_name"""
    return globals()[ie_name + 'IE']


code:
from __future__ import unicode_literals

import hashlib
import hmac
import re
import time

from .common import InfoExtractor
from ..compat import compat_str
from ..utils import (
    ExtractorError,
    js_to_json,
    int_or_none,
    parse_iso8601,
    try_get,
    unescapeHTML,
    update_url_query,
)

class ABCIE(InfoExtractor):
    IE_NAME = 'abc.net.au'
    _VALID_URL = r'https?://(?:www\.)?abc\.net\.au/news/(?:[^/]+/){1,2}(?P<id>\d+)'

    _TESTS = [{
        'url': 'http://www.abc.net.au/news/2014-11-05/australia-to-staff-ebola-treatment-centre-in-sierra-leone/5868334',
        'md5': 'cb3dd03b18455a661071ee1e28344d9f',
        'info_dict': {
            'id': '5868334',
            'ext': 'mp4',
            'title': 'Australia to help staff Ebola treatment centre in Sierra Leone',
            'description': 'md5:809ad29c67a05f54eb41f2a105693a67',
        },
        'skip': 'this video has expired',
    }, {
        'url': 'http://www.abc.net.au/news/2015-08-17/warren-entsch-introduces-same-sex-marriage-bill/6702326',
        'md5': 'db2a5369238b51f9811ad815b69dc086',
        'info_dict': {
            'id': 'NvqvPeNZsHU',
            'ext': 'mp4',
            'upload_date': '20150816',
            'uploader': 'ABC News (Australia)',
            'description': 'Government backbencher Warren Entsch introduces a cross-party sponsored bill to legalise same-sex marriage, saying the bill is designed to promote "an inclusive Australia, not a divided one.". Read more here: http://ab.co/1Mwc6ef',
            'uploader_id': 'NewsOnABC',
            'title': 'Marriage Equality: Warren Entsch introduces same sex marriage bill',
        },
        'add_ie': ['Youtube'],
        'skip': 'Not accessible from Travis CI server',
    }, {
        'url': 'http://www.abc.net.au/news/2015-10-23/nab-lifts-interest-rates-following-westpac-and-cba/6880080',
        'md5': 'b96eee7c9edf4fc5a358a0252881cc1f',
        'info_dict': {
            'id': '6880080',
            'ext': 'mp3',
            'title': 'NAB lifts interest rates, following Westpac and CBA',
            'description': 'md5:f13d8edc81e462fce4a0437c7dc04728',
        },
    }, {
        'url': 'http://www.abc.net.au/news/2015-10-19/6866214',
        'only_matching': True,
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)

        mobj = re.search(
            r'inline(?P<type>Video|Audio|YouTube)Data\.push\((?P<json_data>[^)]+)\);',
            webpage)
        if mobj is None:
            expired = self._html_search_regex(r'(?s)class="expired-(?:video|audio)".+?<span>(.+?)</span>', webpage, 'expired', None)
            if expired:
                raise ExtractorError('%s said: %s' % (self.IE_NAME, expired), expected=True)
            raise ExtractorError('Unable to extract video urls')

        urls_info = self._parse_json(
            mobj.group('json_data'), video_id, transform_source=js_to_json)

        if not isinstance(urls_info, list):
            urls_info = [urls_info]

        if mobj.group('type') == 'YouTube':
            return self.playlist_result([
                self.url_result(url_info['url']) for url_info in urls_info])

        formats = [{
            'url': url_info['url'],
            'vcodec': url_info.get('codec') if mobj.group('type') == 'Video' else 'none',
            'width': int_or_none(url_info.get('width')),
            'height': int_or_none(url_info.get('height')),
            'tbr': int_or_none(url_info.get('bitrate')),
            'filesize': int_or_none(url_info.get('filesize')),
        } for url_info in urls_info]

        self._sort_formats(formats)

        return {
            'id': video_id,
            'title': self._og_search_title(webpage),
            'formats': formats,
            'description': self._og_search_description(webpage),
            'thumbnail': self._og_search_thumbnail(webpage),
        }

class ABCIViewIE(InfoExtractor):
    IE_NAME = 'abc.net.au:iview'
    _VALID_URL = r'https?://iview\.abc\.net\.au/(?:[^/]+/)*video/(?P<id>[^/?#]+)'
    _GEO_COUNTRIES = ['AU']

    # ABC iview programs are normally available for 14 days only.
    _TESTS = [{
        'url': 'https://iview.abc.net.au/show/gruen/series/11/video/LE1927H001S00',
        'md5': '67715ce3c78426b11ba167d875ac6abf',
        'info_dict': {
            'id': 'LE1927H001S00',
            'ext': 'mp4',
            'title': "Series 11 Ep 1",
            'series': "Gruen",
            'description': 'md5:52cc744ad35045baf6aded2ce7287f67',
            'upload_date': '20190925',
            'uploader_id': 'abc1',
            'timestamp': 1569445289,
        },
        'params': {
            'skip_download': True,
        },
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        video_params = self._download_json(
            'https://iview.abc.net.au/api/programs/' + video_id, video_id)
        title = unescapeHTML(video_params.get('title') or video_params['seriesTitle'])
        stream = next(s for s in video_params['playlist'] if s.get('type') in ('program', 'livestream'))

        house_number = video_params.get('episodeHouseNumber') or video_id
        path = '/auth/hls/sign?ts={0}&hn={1}&d=android-tablet'.format(
            int(time.time()), house_number)
        sig = hmac.new(
            b'android.content.res.Resources',
            path.encode('utf-8'), hashlib.sha256).hexdigest()
        token = self._download_webpage(
            'http://iview.abc.net.au{0}&sig={1}'.format(path, sig), video_id)

        def tokenize_url(url, token):
            return update_url_query(url, {
                'hdnea': token,
            })

        for sd in ('720', 'sd', 'sd-low'):
            sd_url = try_get(
                stream, lambda x: x['streams']['hls'][sd], compat_str)
            if not sd_url:
                continue
            formats = self._extract_m3u8_formats(
                tokenize_url(sd_url, token), video_id, 'mp4',
                entry_protocol='m3u8_native', m3u8_id='hls', fatal=False)
            if formats:
                break
        self._sort_formats(formats)

        subtitles = {}
        src_vtt = stream.get('captions', {}).get('src-vtt')
        if src_vtt:
            subtitles['en'] = [{
                'url': src_vtt,
                'ext': 'vtt',
            }]

        is_live = video_params.get('livestream') == '1'
        if is_live:
            title = self._live_title(title)

        return {
            'id': video_id,
            'title': title,
            'description': video_params.get('description'),
            'thumbnail': video_params.get('thumbnail'),
            'duration': int_or_none(video_params.get('eventDuration')),
            'timestamp': parse_iso8601(video_params.get('pubDate'), ' '),
            'series': unescapeHTML(video_params.get('seriesTitle')),
            'series_id': video_params.get('seriesHouseNumber') or video_id[:7],
            'season_number': int_or_none(self._search_regex(
                r'\bSeries\s+(\d+)\b', title, 'season number', default=None)),
            'episode_number': int_or_none(self._search_regex(
                r'\bEp\s+(\d+)\b', title, 'episode number', default=None)),
            'episode_id': house_number,
            'uploader_id': video_params.get('channel'),
            'formats': formats,
            'subtitles': subtitles,
            'is_live': is_live,
        }


code:
# coding: utf-8
from __future__ import unicode_literals

import calendar
import re
import time

from .amp import AMPIE
from .common import InfoExtractor
from .youtube import YoutubeIE
from ..compat import compat_urlparse

class AbcNewsVideoIE(AMPIE):
    IE_NAME = 'abcnews:video'
    _VALID_URL = r'''(?x)
                    https?://
                        (?:
                            abcnews\.go\.com/
                            (?:
                                [^/]+/video/(?P<display_id>[0-9a-z-]+)-|
                                video/embed\?.*?\bid=
                            )|
                            fivethirtyeight\.abcnews\.go\.com/video/embed/\d+/
                        )
                        (?P<id>\d+)
                    '''

    _TESTS = [{
        'url': 'http://abcnews.go.com/ThisWeek/video/week-exclusive-irans-foreign-minister-zarif-20411932',
        'info_dict': {
            'id': '20411932',
            'ext': 'mp4',
            'display_id': 'week-exclusive-irans-foreign-minister-zarif',
            'title': '\'This Week\' Exclusive: Iran\'s Foreign Minister Zarif',
            'description': 'George Stephanopoulos goes one-on-one with Iranian Foreign Minister Dr. Javad Zarif.',
            'duration': 180,
            'thumbnail': r're:^https?://.*\.jpg$',
        },
        'params': {
            # m3u8 download
            'skip_download': True,
        },
    }, {
        'url': 'http://abcnews.go.com/video/embed?id=46979033',
        'only_matching': True,
    }, {
        'url': 'http://abcnews.go.com/2020/video/2020-husband-stands-teacher-jail-student-affairs-26119478',
        'only_matching': True,
    }]

    def _real_extract(self, url):
        mobj = re.match(self._VALID_URL, url)
        display_id = mobj.group('display_id')
        video_id = mobj.group('id')
        info_dict = self._extract_feed_info(
            'http://abcnews.go.com/video/itemfeed?id=%s' % video_id)
        info_dict.update({
            'id': video_id,
            'display_id': display_id,
        })
        return info_dict

class AbcNewsIE(InfoExtractor):
    IE_NAME = 'abcnews'
    _VALID_URL = r'https?://abcnews\.go\.com/(?:[^/]+/)+(?P<display_id>[0-9a-z-]+)/story\?id=(?P<id>\d+)'

    _TESTS = [{
        'url': 'http://abcnews.go.com/Blotter/News/dramatic-video-rare-death-job-america/story?id=10498713#.UIhwosWHLjY',
        'info_dict': {
            'id': '10505354',
            'ext': 'flv',
            'display_id': 'dramatic-video-rare-death-job-america',
            'title': 'Occupational Hazards',
            'description': 'Nightline investigates the dangers that lurk at various jobs.',
            'thumbnail': r're:^https?://.*\.jpg$',
            'upload_date': '20100428',
            'timestamp': 1272412800,
        },
        'add_ie': ['AbcNewsVideo'],
    }, {
        'url': 'http://abcnews.go.com/Entertainment/justin-timberlake-performs-stop-feeling-eurovision-2016/story?id=39125818',
        'info_dict': {
            'id': '38897857',
            'ext': 'mp4',
            'display_id': 'justin-timberlake-performs-stop-feeling-eurovision-2016',
            'title': 'Justin Timberlake Drops Hints For Secret Single',
            'description': 'Lara Spencer reports the buzziest stories of the day in "GMA" Pop News.',
            'upload_date': '20160515',
            'timestamp': 1463329500,
        },
        'params': {
            # m3u8 download
            'skip_download': True,
            # The embedded YouTube video is blocked due to copyright issues
            'playlist_items': '1',
        },
        'add_ie': ['AbcNewsVideo'],
    }, {
        'url': 'http://abcnews.go.com/Technology/exclusive-apple-ceo-tim-cook-iphone-cracking-software/story?id=37173343',
        'only_matching': True,
    }]

    def _real_extract(self, url):
        mobj = re.match(self._VALID_URL, url)
        display_id = mobj.group('display_id')
        video_id = mobj.group('id')

        webpage = self._download_webpage(url, video_id)
        video_url = self._search_regex(
            r'window\.abcnvideo\.url\s*=\s*"([^"]+)"', webpage, 'video URL')
        full_video_url = compat_urlparse.urljoin(url, video_url)

        youtube_url = YoutubeIE._extract_url(webpage)

        timestamp = None
        date_str = self._html_search_regex(
            r'<span[^>]+class="timestamp">([^<]+)</span>',
            webpage, 'timestamp', fatal=False)
        if date_str:
            tz_offset = 0
            if date_str.endswith(' ET'):  # Eastern Time
                tz_offset = -5
                date_str = date_str[:-3]
            date_formats = ['%b. %d, %Y', '%b %d, %Y, %I:%M %p']
            for date_format in date_formats:
                try:
                    timestamp = calendar.timegm(time.strptime(date_str.strip(), date_format))
                except ValueError:
                    continue
            if timestamp is not None:
                timestamp -= tz_offset * 3600

        entry = {
            '_type': 'url_transparent',
            'ie_key': AbcNewsVideoIE.ie_key(),
            'url': full_video_url,
            'id': video_id,
            'display_id': display_id,
            'timestamp': timestamp,
        }

        if youtube_url:
            entries = [entry, self.url_result(youtube_url, ie=YoutubeIE.ie_key())]
            return self.playlist_result(entries)

        return entry


code:
# coding: utf-8
from __future__ import unicode_literals

import re

from .common import InfoExtractor
from ..compat import compat_str
from ..utils import (
    dict_get,
    int_or_none,
    try_get,
)

class ABCOTVSIE(InfoExtractor):
    IE_NAME = 'abcotvs'
    IE_DESC = 'ABC Owned Television Stations'
    _VALID_URL = r'https?://(?P<site>abc(?:7(?:news|ny|chicago)?|11|13|30)|6abc)\.com(?:(?:/[^/]+)*/(?P<display_id>[^/]+))?/(?P<id>\d+)'
    _TESTS = [
        {
            'url': 'http://abc7news.com/entertainment/east-bay-museum-celebrates-vintage-synthesizers/472581/',
            'info_dict': {
                'id': '472548',
                'display_id': 'east-bay-museum-celebrates-vintage-synthesizers',
                'ext': 'mp4',
                'title': 'East Bay museum celebrates synthesized music',
                'description': 'md5:24ed2bd527096ec2a5c67b9d5a9005f3',
                'thumbnail': r're:^https?://.*\.jpg$',
                'timestamp': 1421118520,
                'upload_date': '20150113',
            },
            'params': {
                # m3u8 download
                'skip_download': True,
            },
        },
        {
            'url': 'http://abc7news.com/472581',
            'only_matching': True,
        },
        {
            'url': 'https://6abc.com/man-75-killed-after-being-struck-by-vehicle-in-chester/5725182/',
            'only_matching': True,
        },
    ]
    _SITE_MAP = {
        '6abc': 'wpvi',
        'abc11': 'wtvd',
        'abc13': 'ktrk',
        'abc30': 'kfsn',
        'abc7': 'kabc',
        'abc7chicago': 'wls',
        'abc7news': 'kgo',
        'abc7ny': 'wabc',
    }

    def _real_extract(self, url):
        site, display_id, video_id = re.match(self._VALID_URL, url).groups()
        display_id = display_id or video_id
        station = self._SITE_MAP[site]

        data = self._download_json(
            'https://api.abcotvs.com/v2/content', display_id, query={
                'id': video_id,
                'key': 'otv.web.%s.story' % station,
                'station': station,
            })['data']
        video = try_get(data, lambda x: x['featuredMedia']['video'], dict) or data
        video_id = compat_str(dict_get(video, ('id', 'publishedKey'), video_id))
        title = video.get('title') or video['linkText']

        formats = []
        m3u8_url = video.get('m3u8')
        if m3u8_url:
            formats = self._extract_m3u8_formats(
                video['m3u8'].split('?')[0], display_id, 'mp4', m3u8_id='hls', fatal=False)
        mp4_url = video.get('mp4')
        if mp4_url:
            formats.append({
                'abr': 128,
                'format_id': 'https',
                'height': 360,
                'url': mp4_url,
                'width': 640,
            })
        self._sort_formats(formats)

        image = video.get('image') or {}

        return {
            'id': video_id,
            'display_id': display_id,
            'title': title,
            'description': dict_get(video, ('description', 'caption'), try_get(video, lambda x: x['meta']['description'])),
            'thumbnail': dict_get(image, ('source', 'dynamicSource')),
            'timestamp': int_or_none(video.get('date')),
            'duration': int_or_none(video.get('length')),
            'formats': formats,
        }

class ABCOTVSClipsIE(InfoExtractor):
    IE_NAME = 'abcotvs:clips'
    _VALID_URL = r'https?://clips\.abcotvs\.com/(?:[^/]+/)*video/(?P<id>\d+)'
    _TEST = {
        'url': 'https://clips.abcotvs.com/kabc/video/214814',
        'info_dict': {
            'id': '214814',
            'ext': 'mp4',
            'title': 'SpaceX launch pad explosion destroys rocket, satellite',
            'description': 'md5:9f186e5ad8f490f65409965ee9c7be1b',
            'upload_date': '20160901',
            'timestamp': 1472756695,
        },
        'params': {
            # m3u8 download
            'skip_download': True,
        },
    }

    def _real_extract(self, url):
        video_id = self._match_id(url)
        video_data = self._download_json('https://clips.abcotvs.com/vogo/video/getByIds?ids=' + video_id, video_id)['results'][0]
        title = video_data['title']
        formats = self._extract_m3u8_formats(
            video_data['videoURL'].split('?')[0], video_id, 'mp4')
        self._sort_formats(formats)

        return {
            'id': video_id,
            'title': title,
            'description': video_data.get('description'),
            'thumbnail': video_data.get('thumbnailURL'),
            'duration': int_or_none(video_data.get('duration')),
            'timestamp': int_or_none(video_data.get('pubDate')),
            'formats': formats,
        }


code:
from __future__ import unicode_literals

import re

from .common import InfoExtractor

class AcademicEarthCourseIE(InfoExtractor):
    _VALID_URL = r'^https?://(?:www\.)?academicearth\.org/playlists/(?P<id>[^?#/]+)'
    IE_NAME = 'AcademicEarth:Course'
    _TEST = {
        'url': 'http://academicearth.org/playlists/laws-of-nature/',
        'info_dict': {
            'id': 'laws-of-nature',
            'title': 'Laws of Nature',
            'description': 'Introduce yourself to the laws of nature with these free online college lectures from Yale, Harvard, and MIT.',
        },
        'playlist_count': 3,
    }

    def _real_extract(self, url):
        playlist_id = self._match_id(url)

        webpage = self._download_webpage(url, playlist_id)
        title = self._html_search_regex(
            r'
]*?>(.*?)
', webpage, 'title')
        description = self._html_search_regex(
            r'
]*?>(.*?)
',
            webpage, 'description', fatal=False)
        urls = re.findall(
            r'
\s*?',
            webpage)
        entries = [self.url_result(u) for u in urls]

        return {
            '_type': 'playlist',
            'id': playlist_id,
            'title': title,
            'description': description,
            'entries': entries,
        }


code:
# coding: utf-8
from __future__ import unicode_literals

import re
import functools

from .common import InfoExtractor
from ..compat import compat_str
from ..utils import (
    clean_html,
    float_or_none,
    int_or_none,
    try_get,
    unified_timestamp,
    OnDemandPagedList,
)

class ACastIE(InfoExtractor):
    IE_NAME = 'acast'
    _VALID_URL = r'''(?x)
                    https?://
                        (?:
                            (?:(?:embed|www)\.)?acast\.com/|
                            play\.acast\.com/s/
                        )
                        (?P<channel>[^/]+)/(?P<id>[^/#?]+)
                    '''
    _TESTS = [{
        'url': 'https://www.acast.com/sparpodcast/2.raggarmordet-rosterurdetforflutna',
        'md5': '16d936099ec5ca2d5869e3a813ee8dc4',
        'info_dict': {
            'id': '2a92b283-1a75-4ad8-8396-499c641de0d9',
            'ext': 'mp3',
            'title': '2. Raggarmordet - Röster ur det förflutna',
            'description': 'md5:4f81f6d8cf2e12ee21a321d8bca32db4',
            'timestamp': 1477346700,
            'upload_date': '20161024',
            'duration': 2766.602563,
            'creator': 'Anton Berg & Martin Johnson',
            'series': 'Spår',
            'episode': '2. Raggarmordet - Röster ur det förflutna',
        }
    }, {
        'url': 'http://embed.acast.com/adambuxton/ep.12-adam-joeschristmaspodcast2015',
        'only_matching': True,
    }, {
        'url': 'https://play.acast.com/s/rattegangspodden/s04e09-styckmordet-i-helenelund-del-22',
        'only_matching': True,
    }, {
        'url': 'https://play.acast.com/s/sparpodcast/2a92b283-1a75-4ad8-8396-499c641de0d9',
        'only_matching': True,
    }]

    def _real_extract(self, url):
        channel, display_id = re.match(self._VALID_URL, url).groups()
        s = self._download_json(
            'https://feeder.acast.com/api/v1/shows/%s/episodes/%s' % (channel, display_id),
            display_id)
        media_url = s['url']
        if re.search(r'[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}', display_id):
            episode_url = s.get('episodeUrl')
            if episode_url:
                display_id = episode_url
            else:
                channel, display_id = re.match(self._VALID_URL, s['link']).groups()
        cast_data = self._download_json(
            'https://play-api.acast.com/splash/%s/%s' % (channel, display_id),
            display_id)['result']
        e = cast_data['episode']
        title = e.get('name') or s['title']
        return {
            'id': compat_str(e['id']),
            'display_id': display_id,
            'url': media_url,
            'title': title,
            'description': e.get('summary') or clean_html(e.get('description') or s.get('description')),
            'thumbnail': e.get('image'),
            'timestamp': unified_timestamp(e.get('publishingDate') or s.get('publishDate')),
            'duration': float_or_none(e.get('duration') or s.get('duration')),
            'filesize': int_or_none(e.get('contentLength')),
            'creator': try_get(cast_data, lambda x: x['show']['author'], compat_str),
            'series': try_get(cast_data, lambda x: x['show']['name'], compat_str),
            'season_number': int_or_none(e.get('seasonNumber')),
            'episode': title,
            'episode_number': int_or_none(e.get('episodeNumber')),
        }

class ACastChannelIE(InfoExtractor):
    IE_NAME = 'acast:channel'
    _VALID_URL = r'''(?x)
                    https?://
                        (?:
                            (?:www\.)?acast\.com/|
                            play\.acast\.com/s/
                        )
                        (?P<id>[^/#?]+)
                    '''
    _TESTS = [{
        'url': 'https://www.acast.com/todayinfocus',
        'info_dict': {
            'id': '4efc5294-5385-4847-98bd-519799ce5786',
            'title': 'Today in Focus',
            'description': 'md5:9ba5564de5ce897faeb12963f4537a64',
        },
        'playlist_mincount': 35,
    }, {
        'url': 'http://play.acast.com/s/ft-banking-weekly',
        'only_matching': True,
    }]
    _API_BASE_URL = 'https://play.acast.com/api/'
    _PAGE_SIZE = 10

    @classmethod
    def suitable(cls, url):
        return False if ACastIE.suitable(url) else super(ACastChannelIE, cls).suitable(url)

    def _fetch_page(self, channel_slug, page):
        casts = self._download_json(
            self._API_BASE_URL + 'channels/%s/acasts?page=%s' % (channel_slug, page),
            channel_slug, note='Download page %d of channel data' % page)
        for cast in casts:
            yield self.url_result(
                'https://play.acast.com/s/%s/%s' % (channel_slug, cast['url']),
                'ACast', cast['id'])

    def _real_extract(self, url):
        channel_slug = self._match_id(url)
        channel_data = self._download_json(
            self._API_BASE_URL + 'channels/%s' % channel_slug, channel_slug)
        entries = OnDemandPagedList(functools.partial(
            self._fetch_page, channel_slug), self._PAGE_SIZE)
        return self.playlist_result(entries, compat_str(
            channel_data['id']), channel_data['name'], channel_data.get('description'))


code:
# coding: utf-8
from __future__ import unicode_literals

import base64
import binascii
import json
import os
import random

from .common import InfoExtractor
from ..aes import aes_cbc_decrypt
from ..compat import (
    compat_b64decode,
    compat_ord,
)
from ..utils import (
    bytes_to_intlist,
    bytes_to_long,
    ExtractorError,
    float_or_none,
    intlist_to_bytes,
    long_to_bytes,
    pkcs1pad,
    strip_or_none,
    urljoin,
)

class ADNIE(InfoExtractor):
    IE_DESC = 'Anime Digital Network'
    _VALID_URL = r'https?://(?:www\.)?animedigitalnetwork\.fr/video/[^/]+/(?P<id>\d+)'
    _TEST = {
        'url': 'http://animedigitalnetwork.fr/video/blue-exorcist-kyoto-saga/7778-episode-1-debut-des-hostilites',
        'md5': 'e497370d847fd79d9d4c74be55575c7a',
        'info_dict': {
            'id': '7778',
            'ext': 'mp4',
            'title': 'Blue Exorcist - Kyôto Saga - Épisode 1',
            'description': 'md5:2f7b5aa76edbc1a7a92cedcda8a528d5',
        }
    }
    _BASE_URL = 'http://animedigitalnetwork.fr'
    _RSA_KEY = (0xc35ae1e4356b65a73b551493da94b8cb443491c0aa092a357a5aee57ffc14dda85326f42d716e539a34542a0d3f363adf16c5ec222d713d5997194030ee2e4f0d1fb328c01a81cf6868c090d50de8e169c6b13d1675b9eeed1cbc51e1fffca9b38af07f37abd790924cd3bee59d0257cfda4fe5f3f0534877e21ce5821447d1b, 65537)
    _POS_ALIGN_MAP = {
        'start': 1,
        'end': 3,
    }
    _LINE_ALIGN_MAP = {
        'middle': 8,
        'end': 4,
    }

    @staticmethod
    def _ass_subtitles_timecode(seconds):
        return '%01d:%02d:%02d.%02d' % (seconds / 3600, (seconds % 3600) / 60, seconds % 60, (seconds % 1) * 100)

    def _get_subtitles(self, sub_path, video_id):
        if not sub_path:
            return None

        enc_subtitles = self._download_webpage(
            urljoin(self._BASE_URL, sub_path),
            video_id, 'Downloading subtitles location', fatal=False) or '{}'
        subtitle_location = (self._parse_json(enc_subtitles, video_id, fatal=False) or {}).get('location')
        if subtitle_location:
            enc_subtitles = self._download_webpage(
                urljoin(self._BASE_URL, subtitle_location),
                video_id, 'Downloading subtitles data', fatal=False,
                headers={'Origin': 'https://animedigitalnetwork.fr'})
        if not enc_subtitles:
            return None

        # http://animedigitalnetwork.fr/components/com_vodvideo/videojs/adn-vjs.min.js
        dec_subtitles = intlist_to_bytes(aes_cbc_decrypt(
            bytes_to_intlist(compat_b64decode(enc_subtitles[24:])),
            bytes_to_intlist(binascii.unhexlify(self._K + '4b8ef13ec1872730')),
            bytes_to_intlist(compat_b64decode(enc_subtitles[:24]))
        ))
        subtitles_json = self._parse_json(
            dec_subtitles[:-compat_ord(dec_subtitles[-1])].decode(),
            None, fatal=False)
        if not subtitles_json:
            return None

        subtitles = {}
        for sub_lang, sub in subtitles_json.items():
            ssa = '''[Script Info]
ScriptType:V4.00
[V4 Styles]
Format: Name,Fontname,Fontsize,PrimaryColour,SecondaryColour,TertiaryColour,BackColour,Bold,Italic,BorderStyle,Outline,Shadow,Alignment,MarginL,MarginR,MarginV,AlphaLevel,Encoding
Style: Default,Arial,18,16777215,16777215,16777215,0,-1,0,1,1,0,2,20,20,20,0,0
[Events]
Format: Marked,Start,End,Style,Name,MarginL,MarginR,MarginV,Effect,Text'''
            for current in sub:
                start, end, text, line_align, position_align = (
                    float_or_none(current.get('startTime')),
                    float_or_none(current.get('endTime')),
                    current.get('text'), current.get('lineAlign'),
                    current.get('positionAlign'))
                if start is None or end is None or text is None:
                    continue
                alignment = self._POS_ALIGN_MAP.get(position_align, 2) + self._LINE_ALIGN_MAP.get(line_align, 0)
                ssa += os.linesep + 'Dialogue: Marked=0,%s,%s,Default,,0,0,0,,%s%s' % (
                    self._ass_subtitles_timecode(start),
                    self._ass_subtitles_timecode(end),
                    '{\\a%d}' % alignment if alignment != 2 else '',
                    text.replace('\n', '\\N').replace('<i>', '{\\i1}').replace('</i>', '{\\i0}'))

            if sub_lang == 'vostf':
                sub_lang = 'fr'
            subtitles.setdefault(sub_lang, []).extend([{
                'ext': 'json',
                'data': json.dumps(sub),
            }, {
                'ext': 'ssa',
                'data': ssa,
            }])
        return subtitles

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)
        player_config = self._parse_json(self._search_regex(
            r'playerConfig\s*=\s*({.+});', webpage,
            'player config', default='{}'), video_id, fatal=False)
        if not player_config:
            config_url = urljoin(self._BASE_URL, self._search_regex(
                r'(?:id="player"|class="[^"]*adn-player-container[^"]*")[^>]+data-url="([^"]+)"',
                webpage, 'config url'))
            player_config = self._download_json(
                config_url, video_id,
                'Downloading player config JSON metadata')['player']

        video_info = {}
        video_info_str = self._search_regex(
            r'videoInfo\s*=\s*({.+});', webpage,
            'video info', fatal=False)
        if video_info_str:
            video_info = self._parse_json(
                video_info_str, video_id, fatal=False) or {}

        options = player_config.get('options') or {}
        metas = options.get('metas') or {}
        links = player_config.get('links') or {}
        sub_path = player_config.get('subtitles')
        error = None
        if not links:
            links_url = player_config.get('linksurl') or options['videoUrl']
            token = options['token']
            self._K = ''.join([random.choice('0123456789abcdef') for _ in range(16)])
            message = bytes_to_intlist(json.dumps({
                'k': self._K,
                'e': 60,
                't': token,
            }))
            padded_message = intlist_to_bytes(pkcs1pad(message, 128))
            n, e = self._RSA_KEY
            encrypted_message = long_to_bytes(pow(bytes_to_long(padded_message), e, n))
            authorization = base64.b64encode(encrypted_message).decode()
            links_data = self._download_json(
                urljoin(self._BASE_URL, links_url), video_id,
                'Downloading links JSON metadata', headers={
                    'Authorization': 'Bearer ' + authorization,
                })
            links = links_data.get('links') or {}
            metas = metas or links_data.get('meta') or {}
            sub_path = sub_path or links_data.get('subtitles') or \
                'index.php?option=com_vodapi&task=subtitles.getJSON&format=json&id=' + video_id
            sub_path += '&token=' + token
            error = links_data.get('error')
        title = metas.get('title') or video_info['title']

        formats = []
        for format_id, qualities in links.items():
            if not isinstance(qualities, dict):
                continue
            for quality, load_balancer_url in qualities.items():
                load_balancer_data = self._download_json(
                    load_balancer_url, video_id,
                    'Downloading %s %s JSON metadata' % (format_id, quality),
                    fatal=False) or {}
                m3u8_url = load_balancer_data.get('location')
                if not m3u8_url:
                    continue
                m3u8_formats = self._extract_m3u8_formats(
                    m3u8_url, video_id, 'mp4', 'm3u8_native',
                    m3u8_id=format_id, fatal=False)
                if format_id == 'vf':
                    for f in m3u8_formats:
                        f['language'] = 'fr'
                formats.extend(m3u8_formats)
        if not error:
            error = options.get('error')
        if not formats and error:
            raise ExtractorError('%s said: %s' % (self.IE_NAME, error), expected=True)
        self._sort_formats(formats)

        return {
            'id': video_id,
            'title': title,
            'description': strip_or_none(metas.get('summary') or video_info.get('resume')),
            'thumbnail': video_info.get('image'),
            'formats': formats,
            'subtitles': self.extract_subtitles(sub_path, video_id),
            'episode': metas.get('subtitle') or video_info.get('videoTitle'),
            'series': video_info.get('playlistTitle'),
        }


code:
# coding: utf-8
from __future__ import unicode_literals

from .common import InfoExtractor
from ..compat import (
    compat_parse_qs,
    compat_urlparse,
)

class AdobeConnectIE(InfoExtractor):
    _VALID_URL = r'https?://\w+\.adobeconnect\.com/(?P<id>[\w-]+)'

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)
        title = self._html_search_regex(r'<title>(.+?)</title>', webpage, 'title')
        qs = compat_parse_qs(self._search_regex(r"swfUrl\s*=\s*'([^']+)'", webpage, 'swf url').split('?')[1])
        is_live = qs.get('isLive', ['false'])[0] == 'true'
        formats = []
        for con_string in qs['conStrings'][0].split(','):
            formats.append({
                'format_id': con_string.split('://')[0],
                'app': compat_urlparse.quote('?' + con_string.split('?')[1] + 'flvplayerapp/' + qs['appInstance'][0]),
                'ext': 'flv',
                'play_path': 'mp4:' + qs['streamName'][0],
                'rtmp_conn': 'S:' + qs['ticket'][0],
                'rtmp_live': is_live,
                'url': con_string,
            })

        return {
            'id': video_id,
            'title': self._live_title(title) if is_live else title,
            'formats': formats,
            'is_live': is_live,
        }


code:
# coding: utf-8
from __future__ import unicode_literals

import re
import time
import xml.etree.ElementTree as etree

from .common import InfoExtractor
from ..compat import (
    compat_kwargs,
    compat_urlparse,
)
from ..utils import (
    unescapeHTML,
    urlencode_postdata,
    unified_timestamp,
    ExtractorError,
    NO_DEFAULT,
)

MSO_INFO = {
    'DTV': {
        'name': 'DIRECTV',
        'username_field': 'username',
        'password_field': 'password',
    },
    'ATT': {
        'name': 'AT&T U-verse',
        'username_field': 'userid',
        'password_field': 'password',
    },
    'ATTOTT': {
        'name': 'DIRECTV NOW',
        'username_field': 'email',
        'password_field': 'loginpassword',
    },
    'Rogers': {
        'name': 'Rogers',
        'username_field': 'UserName',
        'password_field': 'UserPassword',
    },
    'Comcast_SSO': {
        'name': 'Comcast XFINITY',
        'username_field': 'user',
        'password_field': 'passwd',
    },
    'TWC': {
        'name': 'Time Warner Cable | Spectrum',
        'username_field': 'Ecom_User_ID',
        'password_field': 'Ecom_Password',
    },
    'Brighthouse': {
        'name': 'Bright House Networks | Spectrum',
        'username_field': 'j_username',
        'password_field': 'j_password',
    },
    'Charter_Direct': {
        'name': 'Charter Spectrum',
        'username_field': 'IDToken1',
        'password_field': 'IDToken2',
    },
    'Verizon': {
        'name': 'Verizon FiOS',
        'username_field': 'IDToken1',
        'password_field': 'IDToken2',
    },
    'thr030': {
        'name': '3 Rivers Communications'
    },
    'com140': {
        'name': 'Access Montana'
    },
    'acecommunications': {
        'name': 'AcenTek'
    },
    'acm010': {
        'name': 'Acme Communications'
    },
    'ada020': {
        'name': 'Adams Cable Service'
    },
    'alb020': {
        'name': 'Albany Mutual Telephone'
    },
    'algona': {
        'name': 'Algona Municipal Utilities'
    },
    'allwest': {
        'name': 'All West Communications'
    },
    'all025': {
        'name': 'Allen\'s Communications'
    },
    'spl010': {
        'name': 'Alliance Communications'
    },
    'all070': {
        'name': 'ALLO Communications'
    },
    'alpine': {
        'name': 'Alpine Communications'
    },
    'hun015': {
        'name': 'American Broadband'
    },
    'nwc010': {
        'name': 'American Broadband Missouri'
    },
    'com130-02': {
        'name': 'American Community Networks'
    },
    'com130-01': {
        'name': 'American Warrior Networks'
    },
    'tom020': {
        'name': 'Amherst Telephone/Tomorrow Valley'
    },
    'tvc020': {
        'name': 'Andycable'
    },
    'arkwest': {
        'name': 'Arkwest Communications'
    },
    'art030': {
        'name': 'Arthur Mutual Telephone Company'
    },
    'arvig': {
        'name': 'Arvig'
    },
    'nttcash010': {
        'name': 'Ashland Home Net'
    },
    'astound': {
        'name': 'Astound (now Wave)'
    },
    'dix030': {
        'name': 'ATC Broadband'
    },
    'ara010': {
        'name': 'ATC Communications'
    },
    'she030-02': {
        'name': 'Ayersville Communications'
    },
    'baldwin': {
        'name': 'Baldwin Lightstream'
    },
    'bal040': {
        'name': 'Ballard TV'
    },
    'cit025': {
        'name': 'Bardstown Cable TV'
    },
    'bay030': {
        'name': 'Bay Country Communications'
    },
    'tel095': {
        'name': 'Beaver Creek Cooperative Telephone'
    },
    'bea020': {
        'name': 'Beaver Valley Cable'
    },
    'bee010': {
        'name': 'Bee Line Cable'
    },
    'wir030': {
        'name': 'Beehive Broadband'
    },
    'bra020': {
        'name': 'BELD'
    },
    'bel020': {
        'name': 'Bellevue Municipal Cable'
    },
    'vol040-01': {
        'name': 'Ben Lomand Connect / BLTV'
    },
    'bev010': {
        'name': 'BEVCOMM'
    },
    'big020': {
        'name': 'Big Sandy Broadband'
    },
    'ble020': {
        'name': 'Bledsoe Telephone Cooperative'
    },
    'bvt010': {
        'name': 'Blue Valley Tele-Communications'
    },
    'bra050': {
        'name': 'Brandenburg Telephone Co.'
    },
    'bte010': {
        'name': 'Bristol Tennessee Essential Services'
    },
    'annearundel': {
        'name': 'Broadstripe'
    },
    'btc010': {
        'name': 'BTC Communications'
    },
    'btc040': {
        'name': 'BTC Vision - Nahunta'
    },
    'bul010': {
        'name': 'Bulloch Telephone Cooperative'
    },
    'but010': {
        'name': 'Butler-Bremer Communications'
    },
    'tel160-csp': {
        'name': 'C Spire SNAP'
    },
    'csicable': {
        'name': 'Cable Services Inc.'
    },
    'cableamerica': {
        'name': 'CableAmerica'
    },
    'cab038': {
        'name': 'CableSouth Media 3'
    },
    'weh010-camtel': {
        'name': 'Cam-Tel Company'
    },
    'car030': {
        'name': 'Cameron Communications'
    },
    'canbytel': {
        'name': 'Canby Telcom'
    },
    'crt020': {
        'name': 'CapRock Tv'
    },
    'car050': {
        'name': 'Carnegie Cable'
    },
    'cas': {
        'name': 'CAS Cable'
    },
    'casscomm': {
        'name': 'CASSCOMM'
    },
    'mid180-02': {
        'name': 'Catalina Broadband Solutions'
    },
    'cccomm': {
        'name': 'CC Communications'
    },
    'nttccde010': {
        'name': 'CDE Lightband'
    },
    'cfunet': {
        'name': 'Cedar Falls Utilities'
    },
    'dem010-01': {
        'name': 'Celect-Bloomer Telephone Area'
    },
    'dem010-02': {
        'name': 'Celect-Bruce Telephone Area'
    },
    'dem010-03': {
        'name': 'Celect-Citizens Connected Area'
    },
    'dem010-04': {
        'name': 'Celect-Elmwood/Spring Valley Area'
    },
    'dem010-06': {
        'name': 'Celect-Mosaic Telecom'
    },
    'dem010-05': {
        'name': 'Celect-West WI Telephone Area'
    },
    'net010-02': {
        'name': 'Cellcom/Nsight Telservices'
    },
    'cen100': {
        'name': 'CentraCom'
    },
    'nttccst010': {
        'name': 'Central Scott / CSTV'
    },
    'cha035': {
        'name': 'Chaparral CableVision'
    },
    'cha050': {
        'name': 'Chariton Valley Communication Corporation, Inc.'
    },
    'cha060': {
        'name': 'Chatmoss Cablevision'
    },
    'nttcche010': {
        'name': 'Cherokee Communications'
    },
    'che050': {
        'name': 'Chesapeake Bay Communications'
    },
    'cimtel': {
        'name': 'Cim-Tel Cable, LLC.'
    },
    'cit180': {
        'name': 'Citizens Cablevision - Floyd, VA'
    },
    'cit210': {
        'name': 'Citizens Cablevision, Inc.'
    },
    'cit040': {
        'name': 'Citizens Fiber'
    },
    'cit250': {
        'name': 'Citizens Mutual'
    },
    'war040': {
        'name': 'Citizens Telephone Corporation'
    },
    'wat025': {
        'name': 'City Of Monroe'
    },
    'wadsworth': {
        'name': 'CityLink'
    },
    'nor100': {
        'name': 'CL Tel'
    },
    'cla010': {
        'name': 'Clarence Telephone and Cedar Communications'
    },
    'ser060': {
        'name': 'Clear Choice Communications'
    },
    'tac020': {
        'name': 'Click! Cable TV'
    },
    'war020': {
        'name': 'CLICK1.NET'
    },
    'cml010': {
        'name': 'CML Telephone Cooperative Association'
    },
    'cns': {
        'name': 'CNS'
    },
    'com160': {
        'name': 'Co-Mo Connect'
    },
    'coa020': {
        'name': 'Coast Communications'
    },
    'coa030': {
        'name': 'Coaxial Cable TV'
    },
    'mid055': {
        'name': 'Cobalt TV (Mid-State Community TV)'
    },
    'col070': {
        'name': 'Columbia Power & Water Systems'
    },
    'col080': {
        'name': 'Columbus Telephone'
    },
    'nor105': {
        'name': 'Communications 1 Cablevision, Inc.'
    },
    'com150': {
        'name': 'Community Cable & Broadband'
    },
    'com020': {
        'name': 'Community Communications Company'
    },
    'coy010': {
        'name': 'commZoom'
    },
    'com025': {
        'name': 'Complete Communication Services'
    },
    'cat020': {
        'name': 'Comporium'
    },
    'com071': {
        'name': 'ComSouth Telesys'
    },
    'consolidatedcable': {
        'name': 'Consolidated'
    },
    'conwaycorp': {
        'name': 'Conway Corporation'
    },
    'coo050': {
        'name': 'Coon Valley Telecommunications Inc'
    },
    'coo080': {
        'name': 'Cooperative Telephone Company'
    },
    'cpt010': {
        'name': 'CP-TEL'
    },
    'cra010': {
        'name': 'Craw-Kan Telephone'
    },
    'crestview': {
        'name': 'Crestview Cable Communications'
    },
    'cross': {
        'name': 'Cross TV'
    },
    'cro030': {
        'name': 'Crosslake Communications'
    },
    'ctc040': {
        'name': 'CTC - Brainerd MN'
    },
    'phe030': {
        'name': 'CTV-Beam - East Alabama'
    },
    'cun010': {
        'name': 'Cunningham Telephone & Cable'
    },
    'dpc010': {
        'name': 'D & P Communications'
    },
    'dak030': {
        'name': 'Dakota Central Telecommunications'
    },
    'nttcdel010': {
        'name': 'Delcambre Telephone LLC'
    },
    'tel160-del': {
        'name': 'Delta Telephone Company'
    },
    'sal040': {
        'name': 'DiamondNet'
    },
    'ind060-dc': {
        'name': 'Direct Communications'
    },
    'doy010': {
        'name': 'Doylestown Cable TV'
    },
    'dic010': {
        'name': 'DRN'
    },
    'dtc020': {
        'name': 'DTC'
    },
    'dtc010': {
        'name': 'DTC Cable (Delhi)'
    },
    'dum010': {
        'name': 'Dumont Telephone Company'
    },
    'dun010': {
        'name': 'Dunkerton Telephone Cooperative'
    },
    'cci010': {
        'name': 'Duo County Telecom'
    },
    'eagle': {
        'name': 'Eagle Communications'
    },
    'weh010-east': {
        'name': 'East Arkansas Cable TV'
    },
    'eatel': {
        'name': 'EATEL Video, LLC'
    },
    'ell010': {
        'name': 'ECTA'
    },
    'emerytelcom': {
        'name': 'Emery Telcom Video LLC'
    },
    'nor200': {
        'name': 'Empire Access'
    },
    'endeavor': {
        'name': 'Endeavor Communications'
    },
    'sun045': {
        'name': 'Enhanced Telecommunications Corporation'
    },
    'mid030': {
        'name': 'enTouch'
    },
    'epb020': {
        'name': 'EPB Smartnet'
    },
    'jea010': {
        'name': 'EPlus Broadband'
    },
    'com065': {
        'name': 'ETC'
    },
    'ete010': {
        'name': 'Etex Communications'
    },
    'fbc-tele': {
        'name': 'F&B Communications'
    },
    'fal010': {
        'name': 'Falcon Broadband'
    },
    'fam010': {
        'name': 'FamilyView CableVision'
    },
    'far020': {
        'name': 'Farmers Mutual Telephone Company'
    },
    'fay010': {
        'name': 'Fayetteville Public Utilities'
    },
    'sal060': {
        'name': 'fibrant'
    },
    'fid010': {
        'name': 'Fidelity Communications'
    },
    'for030': {
        'name': 'FJ Communications'
    },
    'fli020': {
        'name': 'Flint River Communications'
    },
    'far030': {
        'name': 'FMT - Jesup'
    },
    'foo010': {
        'name': 'Foothills Communications'
    },
    'for080': {
        'name': 'Forsyth CableNet'
    },
    'fbcomm': {
        'name': 'Frankfort Plant Board'
    },
    'tel160-fra': {
        'name': 'Franklin Telephone Company'
    },
    'nttcftc010': {
        'name': 'FTC'
    },
    'fullchannel': {
        'name': 'Full Channel, Inc.'
    },
    'gar040': {
        'name': 'Gardonville Cooperative Telephone Association'
    },
    'gbt010': {
        'name': 'GBT Communications, Inc.'
    },
    'tec010': {
        'name': 'Genuine Telecom'
    },
    'clr010': {
        'name': 'Giant Communications'
    },
    'gla010': {
        'name': 'Glasgow EPB'
    },
    'gle010': {
        'name': 'Glenwood Telecommunications'
    },
    'gra060': {
        'name': 'GLW Broadband Inc.'
    },
    'goldenwest': {
        'name': 'Golden West Cablevision'
    },
    'vis030': {
        'name': 'Grantsburg Telcom'
    },
    'gpcom': {
        'name': 'Great Plains Communications'
    },
    'gri010': {
        'name': 'Gridley Cable Inc'
    },
    'hbc010': {
        'name': 'H&B Cable Services'
    },
    'hae010': {
        'name': 'Haefele TV Inc.'
    },
    'htc010': {
        'name': 'Halstad Telephone Company'
    },
    'har005': {
        'name': 'Harlan Municipal Utilities'
    },
    'har020': {
        'name': 'Hart Communications'
    },
    'ced010': {
        'name': 'Hartelco TV'
    },
    'hea040': {
        'name': 'Heart of Iowa Communications Cooperative'
    },
    'htc020': {
        'name': 'Hickory Telephone Company'
    },
    'nttchig010': {
        'name': 'Highland Communication Services'
    },
    'hig030': {
        'name': 'Highland Media'
    },
    'spc010': {
        'name': 'Hilliary Communications'
    },
    'hin020': {
        'name': 'Hinton CATV Co.'
    },
    'hometel': {
        'name': 'HomeTel Entertainment, Inc.'
    },
    'hoodcanal': {
        'name': 'Hood Canal Communications'
    },
    'weh010-hope': {
        'name': 'Hope - Prescott Cable TV'
    },
    'horizoncable': {
        'name': 'Horizon Cable TV, Inc.'
    },
    'hor040': {
        'name': 'Horizon Chillicothe Telephone'
    },
    'htc030': {
        'name': 'HTC Communications Co. - IL'
    },
    'htccomm': {
        'name': 'HTC Communications, Inc. - IA'
    },
    'wal005': {
        'name': 'Huxley Communications'
    },
    'imon': {
        'name': 'ImOn Communications'
    },
    'ind040': {
        'name': 'Independence Telecommunications'
    },
    'rrc010': {
        'name': 'Inland Networks'
    },
    'stc020': {
        'name': 'Innovative Cable TV St Croix'
    },
    'car100': {
        'name': 'Innovative Cable TV St Thomas-St John'
    },
    'icc010': {
        'name': 'Inside Connect Cable'
    },
    'int100': {
        'name': 'Integra Telecom'
    },
    'int050': {
        'name': 'Interstate Telecommunications Coop'
    },
    'irv010': {
        'name': 'Irvine Cable'
    },
    'k2c010': {
        'name': 'K2 Communications'
    },
    'kal010': {
        'name': 'Kalida Telephone Company, Inc.'
    },
    'kal030': {
        'name': 'Kalona Cooperative Telephone Company'
    },
    'kmt010': {
        'name': 'KMTelecom'
    },
    'kpu010': {
        'name': 'KPU Telecommunications'
    },
    'kuh010': {
        'name': 'Kuhn Communications, Inc.'
    },
    'lak130': {
        'name': 'Lakeland Communications'
    },
    'lan010': {
        'name': 'Langco'
    },
    'lau020': {
        'name': 'Laurel Highland Total Communications, Inc.'
    },
    'leh010': {
        'name': 'Lehigh Valley Cooperative Telephone'
    },
    'bra010': {
        'name': 'Limestone Cable/Bracken Cable'
    },
    'loc020': {
        'name': 'LISCO'
    },
    'lit020': {
        'name': 'Litestream'
    },
    'tel140': {
        'name': 'LivCom'
    },
    'loc010': {
        'name': 'LocalTel Communications'
    },
    'weh010-longview': {
        'name': 'Longview - Kilgore Cable TV'
    },
    'lon030': {
        'name': 'Lonsdale Video Ventures, LLC'
    },
    'lns010': {
        'name': 'Lost Nation-Elwood Telephone Co.'
    },
    'nttclpc010': {
        'name': 'LPC Connect'
    },
    'lumos': {
        'name': 'Lumos Networks'
    },
    'madison': {
        'name': 'Madison Communications'
    },
    'mad030': {
        'name': 'Madison County Cable Inc.'
    },
    'nttcmah010': {
        'name': 'Mahaska Communication Group'
    },
    'mar010': {
        'name': 'Marne & Elk Horn Telephone Company'
    },
    'mcc040': {
        'name': 'McClure Telephone Co.'
    },
    'mctv': {
        'name': 'MCTV'
    },
    'merrimac': {
        'name': 'Merrimac Communications Ltd.'
    },
    'metronet': {
        'name': 'Metronet'
    },
    'mhtc': {
        'name': 'MHTC'
    },
    'midhudson': {
        'name': 'Mid-Hudson Cable'
    },
    'midrivers': {
        'name': 'Mid-Rivers Communications'
    },
    'mid045': {
        'name': 'Midstate Communications'
    },
    'mil080': {
        'name': 'Milford Communications'
    },
    'min030': {
        'name': 'MINET'
    },
    'nttcmin010': {
        'name': 'Minford TV'
    },
    'san040-02': {
        'name': 'Mitchell Telecom'
    },
    'mlg010': {
        'name': 'MLGC'
    },
    'mon060': {
        'name': 'Mon-Cre TVE'
    },
    'mou110': {
        'name': 'Mountain Telephone'
    },
    'mou050': {
        'name': 'Mountain Village Cable'
    },
    'mtacomm': {
        'name': 'MTA Communications, LLC'
    },
    'mtc010': {
        'name': 'MTC Cable'
    },
    'med040': {
        'name': 'MTC Technologies'
    },
    'man060': {
        'name': 'MTCC'
    },
    'mtc030': {
        'name': 'MTCO Communications'
    },
    'mul050': {
        'name': 'Mulberry Telecommunications'
    },
    'mur010': {
        'name': 'Murray Electric System'
    },
    'musfiber': {
        'name': 'MUS FiberNET'
    },
    'mpw': {
        'name': 'Muscatine Power & Water'
    },
    'nttcsli010': {
        'name': 'myEVTV.com'
    },
    'nor115': {
        'name': 'NCC'
    },
    'nor260': {
        'name': 'NDTC'
    },
    'nctc': {
        'name': 'Nebraska Central Telecom, Inc.'
    },
    'nel020': {
        'name': 'Nelsonville TV Cable'
    },
    'nem010': {
        'name': 'Nemont'
    },
    'new075': {
        'name': 'New Hope Telephone Cooperative'
    },
    'nor240': {
        'name': 'NICP'
    },
    'cic010': {
        'name': 'NineStar Connect'
    },
    'nktelco': {
        'name': 'NKTelco'
    },
    'nortex': {
        'name': 'Nortex Communications'
    },
    'nor140': {
        'name': 'North Central Telephone Cooperative'
    },
    'nor030': {
        'name': 'Northland Communications'
    },
    'nor075': {
        'name': 'Northwest Communications'
    },
    'nor125': {
        'name': 'Norwood Light Broadband'
    },
    'net010': {
        'name': 'Nsight Telservices'
    },
    'dur010': {
        'name': 'Ntec'
    },
    'nts010': {
        'name': 'NTS Communications'
    },
    'new045': {
        'name': 'NU-Telecom'
    },
    'nulink': {
        'name': 'NuLink'
    },
    'jam030': {
        'name': 'NVC'
    },
    'far035': {
        'name': 'OmniTel Communications'
    },
    'onesource': {
        'name': 'OneSource Communications'
    },
    'cit230': {
        'name': 'Opelika Power Services'
    },
    'daltonutilities': {
        'name': 'OptiLink'
    },
    'mid140': {
        'name': 'OPTURA'
    },
    'ote010': {
        'name': 'OTEC Communication Company'
    },
    'cci020': {
        'name': 'Packerland Broadband'
    },
    'pan010': {
        'name': 'Panora Telco/Guthrie Center Communications'
    },
    'otter': {
        'name': 'Park Region Telephone & Otter Tail Telcom'
    },
    'mid050': {
        'name': 'Partner Communications Cooperative'
    },
    'fib010': {
        'name': 'Pathway'
    },
    'paulbunyan': {
        'name': 'Paul Bunyan Communications'
    },
    'pem020': {
        'name': 'Pembroke Telephone Company'
    },
    'mck010': {
        'name': 'Peoples Rural Telephone Cooperative'
    },
    'pul010': {
        'name': 'PES Energize'
    },
    'phi010': {
        'name': 'Philippi Communications System'
    },
    'phonoscope': {
        'name': 'Phonoscope Cable'
    },
    'pin070': {
        'name': 'Pine Belt Communications, Inc.'
    },
    'weh010-pine': {
        'name': 'Pine Bluff Cable TV'
    },
    'pin060': {
        'name': 'Pineland Telephone Cooperative'
    },
    'cam010': {
        'name': 'Pinpoint Communications'
    },
    'pio060': {
        'name': 'Pioneer Broadband'
    },
    'pioncomm': {
        'name': 'Pioneer Communications'
    },
    'pioneer': {
        'name': 'Pioneer DTV'
    },
    'pla020': {
        'name': 'Plant TiftNet, Inc.'
    },
    'par010': {
        'name': 'PLWC'
    },
    'pro035': {
        'name': 'PMT'
    },
    'vik011': {
        'name': 'Polar Cablevision'
    },
    'pottawatomie': {
        'name': 'Pottawatomie Telephone Co.'
    },
    'premiercomm': {
        'name': 'Premier Communications'
    },
    'psc010': {
        'name': 'PSC'
    },
    'pan020': {
        'name': 'PTCI'
    },
    'qco010': {
        'name': 'QCOL'
    },
    'qua010': {
        'name': 'Quality Cablevision'
    },
    'rad010': {
        'name': 'Radcliffe Telephone Company'
    },
    'car040': {
        'name': 'Rainbow Communications'
    },
    'rai030': {
        'name': 'Rainier Connect'
    },
    'ral010': {
        'name': 'Ralls Technologies'
    },
    'rct010': {
        'name': 'RC Technologies'
    },
    'red040': {
        'name': 'Red River Communications'
    },
    'ree010': {
        'name': 'Reedsburg Utility Commission'
    },
    'mol010': {
        'name': 'Reliance Connects- Oregon'
    },
    'res020': {
        'name': 'Reserve Telecommunications'
    },
    'weh010-resort': {
        'name': 'Resort TV Cable'
    },
    'rld010': {
        'name': 'Richland Grant Telephone Cooperative, Inc.'
    },
    'riv030': {
        'name': 'River Valley Telecommunications Coop'
    },
    'rockportcable': {
        'name': 'Rock Port Cablevision'
    },
    'rsf010': {
        'name': 'RS Fiber'
    },
    'rtc': {
        'name': 'RTC Communication Corp'
    },
    'res040': {
        'name': 'RTC-Reservation Telephone Coop.'
    },
    'rte010': {
        'name': 'RTEC Communications'
    },
    'stc010': {
        'name': 'S&T'
    },
    'san020': {
        'name': 'San Bruno Cable TV'
    },
    'san040-01': {
        'name': 'Santel'
    },
    'sav010': {
        'name': 'SCI Broadband-Savage Communications Inc.'
    },
    'sco050': {
        'name': 'Scottsboro Electric Power Board'
    },
    'scr010': {
        'name': 'Scranton Telephone Company'
    },
    'selco': {
        'name': 'SELCO'
    },
    'she010': {
        'name': 'Shentel'
    },
    'she030': {
        'name': 'Sherwood Mutual Telephone Association, Inc.'
    },
    'ind060-ssc': {
        'name': 'Silver Star Communications'
    },
    'sjoberg': {
        'name': 'Sjoberg\'s Inc.'
    },
    'sou025': {
        'name': 'SKT'
    },
    'sky050': {
        'name': 'SkyBest TV'
    },
    'nttcsmi010': {
        'name': 'Smithville Communications'
    },
    'woo010': {
        'name': 'Solarus'
    },
    'sou075': {
        'name': 'South Central Rural Telephone Cooperative'
    },
    'sou065': {
        'name': 'South Holt Cablevision, Inc.'
    },
    'sou035': {
        'name': 'South Slope Cooperative Communications'
    },
    'spa020': {
        'name': 'Spanish Fork Community Network'
    },
    'spe010': {
        'name': 'Spencer Municipal Utilities'
    },
    'spi005': {
        'name': 'Spillway Communications, Inc.'
    },
    'srt010': {
        'name': 'SRT'
    },
    'cccsmc010': {
        'name': 'St. Maarten Cable TV'
    },
    'sta025': {
        'name': 'Star Communications'
    },
    'sco020': {
        'name': 'STE'
    },
    'uin010': {
        'name': 'STRATA Networks'
    },
    'sum010': {
        'name': 'Sumner Cable TV'
    },
    'pie010': {
        'name': 'Surry TV/PCSI TV'
    },
    'swa010': {
        'name': 'Swayzee Communications'
    },
    'sweetwater': {
        'name': 'Sweetwater Cable Television Co'
    },
    'weh010-talequah': {
        'name': 'Tahlequah Cable TV'
    },
    'tct': {
        'name': 'TCT'
    },
    'tel050': {
        'name': 'Tele-Media Company'
    },
    'com050': {
        'name': 'The Community Agency'
    },
    'thr020': {
        'name': 'Three River'
    },
    'cab140': {
        'name': 'Town & Country Technologies'
    },
    'tra010': {
        'name': 'Trans-Video'
    },
    'tre010': {
        'name': 'Trenton TV Cable Company'
    },
    'tcc': {
        'name': 'Tri County Communications Cooperative'
    },
    'tri025': {
        'name': 'TriCounty Telecom'
    },
    'tri110': {
        'name': 'TrioTel Communications, Inc.'
    },
    'tro010': {
        'name': 'Troy Cablevision, Inc.'
    },
    'tsc': {
        'name': 'TSC'
    },
    'cit220': {
        'name': 'Tullahoma Utilities Board'
    },
    'tvc030': {
        'name': 'TV Cable of Rensselaer'
    },
    'tvc015': {
        'name': 'TVC Cable'
    },
    'cab180': {
        'name': 'TVision'
    },
    'twi040': {
        'name': 'Twin Lakes'
    },
    'tvtinc': {
        'name': 'Twin Valley'
    },
    'uis010': {
        'name': 'Union Telephone Company'
    },
    'uni110': {
        'name': 'United Communications - TN'
    },
    'uni120': {
        'name': 'United Services'
    },
    'uss020': {
        'name': 'US Sonet'
    },
    'cab060': {
        'name': 'USA Communications'
    },
    'she005': {
        'name': 'USA Communications/Shellsburg, IA'
    },
    'val040': {
        'name': 'Valley TeleCom Group'
    },
    'val025': {
        'name': 'Valley Telecommunications'
    },
    'val030': {
        'name': 'Valparaiso Broadband'
    },
    'cla050': {
        'name': 'Vast Broadband'
    },
    'sul015': {
        'name': 'Venture Communications Cooperative, Inc.'
    },
    'ver025': {
        'name': 'Vernon Communications Co-op'
    },
    'weh010-vicksburg': {
        'name': 'Vicksburg Video'
    },
    'vis070': {
        'name': 'Vision Communications'
    },
    'volcanotel': {
        'name': 'Volcano Vision, Inc.'
    },
    'vol040-02': {
        'name': 'VolFirst / BLTV'
    },
    'ver070': {
        'name': 'VTel'
    },
    'nttcvtx010': {
        'name': 'VTX1'
    },
    'bci010-02': {
        'name': 'Vyve Broadband'
    },
    'wab020': {
        'name': 'Wabash Mutual Telephone'
    },
    'waitsfield': {
        'name': 'Waitsfield Cable'
    },
    'wal010': {
        'name': 'Walnut Communications'
    },
    'wavebroadband': {
        'name': 'Wave'
    },
    'wav030': {
        'name': 'Waverly Communications Utility'
    },
    'wbi010': {
        'name': 'WBI'
    },
    'web020': {
        'name': 'Webster-Calhoun Cooperative Telephone Association'
    },
    'wes005': {
        'name': 'West Alabama TV Cable'
    },
    'carolinata': {
        'name': 'West Carolina Communications'
    },
    'wct010': {
        'name': 'West Central Telephone Association'
    },
    'wes110': {
        'name': 'West River Cooperative Telephone Company'
    },
    'ani030': {
        'name': 'WesTel Systems'
    },
    'westianet': {
        'name': 'Western Iowa Networks'
    },
    'nttcwhi010': {
        'name': 'Whidbey Telecom'
    },
    'weh010-white': {
        'name': 'White County Cable TV'
    },
    'wes130': {
        'name': 'Wiatel'
    },
    'wik010': {
        'name': 'Wiktel'
    },
    'wil070': {
        'name': 'Wilkes Communications, Inc./RiverStreet Networks'
    },
    'wil015': {
        'name': 'Wilson Communications'
    },
    'win010': {
        'name': 'Windomnet/SMBS'
    },
    'win090': {
        'name': 'Windstream Cable TV'
    },
    'wcta': {
        'name': 'Winnebago Cooperative Telecom Association'
    },
    'wtc010': {
        'name': 'WTC'
    },
    'wil040': {
        'name': 'WTC Communications, Inc.'
    },
    'wya010': {
        'name': 'Wyandotte Cable'
    },
    'hin020-02': {
        'name': 'X-Stream Services'
    },
    'xit010': {
        'name': 'XIT Communications'
    },
    'yel010': {
        'name': 'Yelcot Communications'
    },
    'mid180-01': {
        'name': 'yondoo'
    },
    'cou060': {
        'name': 'Zito Media'
    },
}

class AdobePassIE(InfoExtractor):
    _SERVICE_PROVIDER_TEMPLATE = 'https://sp.auth.adobe.com/adobe-services/%s'
    _USER_AGENT = 'Mozilla/5.0 (X11; Linux i686; rv:47.0) Gecko/20100101 Firefox/47.0'
    _MVPD_CACHE = 'ap-mvpd'

    _DOWNLOADING_LOGIN_PAGE = 'Downloading Provider Login Page'

    def _download_webpage_handle(self, *args, **kwargs):
        headers = self.geo_verification_headers()
        headers.update(kwargs.get('headers', {}))
        kwargs['headers'] = headers
        return super(AdobePassIE, self)._download_webpage_handle(
            *args, **compat_kwargs(kwargs))

    @staticmethod
    def _get_mvpd_resource(provider_id, title, guid, rating):
        channel = etree.Element('channel')
        channel_title = etree.SubElement(channel, 'title')
        channel_title.text = provider_id
        item = etree.SubElement(channel, 'item')
        resource_title = etree.SubElement(item, 'title')
        resource_title.text = title
        resource_guid = etree.SubElement(item, 'guid')
        resource_guid.text = guid
        resource_rating = etree.SubElement(item, 'media:rating')
        resource_rating.attrib = {'scheme': 'urn:v-chip'}
        resource_rating.text = rating
        return '<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/">' + etree.tostring(channel).decode() + '</rss>'

    def _extract_mvpd_auth(self, url, video_id, requestor_id, resource):
        def xml_text(xml_str, tag):
            return self._search_regex(
                '<%s>(.+?)</%s>' % (tag, tag), xml_str, tag)

        def is_expired(token, date_ele):
            token_expires = unified_timestamp(re.sub(r'[_ ]GMT', '', xml_text(token, date_ele)))
            return token_expires and token_expires <= int(time.time())

        def post_form(form_page_res, note, data={}):
            form_page, urlh = form_page_res
            post_url = self._html_search_regex(r'<form[^>]+action=(["\'])(?P<url>.+?)\1', form_page, 'post url', group='url')
            if not re.match(r'https?://', post_url):
                post_url = compat_urlparse.urljoin(urlh.geturl(), post_url)
            form_data = self._hidden_inputs(form_page)
            form_data.update(data)
            return self._download_webpage_handle(
                post_url, video_id, note, data=urlencode_postdata(form_data), headers={
                    'Content-Type': 'application/x-www-form-urlencoded',
                })

        def raise_mvpd_required():
            raise ExtractorError(
                'This video is only available for users of participating TV providers. '
                'Use --ap-mso to specify Adobe Pass Multiple-system operator Identifier '
                'and --ap-username and --ap-password or --netrc to provide account credentials.', expected=True)

        def extract_redirect_url(html, url=None, fatal=False):
            # TODO: eliminate code duplication with generic extractor and move
            # redirection code into _download_webpage_handle
            REDIRECT_REGEX = r'[0-9]{,2};\s*(?:URL|url)=\'?([^\'"]+)'
            redirect_url = self._search_regex(
                r'(?i)<meta\s+(?=(?:[a-z-]+="[^"]+"\s+)*http-equiv="refresh")'
                r'(?:[a-z-]+="[^"]+"\s+)*?content="%s' % REDIRECT_REGEX,
                html, 'meta refresh redirect',
                default=NO_DEFAULT if fatal else None, fatal=fatal)
            if not redirect_url:
                return None
            if url:
                redirect_url = compat_urlparse.urljoin(url, unescapeHTML(redirect_url))
            return redirect_url

        mvpd_headers = {
            'ap_42': 'anonymous',
            'ap_11': 'Linux i686',
            'ap_z': self._USER_AGENT,
            'User-Agent': self._USER_AGENT,
        }

        guid = xml_text(resource, 'guid') if '<' in resource else resource
        count = 0
        while count < 2:
            requestor_info = self._downloader.cache.load(self._MVPD_CACHE, requestor_id) or {}
            authn_token = requestor_info.get('authn_token')
            if authn_token and is_expired(authn_token, 'simpleTokenExpires'):
                authn_token = None
            if not authn_token:
                # TODO add support for other TV Providers
                mso_id = self._downloader.params.get('ap_mso')
                if not mso_id:
                    raise_mvpd_required()
                username, password = self._get_login_info('ap_username', 'ap_password', mso_id)
                if not username or not password:
                    raise_mvpd_required()
                mso_info = MSO_INFO[mso_id]

                provider_redirect_page_res = self._download_webpage_handle(
                    self._SERVICE_PROVIDER_TEMPLATE % 'authenticate/saml', video_id,
                    'Downloading Provider Redirect Page', query={
                        'noflash': 'true',
                        'mso_id': mso_id,
                        'requestor_id': requestor_id,
                        'no_iframe': 'false',
                        'domain_name': 'adobe.com',
                        'redirect_url': url,
                    })

                if mso_id == 'Comcast_SSO':
                    # Comcast page flow varies by video site and whether you
                    # are on Comcast's network.
                    provider_redirect_page, urlh = provider_redirect_page_res
                    if 'automatically signing you in' in provider_redirect_page:
                        oauth_redirect_url = self._html_search_regex(
                            r'window\.location\s*=\s*[\'"]([^\'"]+)',
                            provider_redirect_page, 'oauth redirect')
                        self._download_webpage(
                            oauth_redirect_url, video_id, 'Confirming auto login')
                    else:
                        if '<form name="signin"' in provider_redirect_page:
                            provider_login_page_res = provider_redirect_page_res
                        elif 'http-equiv="refresh"' in provider_redirect_page:
                            oauth_redirect_url = extract_redirect_url(
                                provider_redirect_page, fatal=True)
                            provider_login_page_res = self._download_webpage_handle(
                                oauth_redirect_url, video_id,
                                self._DOWNLOADING_LOGIN_PAGE)
                        else:
                            provider_login_page_res = post_form(
                                provider_redirect_page_res,
                                self._DOWNLOADING_LOGIN_PAGE)

                        mvpd_confirm_page_res = post_form(
                            provider_login_page_res, 'Logging in', {
                                mso_info['username_field']: username,
                                mso_info['password_field']: password,
                            })
                        mvpd_confirm_page, urlh = mvpd_confirm_page_res
                        if '<button class="submit" value="Resume">Resume</button>' in mvpd_confirm_page:
                            post_form(mvpd_confirm_page_res, 'Confirming Login')
                elif mso_id == 'Verizon':
                    # In general, if you're connecting from a Verizon-assigned IP,
                    # you will not actually pass your credentials.
                    provider_redirect_page, urlh = provider_redirect_page_res
                    if 'Please wait ...' in provider_redirect_page:
                        saml_redirect_url = self._html_search_regex(
                            r'self\.parent\.location=(["\'])(?P<url>.+?)\1',
                            provider_redirect_page,
                            'SAML Redirect URL', group='url')
                        saml_login_page = self._download_webpage(
                            saml_redirect_url, video_id,
                            'Downloading SAML Login Page')
                    else:
                        saml_login_page_res = post_form(
                            provider_redirect_page_res, 'Logging in', {
                                mso_info['username_field']: username,
                                mso_info['password_field']: password,
                            })
                        saml_login_page, urlh = saml_login_page_res
                        if 'Please try again.' in saml_login_page:
                            raise ExtractorError(
                                'We\'re sorry, but either the User ID or Password entered is not correct.')
                    saml_login_url = self._search_regex(
                        r'xmlHttp\.open\("POST"\s*,\s*(["\'])(?P<url>.+?)\1',
                        saml_login_page, 'SAML Login URL', group='url')
                    saml_response_json = self._download_json(
                        saml_login_url, video_id, 'Downloading SAML Response',
                        headers={'Content-Type': 'text/xml'})
                    self._download_webpage(
                        saml_response_json['targetValue'], video_id,
                        'Confirming Login', data=urlencode_postdata({
                            'SAMLResponse': saml_response_json['SAMLResponse'],
                            'RelayState': saml_response_json['RelayState']
                        }), headers={
                            'Content-Type': 'application/x-www-form-urlencoded'
                        })
                else:
                    # Some providers (e.g. DIRECTV NOW) have another meta refresh
                    # based redirect that should be followed.
                    provider_redirect_page, urlh = provider_redirect_page_res
                    provider_refresh_redirect_url = extract_redirect_url(
                        provider_redirect_page, url=urlh.geturl())
                    if provider_refresh_redirect_url:
                        provider_redirect_page_res = self._download_webpage_handle(
                            provider_refresh_redirect_url, video_id,
                            'Downloading Provider Redirect Page (meta refresh)')
                    provider_login_page_res = post_form(
                        provider_redirect_page_res, self._DOWNLOADING_LOGIN_PAGE)
                    mvpd_confirm_page_res = post_form(provider_login_page_res, 'Logging in', {
                        mso_info.get('username_field', 'username'): username,
                        mso_info.get('password_field', 'password'): password,
                    })
                    if mso_id != 'Rogers':
                        post_form(mvpd_confirm_page_res, 'Confirming Login')

                session = self._download_webpage(
                    self._SERVICE_PROVIDER_TEMPLATE % 'session', video_id,
                    'Retrieving Session', data=urlencode_postdata({
                        '_method': 'GET',
                        'requestor_id': requestor_id,
                    }), headers=mvpd_headers)
                if '<pendingLogout' in session:
                    self._downloader.cache.store(self._MVPD_CACHE, requestor_id, {})
                    count += 1
                    continue
                authn_token = unescapeHTML(xml_text(session, 'authnToken'))
                requestor_info['authn_token'] = authn_token
                self._downloader.cache.store(self._MVPD_CACHE, requestor_id, requestor_info)

            authz_token = requestor_info.get(guid)
            if authz_token and is_expired(authz_token, 'simpleTokenTTL'):
                authz_token = None
            if not authz_token:
                authorize = self._download_webpage(
                    self._SERVICE_PROVIDER_TEMPLATE % 'authorize', video_id,
                    'Retrieving Authorization Token', data=urlencode_postdata({
                        'resource_id': resource,
                        'requestor_id': requestor_id,
                        'authentication_token': authn_token,
                        'mso_id': xml_text(authn_token, 'simpleTokenMsoID'),
                        'userMeta': '1',
                    }), headers=mvpd_headers)
                if '<pendingLogout' in authorize:
                    self._downloader.cache.store(self._MVPD_CACHE, requestor_id, {})
                    count += 1
                    continue
                if '<error' in authorize:
                    raise ExtractorError(xml_text(authorize, 'details'), expected=True)
                authz_token = unescapeHTML(xml_text(authorize, 'authzToken'))
                requestor_info[guid] = authz_token
                self._downloader.cache.store(self._MVPD_CACHE, requestor_id, requestor_info)

            mvpd_headers.update({
                'ap_19': xml_text(authn_token, 'simpleSamlNameID'),
                'ap_23': xml_text(authn_token, 'simpleSamlSessionIndex'),
            })

            short_authorize = self._download_webpage(
                self._SERVICE_PROVIDER_TEMPLATE % 'shortAuthorize',
                video_id, 'Retrieving Media Token', data=urlencode_postdata({
                    'authz_token': authz_token,
                    'requestor_id': requestor_id,
                    'session_guid': xml_text(authn_token, 'simpleTokenAuthenticationGuid'),
                    'hashed_guid': 'false',
                }), headers=mvpd_headers)
            if '<pendingLogout' in short_authorize:
                self._downloader.cache.store(self._MVPD_CACHE, requestor_id, {})
                count += 1
                continue
            return short_authorize


code:
from __future__ import unicode_literals

import functools
import re

from .common import InfoExtractor
from ..compat import compat_str
from ..utils import (
    float_or_none,
    int_or_none,
    ISO639Utils,
    OnDemandPagedList,
    parse_duration,
    str_or_none,
    str_to_int,
    unified_strdate,
)

class AdobeTVBaseIE(InfoExtractor):
    def _call_api(self, path, video_id, query, note=None):
        return self._download_json(
            'http://tv.adobe.com/api/v4/' + path,
            video_id, note, query=query)['data']

    def _parse_subtitles(self, video_data, url_key):
        subtitles = {}
        for translation in video_data.get('translations', []):
            vtt_path = translation.get(url_key)
            if not vtt_path:
                continue
            lang = translation.get('language_w3c') or ISO639Utils.long2short(translation['language_medium'])
            subtitles.setdefault(lang, []).append({
                'ext': 'vtt',
                'url': vtt_path,
            })
        return subtitles

    def _parse_video_data(self, video_data):
        video_id = compat_str(video_data['id'])
        title = video_data['title']

        s3_extracted = False
        formats = []
        for source in video_data.get('videos', []):
            source_url = source.get('url')
            if not source_url:
                continue
            f = {
                'format_id': source.get('quality_level'),
                'fps': int_or_none(source.get('frame_rate')),
                'height': int_or_none(source.get('height')),
                'tbr': int_or_none(source.get('video_data_rate')),
                'width': int_or_none(source.get('width')),
                'url': source_url,
            }
            original_filename = source.get('original_filename')
            if original_filename:
                if not (f.get('height') and f.get('width')):
                    mobj = re.search(r'_(\d+)x(\d+)', original_filename)
                    if mobj:
                        f.update({
                            'height': int(mobj.group(2)),
                            'width': int(mobj.group(1)),
                        })
                if original_filename.startswith('s3://') and not s3_extracted:
                    formats.append({
                        'format_id': 'original',
                        'preference': 1,
                        'url': original_filename.replace('s3://', 'https://s3.amazonaws.com/'),
                    })
                    s3_extracted = True
            formats.append(f)
        self._sort_formats(formats)

        return {
            'id': video_id,
            'title': title,
            'description': video_data.get('description'),
            'thumbnail': video_data.get('thumbnail'),
            'upload_date': unified_strdate(video_data.get('start_date')),
            'duration': parse_duration(video_data.get('duration')),
            'view_count': str_to_int(video_data.get('playcount')),
            'formats': formats,
            'subtitles': self._parse_subtitles(video_data, 'vtt'),
        }

class AdobeTVEmbedIE(AdobeTVBaseIE):
    IE_NAME = 'adobetv:embed'
    _VALID_URL = r'https?://tv\.adobe\.com/embed/\d+/(?P<id>\d+)'
    _TEST = {
        'url': 'https://tv.adobe.com/embed/22/4153',
        'md5': 'c8c0461bf04d54574fc2b4d07ac6783a',
        'info_dict': {
            'id': '4153',
            'ext': 'flv',
            'title': 'Creating Graphics Optimized for BlackBerry',
            'description': 'md5:eac6e8dced38bdaae51cd94447927459',
            'thumbnail': r're:https?://.*\.jpg$',
            'upload_date': '20091109',
            'duration': 377,
            'view_count': int,
        },
    }

    def _real_extract(self, url):
        video_id = self._match_id(url)

        video_data = self._call_api(
            'episode/' + video_id, video_id, {'disclosure': 'standard'})[0]
        return self._parse_video_data(video_data)

class AdobeTVIE(AdobeTVBaseIE):
    IE_NAME = 'adobetv'
    _VALID_URL = r'https?://tv\.adobe\.com/(?:(?P<language>fr|de|es|jp)/)?watch/(?P<show_urlname>[^/]+)/(?P<id>[^/]+)'

    _TEST = {
        'url': 'http://tv.adobe.com/watch/the-complete-picture-with-julieanne-kost/quick-tip-how-to-draw-a-circle-around-an-object-in-photoshop/',
        'md5': '9bc5727bcdd55251f35ad311ca74fa1e',
        'info_dict': {
            'id': '10981',
            'ext': 'mp4',
            'title': 'Quick Tip - How to Draw a Circle Around an Object in Photoshop',
            'description': 'md5:99ec318dc909d7ba2a1f2b038f7d2311',
            'thumbnail': r're:https?://.*\.jpg$',
            'upload_date': '20110914',
            'duration': 60,
            'view_count': int,
        },
    }

    def _real_extract(self, url):
        language, show_urlname, urlname = re.match(self._VALID_URL, url).groups()
        if not language:
            language = 'en'

        video_data = self._call_api(
            'episode/get', urlname, {
                'disclosure': 'standard',
                'language': language,
                'show_urlname': show_urlname,
                'urlname': urlname,
            })[0]
        return self._parse_video_data(video_data)

class AdobeTVPlaylistBaseIE(AdobeTVBaseIE):
    _PAGE_SIZE = 25

    def _fetch_page(self, display_id, query, page):
        page += 1
        query['page'] = page
        for element_data in self._call_api(
                self._RESOURCE, display_id, query, 'Download Page %d' % page):
            yield self._process_data(element_data)

    def _extract_playlist_entries(self, display_id, query):
        return OnDemandPagedList(functools.partial(
            self._fetch_page, display_id, query), self._PAGE_SIZE)

class AdobeTVShowIE(AdobeTVPlaylistBaseIE):
    IE_NAME = 'adobetv:show'
    _VALID_URL = r'https?://tv\.adobe\.com/(?:(?P<language>fr|de|es|jp)/)?show/(?P<id>[^/]+)'

    _TEST = {
        'url': 'http://tv.adobe.com/show/the-complete-picture-with-julieanne-kost',
        'info_dict': {
            'id': '36',
            'title': 'The Complete Picture with Julieanne Kost',
            'description': 'md5:fa50867102dcd1aa0ddf2ab039311b27',
        },
        'playlist_mincount': 136,
    }
    _RESOURCE = 'episode'
    _process_data = AdobeTVBaseIE._parse_video_data

    def _real_extract(self, url):
        language, show_urlname = re.match(self._VALID_URL, url).groups()
        if not language:
            language = 'en'
        query = {
            'disclosure': 'standard',
            'language': language,
            'show_urlname': show_urlname,
        }

        show_data = self._call_api(
            'show/get', show_urlname, query)[0]

        return self.playlist_result(
            self._extract_playlist_entries(show_urlname, query),
            str_or_none(show_data.get('id')),
            show_data.get('show_name'),
            show_data.get('show_description'))

class AdobeTVChannelIE(AdobeTVPlaylistBaseIE):
    IE_NAME = 'adobetv:channel'
    _VALID_URL = r'https?://tv\.adobe\.com/(?:(?P<language>fr|de|es|jp)/)?channel/(?P<id>[^/]+)(?:/(?P<category_urlname>[^/]+))?'

    _TEST = {
        'url': 'http://tv.adobe.com/channel/development',
        'info_dict': {
            'id': 'development',
        },
        'playlist_mincount': 96,
    }
    _RESOURCE = 'show'

    def _process_data(self, show_data):
        return self.url_result(
            show_data['url'], 'AdobeTVShow', str_or_none(show_data.get('id')))

    def _real_extract(self, url):
        language, channel_urlname, category_urlname = re.match(self._VALID_URL, url).groups()
        if not language:
            language = 'en'
        query = {
            'channel_urlname': channel_urlname,
            'language': language,
        }
        if category_urlname:
            query['category_urlname'] = category_urlname

        return self.playlist_result(
            self._extract_playlist_entries(channel_urlname, query),
            channel_urlname)

class AdobeTVVideoIE(AdobeTVBaseIE):
    IE_NAME = 'adobetv:video'
    _VALID_URL = r'https?://video\.tv\.adobe\.com/v/(?P<id>\d+)'

    _TEST = {
        # From https://helpx.adobe.com/acrobat/how-to/new-experience-acrobat-dc.html?set=acrobat--get-started--essential-beginners
        'url': 'https://video.tv.adobe.com/v/2456/',
        'md5': '43662b577c018ad707a63766462b1e87',
        'info_dict': {
            'id': '2456',
            'ext': 'mp4',
            'title': 'New experience with Acrobat DC',
            'description': 'New experience with Acrobat DC',
            'duration': 248.667,
        },
    }

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)

        video_data = self._parse_json(self._search_regex(
            r'var\s+bridge\s*=\s*([^;]+);', webpage, 'bridged data'), video_id)
        title = video_data['title']

        formats = []
        sources = video_data.get('sources') or []
        for source in sources:
            source_src = source.get('src')
            if not source_src:
                continue
            formats.append({
                'filesize': int_or_none(source.get('kilobytes') or None, invscale=1000),
                'format_id': '-'.join(filter(None, [source.get('format'), source.get('label')])),
                'height': int_or_none(source.get('height') or None),
                'tbr': int_or_none(source.get('bitrate') or None),
                'width': int_or_none(source.get('width') or None),
                'url': source_src,
            })
        self._sort_formats(formats)

        # For both metadata and downloaded files the duration varies among
        # formats. I just pick the max one
        duration = max(filter(None, [
            float_or_none(source.get('duration'), scale=1000)
            for source in sources]))

        return {
            'id': video_id,
            'formats': formats,
            'title': title,
            'description': video_data.get('description'),
            'thumbnail': video_data.get('video', {}).get('poster'),
            'duration': duration,
            'subtitles': self._parse_subtitles(video_data, 'vttPath'),
        }