Social Media Downloader for Python
Project description
btch-downloader
A Python library for downloading content from various social media platforms asynchronously.
Installation
Python Installation
Install the library using pip:
pip install btch-downloader
Prerequisites
- Python 3.8 or higher (for Python usage)
- Required dependencies:
httpx,asyncio(for Python) - Full Documentation Official documentation.
Usage
Python Usage
The library provides asynchronous functions to download content from supported platforms. Below is an example demonstrating how to use each downloader function:
import asyncio
from btch_downloader import ttdl, igdl, twitter, youtube, fbdown, aio, mediafire, capcut, gdrive, pinterest
async def main():
# TikTok Downloader
tiktok_result = await ttdl("https://vt.tiktok.com/ZSBnSFTeK/")
print("TikTok:", tiktok_result)
# Instagram Downloader
instagram_result = await igdl("https://www.instagram.com/p/ByxKbUSnubS/?utm_source=ig_web_copy_link")
print("Instagram:", instagram_result)
# YouTube Downloader
youtube_result = await youtube("https://www.youtube.com/watch?v=Z28dtg_QmFw")
print("YouTube:", youtube_result)
# Facebook Downloader
facebook_result = await fbdown("https://www.facebook.com/watch/?v=1393572814172251")
print("Facebook:", facebook_result)
# AIO (All-in-One) Downloader
aio_result = await aio("https://www.facebook.com/watch/?v=1393572814172251")
print("AIO:", aio_result)
# MediaFire Downloader
mediafire_result = await mediafire("https://www.mediafire.com/file/941xczxhn27qbby/GBWA_V12.25FF-By.SamMods-.apk/file")
print("MediaFire:", mediafire_result)
# Capcut Downloader
capcut_result = await capcut("https://www.capcut.com/template-detail/7299286607478181121?template_id=7299286607478181121&share_token=80302b19-8026-4101-81df-2fd9a9cecb9c&enter_from=template_detail®ion=ID&language=in&platform=copy_link&is_copy_link=1")
print("Capcut:", capcut_result)
# Google Drive Downloader
gdrive_result = await gdrive("https://drive.google.com/file/d/1thDYWcS5p5FFhzTpTev7RUv0VFnNQyZ4/view?usp=drivesdk")
print("Google Drive:", gdrive_result)
# Pinterest Downloader
pinterest_result = await pinterest("https://pin.it/4CVodSq")
print("Pinterest:", pinterest_result)
# Pinterest Search
pinterest_search_result = await pinterest("Zhao Lusi")
print("Pinterest Search:", pinterest_search_result)
# Twitter Downloader
twitter_result = await twitter("https://twitter.com/gofoodindonesia/status/1229369819511709697")
print("Twitter:", twitter_result)
asyncio.run(main())
Error Handling Example
To handle potential errors (e.g., invalid URLs or network issues), save the following code to a file named test.py and run it with a URL or keyword as an argument. Below is an example for all supported functions:
import asyncio
import json
import sys
from btch_downloader import ttdl, igdl, twitter, youtube, fbdown, aio, mediafire, capcut, gdrive, pinterest
async def main(url, function_name):
try:
if function_name == "ttdl":
result = await ttdl(url)
elif function_name == "igdl":
result = await igdl(url)
elif function_name == "twitter":
result = await twitter(url)
elif function_name == "youtube":
result = await youtube(url)
elif function_name == "fbdown":
result = await fbdown(url)
elif function_name == "aio":
result = await aio(url)
elif function_name == "mediafire":
result = await mediafire(url)
elif function_name == "capcut":
result = await capcut(url)
elif function_name == "gdrive":
result = await gdrive(url)
elif function_name == "pinterest":
result = await pinterest(url)
elif function_name == "pinterest_search":
result = await pinterest(url) # For search, URL is a keyword
else:
raise ValueError("Invalid function name")
print(json.dumps(result, indent=2))
except Exception as e:
print(json.dumps({"error": str(e)}), file=sys.stderr)
sys.exit(1)
if __name__ == "__main__":
if len(sys.argv) < 3:
print(json.dumps({"error": "Please provide a function name and URL/keyword"}), file=sys.stderr)
sys.exit(1)
function_name = sys.argv[1]
url = sys.argv[2]
asyncio.run(main(url, function_name))
Run the script with a specific function and URL/keyword, for example:
python3 test.py ttdl "https://vt.tiktok.com/ZSBnSFTeK/"
python3 test.py igdl "https://www.instagram.com/p/ByxKbUSnubS/?utm_source=ig_web_copy_link"
python3 test.py youtube "https://www.youtube.com/watch?v=Z28dtg_QmFw"
python3 test.py fbdown "https://www.facebook.com/watch/?v=1393572814172251"
python3 test.py aio "https://www.facebook.com/watch/?v=1393572814172251"
python3 test.py mediafire "https://www.mediafire.com/file/941xczxhn27qbby/GBWA_V12.25FF-By.SamMods-.apk/file"
python3 test.py capcut "https://www.capcut.com/template-detail/7299286607478181121?template_id=7299286607478181121&share_token=80302b19-8026-4101-81df-2fd9a9cecb9c&enter_from=template_detail®ion=ID&language=in&platform=copy_link&is_copy_link=1"
python3 test.py gdrive "https://drive.google.com/file/d/1thDYWcS5p5FFhzTpTev7RUv0VFnNQyZ4/view?usp=drivesdk"
python3 test.py pinterest "https://pin.it/4CVodSq"
python3 test.py pinterest_search "Zhao Lusi"
python3 test.py twitter "https://twitter.com/gofoodindonesia/status/1229369819511709697"
Features
- Download content from TikTok, Instagram, Twitter, YouTube, Facebook, MediaFire, Capcut, Google Drive, and Pinterest.
- Asynchronous API calls using
httpxfor efficient performance (Python). - Simple and consistent interface across all platforms.
- Support for Pinterest search by keyword.
API Reference
Each downloader function accepts a URL (or keyword for Pinterest search) and returns a dictionary containing the downloaded content details.
Common Parameters
url(str): The URL of the content to download (e.g., video, image, or file link). For Pinterest search, provide a keyword instead.- Optional: Some functions may accept additional parameters (e.g., authentication tokens). Check the official Python documentation or Node.js documentation for details.
Return Value
Each function returns a dictionary with the following possible keys:
url(str): Direct URL to the downloaded content (e.g., video or image file).metadata(dict): Additional information about the content (e.g., title, author, or resolution).error(str): Error message if the download fails (only in case of failure).
Supported Platforms and Functions
| Function | Platform | Description |
|---|---|---|
ttdl |
TikTok | Downloads videos or images from TikTok. |
igdl |
Downloads posts, reels, or stories from Instagram. | |
twitter |
Downloads media from Twitter posts. | |
youtube |
YouTube | Downloads videos or audio from YouTube. |
fbdown |
Downloads videos from Facebook. | |
aio |
All-in-One | Attempts to download from any supported platform. |
mediafire |
MediaFire | Downloads files from MediaFire links. |
capcut |
Capcut | Downloads templates or videos from Capcut. |
gdrive |
Google Drive | Downloads files from Google Drive. |
pinterest |
Downloads pins or searches for content by keyword. |
Notes
- Some platforms may require authentication or have rate limits. Ensure you comply with each platform's terms of service.
- The
aiofunction automatically detects the platform from the URL but may be slower than platform-specific functions. - For large files or slow networks, ensure proper error handling and timeouts.
Documentation
- For detailed Python usage, including advanced configuration and authentication setup, visit https://github.com/hostinger-bot/btch-downloader-py.
License
MIT License
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 btch_downloader-4.0.18.tar.gz.
File metadata
- Download URL: btch_downloader-4.0.18.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50302d63125f0262b021623cc7ab0ab56174d93e8cf34ceeb5b0e6e87de97403
|
|
| MD5 |
f441c30063ea54a72e0ce12931663796
|
|
| BLAKE2b-256 |
88ed28c072489ad4a8788bc6b0b8fb94dbd9855ace0ef139e8455330e339bb50
|
File details
Details for the file btch_downloader-4.0.18-py3-none-any.whl.
File metadata
- Download URL: btch_downloader-4.0.18-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7d972be4a5a754b53c7270a535c142da1f36fb2dfa44b14619e88aefcd59204
|
|
| MD5 |
14ccd813aa3cae23f85a9270499649c2
|
|
| BLAKE2b-256 |
b522c54bdd648dcd3f6dfaafced6398ca83c796f681516a934c665c04c7ad7f0
|