mirror of
https://github.com/bellingcat/facebook-downloader.git
synced 2026-06-11 04:58:30 +03:00
Compare commits
21 Commits
2022.1.2.0
...
1.3.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ddd14c151d | ||
|
|
18213172aa | ||
|
|
99dc9e3ea7 | ||
|
|
1126a72a9f | ||
|
|
de660b30f4 | ||
|
|
07bf9a0220 | ||
|
|
0a8454fcf9 | ||
|
|
8abc59474b | ||
|
|
885676d826 | ||
|
|
59d8a30d85 | ||
|
|
fa12e7e477 | ||
|
|
d38eb6aefe | ||
|
|
eda82c051d | ||
|
|
e1c15ddb0f | ||
|
|
47844da5b8 | ||
|
|
aebb6f0e65 | ||
|
|
37e028c769 | ||
|
|
a65a1f65d5 | ||
|
|
864f80921e | ||
|
|
b1760aad56 | ||
|
|
52df5b63ae |
16
Dockerfile
Normal file
16
Dockerfile
Normal 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"]
|
||||
2
LICENSE
2
LICENSE
@@ -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.
|
||||
|
||||
17
README.md
17
README.md
@@ -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
|
||||
[](https://github.com/rly0nheart/facebook-downloader/actions/workflows/python-publish.yml)
|
||||
[](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
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user