21 Commits

Author SHA1 Message Date
Richard Mwewa
ddd14c151d Update README.md 2023-01-02 05:14:30 +02:00
Richard Mwewa
18213172aa Switched to semantic versioning 2023-01-02 05:11:48 +02:00
Richard Mwewa
99dc9e3ea7 Update README.md 2023-01-02 05:03:04 +02:00
Richard Mwewa
1126a72a9f Update README.md 2023-01-02 04:57:08 +02:00
Richard Mwewa
de660b30f4 Update README.md 2023-01-02 04:56:22 +02:00
Richard Mwewa
07bf9a0220 Update main.py 2023-01-02 04:49:33 +02:00
Richard Mwewa
0a8454fcf9 Switched to semantic versioning 2023-01-02 04:32:51 +02:00
Richard Mwewa
8abc59474b Update main.py 2023-01-02 04:13:52 +02:00
Richard Mwewa
885676d826 Update downloader.py 2023-01-02 04:12:24 +02:00
Richard Mwewa
59d8a30d85 Update LICENSE 2023-01-02 04:06:54 +02:00
Richard Mwewa
fa12e7e477 Update Dockerfile 2022-12-02 23:15:58 +02:00
Richard Mwewa
d38eb6aefe Update Dockerfile 2022-12-02 23:06:09 +02:00
Richard Mwewa
eda82c051d Update Dockerfile 2022-11-27 02:40:29 +02:00
Richard Mwewa
e1c15ddb0f Update README.md 2022-11-03 01:32:31 +02:00
Richard Mwewa
47844da5b8 Merge pull request #1 from rly0nheart/dev
Create Dockerfile
2022-11-03 01:25:26 +02:00
Richard Mwewa
aebb6f0e65 Update README.md 2022-10-31 21:36:03 +02:00
Richard Mwewa
37e028c769 Create Dockerfile 2022-10-31 19:17:02 +02:00
Richard Mwewa
a65a1f65d5 Update README.md 2022-10-21 23:28:18 +02:00
Richard Mwewa
864f80921e Update setup.py 2022-10-21 23:23:42 +02:00
Richard Mwewa
b1760aad56 Update downloader.py 2022-10-21 23:23:39 +02:00
Richard Mwewa
52df5b63ae Update downloader.py 2022-10-21 23:22:30 +02:00
6 changed files with 45 additions and 21 deletions

16
Dockerfile Normal file
View File

@@ -0,0 +1,16 @@
FROM python:latest
WORKDIR /app
COPY . .
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates curl firefox-esr \
&& rm -fr /var/lib/apt/lists/* \
&& curl -L https://github.com/mozilla/geckodriver/releases/download/v0.32.0/geckodriver-v0.32.0-linux64.tar.gz | tar xz -C /usr/local/bin \
&& apt-get purge -y ca-certificates curl
RUN pip install --upgrade pip && pip install build && python -m build
RUN pip install dist/*.whl
ENTRYPOINT ["facebook_downloader"]

View File

@@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Facebook-Downloader Copyright (C) 2022 Richard Mwewa
Facebook-Downloader Copyright (C) 2023 Richard Mwewa
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.

View File

@@ -1,17 +1,24 @@
# Facebook Downloader
A program for downloading videos from Facebook, given a video url
A program for downloading videos from facebook, given a video url
[![Upload Python Package](https://github.com/rly0nheart/facebook-downloader/actions/workflows/python-publish.yml/badge.svg)](https://github.com/rly0nheart/facebook-downloader/actions/workflows/python-publish.yml)
[![CodeQL](https://github.com/rly0nheart/facebook-downloader/actions/workflows/codeql.yml/badge.svg)](https://github.com/rly0nheart/facebook-downloader/actions/workflows/codeql.yml)
# Installation
**Install from PyPI**
## Install from PyPI
```
pip install facebook-downloader
```
### Note
> You will need to have the FireFox browser installed on your pc
> You will need to have the FireFox browser installed on your pc (for the PyPI Package)
>> The program is dependent on selenium, so in order to run it, you will have to download and properly setup geckodriver (setup instructions available below)
# Docker
## Pull the image
```
docker pull rly0nheart/facebook-downloader:facebook-downloader
```
# Geckodriver setup
## Linux
**1. Go to the geckodriver [releases page](https://github.com/mozilla/geckodriver/releases/). Find the latest version of the driver for your platform and download it**
@@ -46,6 +53,10 @@ export PATH=$PATH:/path/to/downloaded/geckodriver
facebook_downloader <video-url>
```
# Docker
```
docker run -it -v $PWD/downloads:/app/downloads facebook-downloader <facebook_url>
```
## Note
> The url format should be as follows; https://www.facebook.com/PageName/videos/VideoID

View File

@@ -21,30 +21,29 @@ class FacebookDownloader:
option.add_argument('--headless')
self.driver = webdriver.Firefox(options=option)
self.program_version_number = "2022.1.2.0"
self.program_version_number = "1.3.1"
self.downloading_url = "https://getfvid.com"
self.update_check_endpoint = "https://api.github.com/repos/rly0nheart/facebook-downloader/releases/latest"
def notice(self):
notice_msg = f"""
facebook-downloader {self.program_version_number} Copyright (C) 2022 Richard Mwewa
return f"""
facebook-downloader v{self.program_version_number} Copyright (C) 2023 Richard Mwewa
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
"""
print(notice_msg)
def check_updates(self):
self.notice()
print(self.notice())
response = requests.get(self.update_check_endpoint).json()
if response['tag_name'] == self.program_version_number:
"""Ignore if the program is up to date"""
pass
else:
print(f"[!] A new release is available ({response['tag_name']}). Run 'pip install --upgrade facebook-downloader' to get the updates.")
print(f"[UPDATE] A new release is available ({response['tag_name']}). Run 'pip install --upgrade facebook-downloader' to get the updates.")
def download_type(self):
@@ -66,9 +65,7 @@ class FacebookDownloader:
def path_finder(self):
directory_list = [os.path.join('downloads', 'videos'), os.path.join('downloads', 'audio')]
for directory in directory_list:
os.makedirs(directory, exist_ok=True)
os.makedirs("downloads", exist_ok=True)
def download_video(self):
@@ -78,17 +75,17 @@ class FacebookDownloader:
url_entry_field = self.driver.find_element(By.NAME, "url") # Find the url entry field
url_entry_field.send_keys(self.args.url) # write facebook url in the entry field
url_entry_field.send_keys(Keys.ENTER) # press enter
print('Please standby (20 seconds)...')
self.driver.refresh
print('[INFO] Loading web resource, please wait...')
# self.driver.refresh
download_btn = WebDriverWait(self.driver, 20).until(expected_conditions.presence_of_element_located((By.XPATH, self.download_type()))) # Find the download button (this clicks the first button which returns a video in hd)
download_url = download_btn.get_attribute('href')
with requests.get(download_url, stream=True) as response:
response.raise_for_status()
with open(os.path.join('downloads', 'videos', f'{self.args.output}.mp4'), 'wb') as file:
for chunk in tqdm(response.iter_content(chunk_size=8192), desc=f'Downloading: {self.args.output}.mp4'):
with open(os.path.join('downloads', f'{self.args.output}.mp4'), 'wb') as file:
for chunk in tqdm(response.iter_content(chunk_size=8192), desc=f'[INFO] Downloading: {self.args.output}.mp4'):
file.write(chunk)
print(f'Downloaded: {file.name}')
print(f'[INFO] Downloaded: {file.name}')
self.driver.close()

View File

@@ -6,7 +6,7 @@ def main():
start.download_video()
except KeyboardInterrupt:
print('Process interrupted with Ctrl+C.')
print('[WARNING] Process interrupted with Ctrl+C.')
except Exception as e:
print('An error occured:', e)
print('[ERROR]', e)

View File

@@ -5,7 +5,7 @@ with open('README.md', 'r', encoding='utf-8') as file:
setuptools.setup(
name='facebook-downloader',
version='2022.1.2.0',
version='1.3.1',
author='Richard Mwewa',
author_email='rly0nheart@duck.com',
packages=['facebook_downloader'],