A library that helps downloading videos from cda.pl
Project description
CDA_download
A library that helps download videos from CDA website
Installation:
pip install cda_download
How to use:
from cda_download import CdaDownload
url = "CDA url"
cda = CdaDownload(url=url)
cda.download()
Additional features:
Progress callback
If you need to get progress like percentage or download speed, you can create a function and pass as a parameter in the download method.
from datetime import datetime, timedelta
from cda_download import CdaDownload
download_start_time = datetime.now()
last_update_time = datetime.now()
def show_progress(count, block_size, total_size):
global last_update_time
# download speed
elapsed_time = (datetime.now() - download_start_time).total_seconds()
download_speed = (count * block_size) / (1024 * elapsed_time)
# progress
progress = min(1.0, count * block_size / total_size)
current_time = datetime.now()
if (current_time - last_update_time) >= timedelta(seconds=1):
print(f'\rDownloading: {progress:.2f} complete', end='')
print(f' | Speed: {download_speed:.2f} KB/s', end='')
last_update_time = current_time
url = "CDA url"
cda = CdaDownload(url=url)
cda.download(on_progress_callback=show_progress)
Filename
You can pass filename as a parameter in the form of a string to specify download location.
Using download method without the filename parameter will save the file to where your script is located.
from cda_download import CdaDownload
url = "cda url"
cda = CdaDownload(url=url)
output_path = "D:/Downloads/title.mp4"
cda.download(filename=output_path)
Other data
Apart from downloading, you can access other data about CDA video:
from cda_download import CdaDownload
url = "CDA url"
cda = CdaDownload(url=url)
# video title
print(cda.title())
# channel name
print(cda.channel())
# video description
print(cda.description())
# video publish date
print(cda.publish_date())
# video duration
print(cda.duration())
# file size in bytes
print(cda.filesize())
# thumbnail image
print(cda.thumbnail())
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cda_download-0.0.7.tar.gz.
File metadata
- Download URL: cda_download-0.0.7.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f08f51519af54d28016f03d1d8951c9d53beb80f4c9d2322226f9c226ac85bc
|
|
| MD5 |
bb6f920164b4ca223f77fc32ecf4951d
|
|
| BLAKE2b-256 |
0f0e93eccb643b5e12ee4b80709e786d47d775fd33c22307d54c6ecc619b1247
|
File details
Details for the file cda_download-0.0.7-py3-none-any.whl.
File metadata
- Download URL: cda_download-0.0.7-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
418efb496a244dd3282ab4dc0bf7b31a23a1f5df7153a3159eb9487ae9ad4e58
|
|
| MD5 |
c48ef9996556eb8e39bacdc2f7dbd463
|
|
| BLAKE2b-256 |
f8ea4aff1312b89195bdcdf35992c21576950ecaf4b80cc9bc5dbef51681efc2
|