Beispiel #1
0
def DownloadsIndex(refresh = 0):
    container = ObjectContainer(title1 = L('heading.download'))

    if bridge.download.assumed_running():
        current       = bridge.download.current()
        endpoint      = current['endpoint']
        status        = DownloadStatus(Downloader.status_file_for(endpoint))

        container.add(popup_button(current['title'], DownloadsOptions, endpoint = endpoint, icon = 'icon-downloads.png'))

        for ln in status.report():
            container.add(popup_button(ln, DownloadsOptions, endpoint = endpoint, icon = 'icon-downloads.png'))

    for download in bridge.download.queue():
        container.add(popup_button(download['title'], DownloadsOptions, endpoint = download['endpoint'], icon = 'icon-downloads-queue.png'))

    add_refresh_to(container, refresh, DownloadsIndex)
    return container
Beispiel #2
0
        def perform_download():
            downloader = Downloader(download['endpoint'],
                environment = environment.plex,
                destination = plex.section_destination(download['media_hint']),
                limit       = speed_limit()
            )
            downloader.wizard.avoid_flv = avoid_flv()

            def store_curl_pid(dl):
                current()['title'] = dl.file_name()
                current()['pid']   = dl.pid
                plex.user_dict().Save()

            def update_library(dl):
                plex.refresh_section(download['media_hint'])

            def clear_download_and_dispatch(dl):
                clear_current()
                dispatch(False)

            def store_download_endpoint(dl):
                history().append(dl.endpoint)

            downloader.on_start(store_curl_pid)

            downloader.on_success(update_library)
            downloader.on_success(store_download_endpoint)
            downloader.on_success(clear_download_and_dispatch)

            downloader.on_error(clear_download_and_dispatch)
            downloader.download()