From 93d23e050ed9c36bfd5f5377e6c56e84e155a327 Mon Sep 17 00:00:00 2001 From: Mort Yao Date: Sun, 2 Sep 2012 03:13:16 +0200 Subject: [PATCH] add support for Vimeo --- you_get/downloader/__init__.py | 1 + you_get/downloader/vimeo.py | 31 +++++++++++++++++++++++++++++++ you_get/main.py | 3 +++ 3 files changed, 35 insertions(+) create mode 100644 you_get/downloader/vimeo.py diff --git a/you_get/downloader/__init__.py b/you_get/downloader/__init__.py index 2cd6305c..2b6b29ea 100644 --- a/you_get/downloader/__init__.py +++ b/you_get/downloader/__init__.py @@ -9,6 +9,7 @@ from .pptv import * from .sina import * from .sohu import * from .tudou import * +from .vimeo import * from .w56 import * from .yinyuetai import * from .youku import * diff --git a/you_get/downloader/vimeo.py b/you_get/downloader/vimeo.py new file mode 100644 index 00000000..d3617ab0 --- /dev/null +++ b/you_get/downloader/vimeo.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python + +__all__ = ['vimeo_download', 'vimeo_download_by_id'] + +from ..common import * + +def vimeo_download_by_id(id, title = None, output_dir = '.', merge = True, info_only = False): + html = get_html('http://vimeo.com/%s' % id, faker = True) + + signature = r1(r'"signature":"([^"]+)"', html) + timestamp = r1(r'"timestamp":([^,]+)', html) + + title = r1(r'"title":"([^"]+)"', html) + title = escape_file_path(title) + + url = 'http://player.vimeo.com/play_redirect?clip_id=%s&sig=%s&time=%s' % (id, signature, timestamp) + type, ext, size = url_info(url, faker = True) + + print_info(site_info, title, type, size) + if not info_only: + download_urls([url], title, ext, size, output_dir, merge = merge, faker = True) + +def vimeo_download(url, output_dir = '.', merge = True, info_only = False): + id = r1(r'http://\w*vimeo.com[/\w]*/(\d+)$', url) + assert id + + vimeo_download_by_id(id, None, output_dir = output_dir, merge = merge, info_only = info_only) + +site_info = "Vimeo.com" +download = vimeo_download +download_playlist = playlist_not_supported('vimeo') diff --git a/you_get/main.py b/you_get/main.py index d491051b..6d5a1766 100644 --- a/you_get/main.py +++ b/you_get/main.py @@ -12,6 +12,8 @@ def url_to_module(url): if site.endswith('.com.cn'): site = site[:-3] domain = r1(r'(\.[^.]+\.[^.]+)$', site) + if not domain: + domain = site assert domain, 'unsupported url: ' + url k = r1(r'([^.]+)', domain) @@ -28,6 +30,7 @@ def url_to_module(url): 'sina': sina, 'sohu': sohu, 'tudou': tudou, + 'vimeo': vimeo, 'yinyuetai': yinyuetai, 'youku': youku, 'youtube': youtube,