Ejemplo n.º 1
0
def YTPlaylist(pl: Playlist):
    color.green('\n' + pl.title)
    color.green(f'{len(pl.video_urls)} videos found.\n')

    # get settings from settings.json
    settings = download_settings()
    settings.download_dir = path.join(settings.download_dir, pl.title)

    try:
        mkdir(settings.download_dir)
    except:
        pass
    video_count = 1
    for video in pl.videos:
        video.video_id
        video_start_time = time.time()
        stream = video.streams.filter(
            progressive=True,
            only_audio=settings.audioOnly).get_by_resolution(settings.res)
        color.yellow(f"\n\n[{video_count} of {len(pl.video_urls)}]")
        video.register_on_progress_callback(on_progress)
        video.register_on_complete_callback(on_complete)
        print("Title 🔥 : " + video.title)
        print("Size  📂 :  " + file_size(stream.filesize) + "\n")

        stream.download(output_path=settings.download_dir)

        print(
            f"\n Got  🕓 {seconds(time.time()-video_start_time)} to download."
        )
        video_count += 1
    if (settings.open_file):
        openFile(settings.download_dir)
Ejemplo n.º 2
0
def index(request):
    result = get_navbar(request)

    unique_files = File.objects.order_by('md5sum', 'sha1sum').distinct('md5sum', 'sha1sum')
    total_sizes = 0
    for unique_file in unique_files:
        total_sizes += unique_file.size

    result.update({
        'file': {
            'total': File.objects.count(),
            'unique': len(unique_files),
            'size': file_size(total_sizes),
        },
        'download': {
            'today': len(Download.objects.filter(time__gte=date.today())),
            'week': len(Download.objects.filter(time__gt=date.today() - timedelta(days=6))),
            'month': len(Download.objects.filter(time__gt=date.today() - timedelta(days=29))),
        },
        'date': {
            'week': date.today() - timedelta(days=6),
            'month': date.today() - timedelta(days=29),
        },
    })

    return render_to_response('file/index.html', result)
Ejemplo n.º 3
0
def index(request):
    result = get_navbar(request)

    unique_files = File.objects.order_by('md5sum', 'sha1sum').distinct(
        'md5sum', 'sha1sum')
    total_sizes = 0
    for unique_file in unique_files:
        total_sizes += unique_file.size

    result.update({
        'file': {
            'total': File.objects.count(),
            'unique': len(unique_files),
            'size': file_size(total_sizes),
        },
        'download': {
            'today':
            len(Download.objects.filter(time__gte=date.today())),
            'week':
            len(
                Download.objects.filter(time__gt=date.today() -
                                        timedelta(days=6))),
            'month':
            len(
                Download.objects.filter(time__gt=date.today() -
                                        timedelta(days=29))),
        },
        'date': {
            'week': date.today() - timedelta(days=6),
            'month': date.today() - timedelta(days=29),
        },
    })

    return render_to_response('file/index.html', result)
Ejemplo n.º 4
0
def YTVideo(video: YouTube):
    settings = download_settings()
    stream = video.streams.filter(
        progressive=True,
        only_audio=settings.audioOnly).get_by_resolution(settings.res)
    print("Title 🔥 : " + video.title)
    print("Size  📂 :  " + file_size(stream.filesize) + "\n")
    video_start_time = time.time()
    video.register_on_progress_callback(on_progress)
    stream.download(output_path=settings.download_dir)

    print(f"\n Got  🕓 {seconds(time.time()-video_start_time)} to download.")
    if (settings.open_file):
        openFile(
            path.normpath(
                path.join(settings.download_dir, stream.default_filename)))
Ejemplo n.º 5
0
def index(request):
    result = get_navbar(request)
    result.update({'more_list': get_more_list(request)})

    results = []
    mirrors = Mirror.objects.filter(active=True).order_by('order')
    for mirror in mirrors:
        item = mirror.status

        try:
            if mirror.name in ['cpan']:
                item.status = '实时同步'
                item.style = 'success'
            elif mirror.name in ['kali', 'kali-security']:
                item.status = '被动同步'
                item.style = 'success'
            else:
                if item.status == -1:
                    item.status = '正在同步'
                    item.style = 'info'
                elif item.status == -2:
                    item.status = '正在统计'
                    item.style = 'info'
                elif item.status == 0:
                    item.status = '同步成功'
                    item.style = 'success'
                elif item.status is None:
                    item.status = '状态未知'
                    item.style = 'default'
                else:
                    item.status = '同步失败'
                    item.style = 'danger'

            results.append({
                'mirror': mirror.name,
                'status': item.status,
                'style': item.style,
                'count': item.count,
                'size': file_size(item.size),
                'timestamp': item.time
            })
        except Status.DoesNotExist:
            pass

    result.update({'results': results})

    return render_to_response('mirror/index.html', result)
Ejemplo n.º 6
0
 def size_unit(self):
     return file_size(self.size)
Ejemplo n.º 7
0
def index(request):
    result = get_navbar(request)
    result.update({'more_list': get_more_list(request)})

    results = []
    mirrors = Mirror.objects.filter(active=True).order_by('order')
    for mirror in mirrors:
        item = mirror.status

        try:
            if mirror.name in ['cpan']:
                item.status = '实时同步'
                item.style = 'success'
            elif mirror.name in ['kali', 'kali-security']:
                item.status = '被动同步'
                item.style = 'success'
            else:
                if item.status == -1:
                    item.status = '正在同步'
                    item.style = 'info'
                elif item.status == -2:
                    item.status = '正在统计'
                    item.style = 'info'
                elif item.status == 0:
                    item.status = '同步成功'
                    item.style = 'success'
                elif item.status is None:
                    item.status = '状态未知'
                    item.style = 'default'
                else:
                    item.status = '同步失败'
                    item.style = 'danger'

            results.append({
                'mirror': mirror.name, 'status': item.status, 'style': item.style, 'count': item.count, 'size': file_size(item.size), 'timestamp': item.time
            })
        except Status.DoesNotExist:
            pass

    result.update({'results': results})

    return render_to_response('mirror/index.html', result)
Ejemplo n.º 8
0
 def size_unit(self):
     return file_size(self.size)
Ejemplo n.º 9
0
def index(request):
    result = get_navbar(request)

    results = []
    mirrors = [
        'centos', 'epel', 'atomic', 'repoforge',
        'kali', 'kali-security', 'kali-images',
        'raspbian', 'rpi-firmware', 'rpi-kernel',
        'ubuntu-releases',
        'archlinux', 'gentoo', 'gentoo-portage',
        'mariadb',
        'cpan', 'pypi', 'rubygems',
        'cygwin', 'eclipse', 'putty',
        'android', 'qt',
        'ldp', 'lfs', 'blfs'
    ]
    for mirror in mirrors:
        if mirror in ['cpan']:
            status = '实时同步'
            style = 'success'
        else:
            status = get_value(mirror, 'status')

            if status == '-1':
                status = '正在同步'
                style = 'info'
            elif status == '-2':
                status = '正在统计'
                style = 'info'
            elif status == '0':
                status = '同步成功'
                style = 'success'
            else:
                status = '同步失败'
                style = 'danger'

        count = get_value(mirror, 'count')
        size = get_value(mirror, 'size')
        timestamp = get_value(mirror, 'timestamp')

        results.append({
            'mirror': mirror, 'status': status, 'style': style, 'count': count, 'size': file_size(int(size)), 'timestamp': timestamp
        })
    result.update({'results': results})

    return render_to_response('mirror/index.html', result)