├── cookie.json ├── README.md └── scribd.py /cookie.json: -------------------------------------------------------------------------------- 1 | #Example JSON Replace with actual premium Scribd Account JSON 2 | 3 | [ 4 | { 5 | "domain": ".scribd.com", 6 | "expirationDate": 1743673276.655682, 7 | "hostOnly": false, 8 | "httpOnly": false, 9 | "name": "__CJ_nwt", 10 | "path": "/", 11 | "sameSite": "lax", 12 | "secure": true, 13 | "session": false, 14 | "storeId": "0", 15 | "value": "%3A6980%2C%22nw2742%22%3A6970%7D", 16 | "id": 1 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

Scribd Downloader

2 | 3 |

4 | GitHub Repo stars 5 | GitHub issues 6 | GitHub pull requests 7 | GitHub contributors 8 | GitHub forks 9 |

10 | 11 |

12 | Scribd Downloader is Python Script capable of downloading Scribd documents as PDF files using cookies from a premium account. It's designed to help users access Scribd documents directly through Telegram 13 |

14 | 15 | ## Features 16 | 17 | - Download Scribd documents as PDFs. 18 | - Support for various Scribd URL formats. 19 | - Utilizes premium account cookies for access. 20 | - Inline download link and information about the document. 21 | 22 | ## Requirements 23 | 24 | - `aiogram=2.6` 25 | - A Telegram bot token. 26 | - Access to a Scribd premium account (for cookies). 27 | - Must be use Premium Account Cookies [ Update cookie file with you actual premium account cookies ] 28 | 29 | 1. Install the required dependencies, ensuring Python 3.8 or higher: 30 | 31 | ```bash 32 | pip install aiogram==2.6 33 | ``` 34 | 35 | ## Deploy the Bot 36 | 37 | ```sh 38 | git clone https://github.com/bisnuray/ScribdDownloader 39 | cd ScribdDownloader 40 | python3 scribd.py 41 | ``` 42 | ### Setting Up the Bot 43 | 44 | 1. Create a new bot with [@BotFather](https://t.me/botfather) on Telegram and get the bot token. 45 | 2. Replace the placeholder token in the script with your actual bot token. 46 | 47 | ### Running the Bot 48 | 49 | Execute the script to start the bot: 50 | 51 | ```bash 52 | python3 scribd.py 53 | ``` 54 | ## Usage 🛠️ 55 | The bot supports the following commands: 56 | 57 | - /scribd with scribd file url 58 | 59 | ## Author 📝 60 | 61 | - Name: Bisnu Ray 62 | - Telegram: [@SmartBisnuBio](https://t.me/SmartBisnuBio) 63 | 64 | Feel free to reach out if you have any questions or feedback. 65 | 66 | -------------------------------------------------------------------------------- /scribd.py: -------------------------------------------------------------------------------- 1 | """ 2 | Author: Bisnu Ray 3 | https://t.me/itsSmartDev 4 | """ 5 | 6 | import logging 7 | import re 8 | import requests 9 | import asyncio 10 | import json 11 | from aiogram import Bot, Dispatcher, executor, types 12 | from aiogram.utils.exceptions import MessageToDeleteNotFound 13 | 14 | # Initialize bot and dispatcher 15 | bot_token = '1234567890:AAGNaKh6J5jrK4og9FWkiGR1jifbZjTniik' # Replace with your bot's token 16 | bot = Bot(token=bot_token) 17 | dp = Dispatcher(bot) 18 | 19 | # Function to load cookies from a file 20 | def load_cookies(file_path): 21 | with open(file_path, 'r') as file: 22 | cookies_raw = json.load(file) 23 | if isinstance(cookies_raw, dict): 24 | return cookies_raw 25 | elif isinstance(cookies_raw, list): 26 | cookies = {} 27 | for cookie in cookies_raw: 28 | if 'name' in cookie and 'value' in cookie: 29 | cookies[cookie['name']] = cookie['value'] 30 | return cookies 31 | else: 32 | raise ValueError("Cookies are in an unsupported format.") 33 | 34 | # Function to extract necessary information from the first response 35 | def extract_information(response_json): 36 | print(extract_information) 37 | document = response_json.get('document', {}) 38 | title = document.get('title', 'Not Available') 39 | access_key = document.get('access_key', 'Not Available') 40 | author = document.get('author', {}) 41 | author_name = author.get('name', 'Not Available') 42 | receipt_url = response_json.get('receipt_url', 'Not Available') 43 | 44 | return { 45 | "title": title, 46 | "access_key": access_key, 47 | "author_name": author_name, 48 | "receipt_url": receipt_url 49 | } 50 | 51 | # Load cookies 52 | cookies = load_cookies('cookie.json') 53 | 54 | # First request 55 | try: 56 | response = requests.get(first_url, cookies=cookies) 57 | if response.status_code == 200: 58 | info = extract_information(response.json()) 59 | print("Title:", info['title']) 60 | print("Author Name:", info['author_name']) 61 | print("Receipt URL:", info['receipt_url']) 62 | 63 | # Construct the second URL using the extracted access_key and URL ID 64 | url_id = first_url.split('/')[-1] 65 | second_url = f"{base_second_url}{url_id}/?secret_password={info['access_key']}&extension=pdf" 66 | 67 | # Second request 68 | response = requests.get(second_url, cookies=cookies, allow_redirects=False) 69 | if response.status_code in [301, 302]: # Check if it's a redirect 70 | redirect_url = response.headers.get('Location') 71 | if redirect_url: 72 | print("Redirect URL from second request:", redirect_url) 73 | 74 | # Third request to the redirect URL 75 | third_response = requests.get(redirect_url, cookies=cookies, allow_redirects=False) 76 | if third_response.status_code in [301, 302]: 77 | final_redirect_url = third_response.headers.get('Location') 78 | if final_redirect_url: 79 | print("Final Redirect URL from third request:", final_redirect_url) 80 | else: 81 | print("No 'Location' header found in the third request.") 82 | else: 83 | print("Third request status code:", third_response.status_code) 84 | print("This URL didn't redirect as expected.") 85 | 86 | else: 87 | print("No redirect URL found in the headers of the second request.") 88 | else: 89 | print("Second request status code:", response.status_code) 90 | print("Response:") 91 | print(response.text) 92 | 93 | else: 94 | print("First request failed with status code:", response.status_code) 95 | except Exception as e: 96 | print("An error occurred:", e) 97 | 98 | 99 | 100 | @dp.message_handler(commands=['scribd']) # You Can Change the command scribd to any thing 101 | async def process_scribd_url(message: types.Message): 102 | user_id = message.from_user.id 103 | chat_id = message.chat.id 104 | 105 | # Check if the URL is valid 106 | url = message.get_args() 107 | match = re.search(r'scribd\.com/document/(\d+)|scribd\.com/doc/(\d+)|scribd\.com/presentation/(\d+)', url) 108 | if not url or not match: 109 | await message.answer("Please provide a valid Scribd URL after the /scribd ", parse_mode='HTML') 110 | return 111 | 112 | document_id = match.group(1) or match.group(2) 113 | first_url = f'https://www.scribd.com/doc-page/download-receipt-modal-props/{document_id}' 114 | 115 | # Send a loading message 116 | loading_message = await message.answer("Processing your request...", parse_mode='HTML') 117 | 118 | try: 119 | # Load cookies 120 | cookies = load_cookies('cookie.json') # Ensure the 'sc.json' file is in the correct path 121 | 122 | # First request 123 | response = requests.get(first_url, cookies=cookies) 124 | if response.status_code == 200: 125 | info = extract_information(response.json()) 126 | title = info['title'] 127 | author_name = info['author_name'] 128 | receipt_url = info['receipt_url'] 129 | 130 | # Construct the second URL using the extracted access_key and URL ID 131 | second_url = f"https://www.scribd.com/document_downloads/{document_id}/?secret_password={info['access_key']}&extension=pdf" 132 | 133 | # Second request 134 | response = requests.get(second_url, cookies=cookies, allow_redirects=False) 135 | if response.status_code in [301, 302]: 136 | redirect_url = response.headers.get('Location') 137 | if redirect_url: 138 | # Third request to the redirect URL 139 | third_response = requests.get(redirect_url, cookies=cookies, allow_redirects=False) 140 | if third_response.status_code in [301, 302]: 141 | final_redirect_url = third_response.headers.get('Location') 142 | if final_redirect_url: 143 | # Create the message text 144 | message_text = ( 145 | f"Here is the Download Link ✅\n" 146 | f"━━━━━━━━━━━━━━━━\n" 147 | f"Title: {title}\n" 148 | f"Author Name: {author_name}\n" 149 | f"Main Url: Click Here\n" 150 | f"Download Link: Download Now\n" 151 | f"━━━━━━━━━━━━━━━━\n" 152 | f"Scribd Downloader By: Study Mate" 153 | ) 154 | download_button = types.InlineKeyboardMarkup() 155 | download_button.add(types.InlineKeyboardButton(text="Download Now", url=final_redirect_url)) 156 | 157 | # Send the message with the inline button 158 | await message.answer(message_text, reply_markup=download_button, parse_mode='HTML') 159 | else: 160 | await message.answer("Failed to get the final redirect URL.", parse_mode='HTML') 161 | else: 162 | await message.answer("Failed to redirect from the second request.", parse_mode='HTML') 163 | else: 164 | await message.answer("No redirect URL found in the headers of the second request.", parse_mode='HTML') 165 | else: 166 | await message.answer(f"Second request failed with status code: {response.status_code}", parse_mode='HTML') 167 | else: 168 | await message.answer(f"First request failed with status code: {response.status_code}", parse_mode='HTML') 169 | 170 | except Exception as e: 171 | await message.answer(f"An error occurred: {e}", parse_mode='HTML') 172 | 173 | # After processing is complete, delete the loading message 174 | try: 175 | await bot.delete_message(chat_id, loading_message.message_id) 176 | except MessageToDeleteNotFound: 177 | pass # Message was already deleted 178 | 179 | 180 | # Be sure to start the reset task when the bot starts up 181 | if __name__ == '__main__': 182 | executor.start_polling(dp, skip_updates=True) 183 | --------------------------------------------------------------------------------