def play_video(source, url):
    if source == 'apple.com':
        url = '%s|User-Agent=QuickTime' % url
    elif source == 'youtube.com':
        import re
        video_id = re.search(r'v=(.+)&?', url).groups(1)
        url = (
            'plugin://plugin.video.youtube/'
            '?action=play_video&videoid=%s' % video_id
        )
    elif source == 'yahoo-redir':
        import re
        vid, res = re.search('id=(.+)&resolution=(.+)', url).groups()
        url = scraper.get_yahoo_url(vid, res)
    log('Using URL: %s' % url)
    return plugin.set_resolved_url(url)
def _get_playable_url(source, raw_url, download_mode=False):
    if source == 'apple.com':
        raw_url = '%s|User-Agent=QuickTime' % raw_url
    elif source == 'youtube.com':
        import re
        video_id = re.search(r'v=(.+)&?', raw_url).groups(1)
        if download_mode:
            raw_url = ('plugin://plugin.video.youtube/'
                       '?action=download&videoid=%s' % video_id)
        else:
            raw_url = ('plugin://plugin.video.youtube/'
                       '?action=play_video&videoid=%s' % video_id)
    elif source == 'yahoo-redir':
        import re
        vid, res = re.search('id=(.+)&resolution=(.+)', raw_url).groups()
        raw_url = scraper.get_yahoo_url(vid, res)
    return raw_url
def _get_playable_url(source, raw_url, download_mode=False):
    if source == 'apple.com':
        raw_url = '%s|User-Agent=QuickTime' % raw_url
    elif source == 'youtube.com':
        import re
        video_id = re.search(r'v=(.+)&?', raw_url).groups(1)
        if download_mode:
            raw_url = (
                'plugin://plugin.video.youtube/'
                '?action=download&videoid=%s' % video_id
            )
        else:
            raw_url = (
                'plugin://plugin.video.youtube/'
                '?action=play_video&videoid=%s' % video_id
            )
    elif source == 'yahoo-redir':
        import re
        vid, res = re.search('id=(.+)&resolution=(.+)', raw_url).groups()
        raw_url = scraper.get_yahoo_url(vid, res)
    return raw_url