Example #1
0
def get_hot_links(url):
    normal_url = _norm_url(url)
    url_match = Match(normal_url)

    try:
        if url_match(r'^(http://i\.imgur\.com/[.\w]+)$'):
            urls = [url_match.group(1)]

        elif (url_match(r'^http://imgur\.com/a/(\w+)$') or
              url_match(r'^http://imgur\.com/a/(\w+)/.+$')):
            urls = _imgur.album_images(url_match.group(1))

        elif url_match(r'^http://imgur\.com/gallery/(\w+)$'):
            id = url_match.group(1)
            try:
                urls = _imgur.gallery_album(id)
            except _imgur.DoesNotFindAlbum:
                urls = [_imgur.gallery_image(id)]

        elif _image_link.match(normal_url):
            urls = map(_imgur.image, _image_link.id_list)

        else:
            raise DoesNotKnowHowToGetUrl
    except (_imgur.GetsUnexpectedResponse, _imgur.IsUnreachable, 
            _imgur.DoesNotUnderstandRequest, _imgur.RequiresAuthentication, 
            _imgur.ForbidsAccess, _imgur.DoesNotFindResource, 
            _imgur.LimitsRate, _imgur.HaveGotInternalError):
        urls = []
    return urls
Example #2
0
def get_thumbnails(url):
    url_match = Match(url)
    if url_match(r'^http://i\.imgur\.com/(?P<id>\w+)\.(?P<ext>\w+)$'):
        thumbnail = 'http://i.imgur.com/%(id)st.%(ext)s' % {
            'id': url_match.group('id'), 'ext': url_match.group('ext')}
    else:
        raise DoesNotKnowHowToGetUrl
    return [thumbnail]
def get_hot_links(url):
    url_match = Match(url)

    if (url_match(r'^http(?:s)?://www\.youtube\.com/watch\?.*v=([-_\w]+).*$') or 
        url_match(r'^http(?:s)?://youtu\.be/([-_\w]+)$')):
        id = url_match.group(1)
        urls = ['%smedia/youtube/%s/' % (addon.base_url, id)]
    else:
        raise DoesNotKnowHowToGetUrl
    return urls
def get_thumbnails(url):
    url_match = Match(url)
    if url_match(r'^%smedia/youtube/([-_\w]+)/$' % addon.base_url):
        try:
            video = _youtube.GetYouTubeVideoEntry(video_id=url_match.group(1))
            thumbnail = [tn.url for tn in video.media.thumbnail]
        except gdata.service.RequestError as e:
            raise DoesNotKnowHowToGetUrl
    else:
        raise DoesNotKnowHowToGetUrl
    return thumbnail