Esempio n. 1
0
def shall_I_begin(in_str, is_file=False, is_hq=False):
    #start terminate_watcher
    Terminate_Watcher()

    #xiami obj
    xiami_obj = xm.Xiami(config.XIAMI_LOGIN_EMAIL,\
            config.XIAMI_LOGIN_PASSWORD, \
            is_hq)
    #netease obj
    m163 = netease.Netease(is_hq)

    if is_file:
        from_file(xiami_obj, m163,in_str)
    elif re.match(pat_xm, in_str):
        from_url_xm(xiami_obj, in_str)
    elif re.match(pat_163, in_str):
        from_url_163(m163, in_str)

    print border
    if len(dl_songs):
        LOG.info(u' 下载任务总数: %d \n 3秒后开始下载' % len(dl_songs))
        sleep(3)
        downloader.start_download(dl_songs)
    else:
        LOG.warning(u' 没有可下载任务,自动退出.')
Esempio n. 2
0
def shall_I_begin(in_str, is_file=False, is_hq=False, dl_lyric=False, need_proxy_pool = False):
    #start terminate_watcher
    Terminate_Watcher()
    global ppool, xiami_obj
    if need_proxy_pool:
        LOG.info(msgTxt.init_proxypool)
        ppool = ProxyPool()
        LOG.info(msgTxt.fmt_init_proxypool_done %len(ppool.proxies))

    #netease obj
    m163 = netease.Netease(is_hq, dl_lyric, proxies=ppool)

    if is_file:
        from_file(is_hq, m163, dl_lyric,in_str)
    elif re.match(pat_xm, in_str):
        __init_xiami_obj(is_hq, dl_lyric)
        from_url_xm(xiami_obj, in_str)
    elif re.match(pat_163, in_str):
        from_url_163(m163, in_str)

    print border
    if len(dl_songs):
        LOG.info(msgTxt.fmt_total_dl_nm % len(dl_songs))
        sleep(3)
        downloader.start_download(dl_songs)
    else:
        LOG.warning(msgTxt.no_dl_task)
Esempio n. 3
0
def shall_I_begin(in_str, is_file=False, is_hq=False, need_proxy_pool=False):
    #start terminate_watcher
    Terminate_Watcher()
    global ppool
    if need_proxy_pool:
        LOG.info(u'初始化proxy pool')
        ppool = ProxyPool()
        LOG.info(u'proxy pool:[%d] 初始完毕' % len(ppool.proxies))

    #xiami obj
    xiami_obj = xm.Xiami(config.XIAMI_LOGIN_EMAIL,\
            config.XIAMI_LOGIN_PASSWORD, \
            is_hq,proxies=ppool)
    #netease obj
    m163 = netease.Netease(is_hq, proxies=ppool)

    if is_file:
        from_file(xiami_obj, m163, in_str)
    elif re.match(pat_xm, in_str):
        from_url_xm(xiami_obj, in_str)
    elif re.match(pat_163, in_str):
        from_url_163(m163, in_str)

    print border
    if len(dl_songs):
        LOG.info(u' 下载任务总数: %d \n 3秒后开始下载' % len(dl_songs))
        sleep(3)
        downloader.start_download(dl_songs)
    else:
        LOG.warning(u' 没有可下载任务,自动退出.')
Esempio n. 4
0
def shall_I_begin(in_str, is_file=False, is_hq=False, need_proxy_pool = False):
    #start terminate_watcher
    Terminate_Watcher()
    global ppool
    if need_proxy_pool:
        LOG.info(u'初始化proxy pool')
        ppool = ProxyPool()
        LOG.info(u'proxy pool:[%d] 初始完毕'%len(ppool.proxies))

    #xiami obj
    xiami_obj = xm.Xiami(config.XIAMI_LOGIN_EMAIL,\
            config.XIAMI_LOGIN_PASSWORD, \
            is_hq,proxies=ppool)
    #netease obj
    m163 = netease.Netease(is_hq, proxies=ppool)

    if is_file:
        from_file(xiami_obj, m163,in_str)
    elif re.match(pat_xm, in_str):
        from_url_xm(xiami_obj, in_str)
    elif re.match(pat_163, in_str):
        from_url_163(m163, in_str)

    print border
    if len(dl_songs):
        LOG.info(u' 下载任务总数: %d \n 3秒后开始下载' % len(dl_songs))
        sleep(3)
        downloader.start_download(dl_songs)
    else:
        LOG.warning(u' 没有可下载任务,自动退出.')
Esempio n. 5
0
def shall_I_begin(in_str, is_file=False, is_hq=False):
    xiami_obj = xm.Xiami(config.XIAMI_LOGIN_EMAIL,\
            config.XIAMI_LOGIN_PASSWORD, \
            is_hq)
    if is_file:
        from_file(xiami_obj, in_str)
    else:
        from_url(xiami_obj, in_str)

    print border
    LOG.info(u' 下载任务总数: %d' % len(dl_songs))
    sleep(3)
    downloader.start_download(dl_songs)
Esempio n. 6
0
def shall_I_begin(in_str, is_file=False, is_hq=False):
    xiami_obj = xm.Xiami(config.XIAMI_LOGIN_EMAIL,\
            config.XIAMI_LOGIN_PASSWORD, \
            is_hq)
    if is_file:
        from_file(xiami_obj, in_str)
    else:
        from_url(xiami_obj, in_str)

    print border
    LOG.info(u' 下载任务总数: %d' % len(dl_songs))
    sleep(3)
    downloader.start_download(dl_songs)
Esempio n. 7
0
def shall_I_begin(option):
    #start terminate_watcher
    Terminate_Watcher()
    global ppool, xiami_obj
    if option.need_proxy_pool:
        LOG.info(msgTxt.init_proxypool)
        ppool = ProxyPool()
        option.proxies = ppool
        LOG.info(msgTxt.fmt_init_proxypool_done %len(ppool.proxies))

    #netease obj
    m163 = netease.Netease(option)

    if option.inFile:
        from_file(m163,option)
    elif re.match(pat_xm, option.inUrl):
        __init_xiami_obj(option)
        from_url_xm(xiami_obj, option.inUrl)
    elif re.match(pat_163, option.inUrl):
        from_url_163(m163, option.inUrl)

    print border
    #here do filtering for incremental download
    skipped_songs = [] #used by incremental_dl
    skipped_hists = [] #used by incremental_dl

    dl_songs = []
    if option.incremental_dl:
        skipped_songs, skipped_hists = hist_handler.filter_songs(total_songs)
        LOG.warning(msgTxt.fmt_skip_dl_nm % len(skipped_songs))

    dl_songs = [song for song in total_songs if song not in skipped_songs]
    dl_num = len(dl_songs)
    skip_num = len(skipped_songs)
    output_num = '%d' % dl_num if not skip_num else \
                 "%d-%d=%d" %(dl_num + skip_num, skip_num, dl_num)
    if len(dl_songs):
        LOG.info(msgTxt.fmt_total_dl_nm % output_num)
        sleep(3)
        downloader.start_download(dl_songs, skipped_hists)
        # test
        # downloader.success_list.extend(dl_songs)
        # downloader.failed_list.extend(dl_songs)
        # downloader.finish_summary(skipped_hists)
        # test
    else:
        LOG.warning(msgTxt.no_dl_task)
Esempio n. 8
0
from directory import check_output_directories
from downloader import start_download

# Add source code to content.txt along with cards.json to the desktop
content_path = "C:\\Users\\Gerry\\Desktop\\content.txt"

with open(content_path, 'r') as file:
    content = file.read().replace('\n', '')
    check_output_directories()
    start_download(content)
Esempio n. 9
0
Working:
    Call commander's get_command and wait to command
    forward the command to content_retriever and get content name (E.g.: movie name)
    forward content name to content_provider to get media link
    forward media link to downloader
    repeat
"""
if __name__ == '__main__':
    from logger import *
    from commander import get_command
    from content_retriever import get_content
    from content_provider import get_download_url
    from downloader import start_download

    while True:
        try:
            cmd = get_command()
            logging.info(f'Got command {repr(cmd)}')

            content = get_content(cmd)
            logging.info(f'Got content {repr(content)}')

            magnet = get_download_url(content)
            logging.info(f'Got download url {magnet}')

            start_download(magnet)
            logging.info('Started download')
        except KeyboardInterrupt:
            logging.info('exiting!')
            break