move parse_size to dongting.py

This commit is contained in:
lilydjwg 2014-09-23 21:32:49 +08:00
parent d152c3e78d
commit 388e5f0b1c
2 changed files with 10 additions and 9 deletions

View File

@ -1023,12 +1023,3 @@ def any_download_playlist(url, **kwargs):
def main(): def main():
script_main('you-get', any_download, any_download_playlist) script_main('you-get', any_download, any_download_playlist)
_unit_prefixes = 'bkmg'
def parse_size(size):
m = re.match(r'([\d.]+)(.(?:i?B)?)', size, re.I)
if m:
return int(float(m.group(1)) * 1024 **
_unit_prefixes.index(m.group(2).lower()))
else:
return 0

View File

@ -4,6 +4,16 @@ __all__ = ['dongting_download']
from ..common import * from ..common import *
_unit_prefixes = 'bkmg'
def parse_size(size):
m = re.match(r'([\d.]+)(.(?:i?B)?)', size, re.I)
if m:
return int(float(m.group(1)) * 1024 **
_unit_prefixes.index(m.group(2).lower()))
else:
return 0
def dongting_download_lyric(lrc_url, file_name, output_dir): def dongting_download_lyric(lrc_url, file_name, output_dir):
j = get_html(lrc_url) j = get_html(lrc_url)
info = json.loads(j) info = json.loads(j)