예제 #1
0
파일: singleclick.py 프로젝트: cool-RR/Miro
    def callback(headers):
        """We need to figure out if the URL is a external video link,
        or a link to a feed.
        """
        if check_url_exists(url):
            return

        content_type = headers.get("content-type")
        if content_type:
            if filetypes.is_feed_content_type(content_type):
                add_feeds([url])
                return

            if flashscraper.is_maybe_flashscrapable(url):
                entry = _build_entry(url, "video/x-flv", additional=metadata)
                download_video(entry)
                return

            if filetypes.is_maybe_feed_content_type(content_type):
                logging.info("%s content type is %s.  " "going to peek to see if it's a feed....", url, content_type)
                httpclient.grab_url(url, callback_peek, errback)
                return

        entry = _build_entry(url, content_type)

        if filetypes.is_video_enclosure(entry["enclosures"][0]):
            download_video(entry)
        else:
            handle_unknown_callback(url)
예제 #2
0
파일: util.py 프로젝트: foxi/miro
def get_first_video_enclosure(entry):
    """
    Find the first *best* video enclosure in a feedparser entry.

    Returns the enclosure, or None if no video enclosure is found.
    """
    try:
        enclosures = entry.enclosures
    except (KeyError, AttributeError):
        return None

    enclosures = [e for e in enclosures if filetypes.is_video_enclosure(e)]
    if len(enclosures) == 0:
        return None

    enclosures.sort(cmp_enclosures)
    return enclosures[0]
예제 #3
0
def get_first_video_enclosure(entry):
    """
    Find the first *best* video enclosure in a feedparser entry.

    Returns the enclosure, or None if no video enclosure is found.
    """
    try:
        enclosures = entry.enclosures
    except (KeyError, AttributeError):
        return None

    enclosures = [e for e in enclosures if filetypes.is_video_enclosure(e)]
    if len(enclosures) == 0:
        return None

    enclosures.sort(cmp_enclosures)
    return enclosures[0]
예제 #4
0
파일: singleclick.py 프로젝트: kfatehi/miro
    def callback(headers, content_type=None):
        """We need to figure out if the URL is a external video link,
        or a link to a feed.
        """
        print 'callback for', url, headers, content_type
        if check_url_exists(url):
            return

        if content_type is None:
            content_type = headers.get("content-type")

        if content_type:
            if filetypes.is_feed_content_type(content_type):
                add_feeds([url])
                return

            if flashscraper.is_maybe_flashscrapable(url):
                entry = _build_entry(url, 'video/x-flv', additional=metadata)
                download_video(entry)
                return

            if amazon.is_amazon_content_type(content_type):
                amazon.download_file(url, handle_unknown_callback)
                return

            if filetypes.is_maybe_feed_content_type(content_type):
                logging.info(
                    "%s content type is %s.  "
                    "going to peek to see if it's a feed....", url,
                    content_type)
                httpclient.grab_url(url, callback_peek, errback)
                return

        entry = _build_entry(url, content_type)

        if filetypes.is_video_enclosure(entry['enclosures'][0]):
            download_video(entry)
        else:
            handle_unknown_callback(url)