-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Update] new structure + bookmarks + basic menu
- Loading branch information
1 parent
e1b3acf
commit 255f075
Showing
15 changed files
with
119 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
// do not modify this | ||
export const FB_API_HOST = "https://graph.facebook.com"; | ||
export const FB_API_HOST = "https://graph.facebook.com/v12.0"; | ||
|
||
// you can modify all the variables below | ||
export const ACCESS_TOKEN = "YOUR_ACCESS_TOKEN"; | ||
export const WAIT_BEFORE_NEXT_FETCH = 0; | ||
export const ID_LINK_SEPERATOR = ";"; | ||
export const FOLDER_TO_SAVE_LINKS = "links"; | ||
export const FOLDER_TO_SAVE_IMAGES = 'images'; | ||
export const PHOTO_FILE_FORMAT = 'png'; // OR jpg | ||
export const FOLDER_TO_SAVE_LINKS = "downloads/links"; | ||
export const FOLDER_TO_SAVE_IMAGES = 'downloads/images'; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import fetch from "node-fetch"; | ||
import { ACCESS_TOKEN, FB_API_HOST } from "../config.js"; | ||
|
||
export const fetchGroupFeeds = async (groupId) => { | ||
const fetchOnce = async (_url) => { | ||
try { | ||
const response = await fetch(_url); | ||
const json = await response.json(); | ||
return json; | ||
} catch (e) { | ||
return {}; | ||
} | ||
}; | ||
|
||
const url = `${FB_API_HOST}/${groupId}/feed?fields=attachments&access_token=${ACCESS_TOKEN}`; | ||
const firstFetch = await fetchOnce(url); | ||
|
||
}; | ||
|
||
fetchGroupFeeds(697332711026460); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import readline from "readline"; | ||
import { | ||
fetchAlbumInfo, | ||
saveAlbumPhoto, | ||
saveAlbumPhotoLinks, | ||
} from "./download_album.js"; | ||
import { | ||
fetchTimeLineAlbumId, | ||
saveTimeLineAlbum_FBPage, | ||
saveTimeLineAlbumPhotoLinks_FBPage, | ||
} from "./download_timeline_album.js"; | ||
|
||
// https://stackoverflow.com/a/68504470 | ||
const rl = readline.createInterface({ | ||
input: process.stdin, | ||
output: process.stdout, | ||
}); | ||
const prompt = (query) => new Promise((resolve) => rl.question(query, resolve)); | ||
rl.on("close", () => process.exit(0)); | ||
|
||
const wait_input = async () => await prompt(""); | ||
|
||
const choose = async (title, menu_items) => { | ||
let ui = `\n======== ${title} ========`; | ||
Object.entries(menu_items).map(([key, value], index) => { | ||
ui += `\n${key}: ${value}`; | ||
}); | ||
console.log(ui); | ||
|
||
while (true) { | ||
const input = await prompt("> Choose action: "); | ||
if (input in menu_items) { | ||
return { | ||
key: input, | ||
value: menu_items[input], | ||
}; | ||
} else { | ||
console.log("[!] Invalid. Please choose again."); | ||
} | ||
} | ||
}; | ||
|
||
// ========================================== MENU ========================================= | ||
|
||
export const menu = async () => { | ||
while (true) { | ||
const main_menu = { | ||
0: "Download Album", | ||
3: "Get Album Infomation", | ||
4: "Exit", | ||
}; | ||
|
||
const action = await choose("FB Album Downloader Tool", main_menu); | ||
if (action.key == 2) { | ||
const album_id = await prompt("Enter album id: "); | ||
const album_info = await fetchAlbumInfo(album_id); | ||
console.log(album_info); | ||
} | ||
if (action.key == 3) break; | ||
} | ||
|
||
rl.close(); | ||
}; |
File renamed without changes.
File renamed without changes.