diff --git a/.gitignore b/.gitignore index 0ea6a17..96131b6 100644 --- a/.gitignore +++ b/.gitignore @@ -130,6 +130,8 @@ dmypy.json #Project files Likes.txt +user_data.json features-missing.txt /video -/logs \ No newline at end of file +/logs +test.py \ No newline at end of file diff --git a/README.md b/README.md index 93e961d..b351814 100644 --- a/README.md +++ b/README.md @@ -33,13 +33,11 @@ This is a TikTok archiver and viewer. It supports watching or archiving your lik 4) Extract **all** files to an empty folder. -5) Move your `Likes.txt` file to the folder. Refer to [How to get video list](https://github.com/nanometer5088/CLI-TikTok/blob/main/docs/HowToGetVideoList.md) for more details on how to get yours. +5) Move your `user_data.json` file to the folder. Refer to [How to get video list](https://github.com/nanometer5088/CLI-TikTok/blob/main/docs/HowToGetVideoList.md) for more details on how to get yours. 6) Open a terminal within the folder. -7) `pip install -r requirements.txt` - -8) `main.py` +7) Run `main.py` ## Contributing diff --git a/docs/HowToGetVideoList.md b/docs/HowToGetVideoList.md index c72140e..ee562ab 100644 --- a/docs/HowToGetVideoList.md +++ b/docs/HowToGetVideoList.md @@ -1,4 +1,4 @@ -## How to get your `Likes.txt` file: +## How to get your `user_data.json` file: # @@ -10,7 +10,7 @@ ![2](assets/2.png) -### 3. Select `TXT` as the file format and request your data. This process might take a couple days. You'll be notified once it's ready to download. +### 3. Select `JSON` as the file format and request your data. This process might take a couple days. You'll be notified once it's ready to download. ![3](assets/3.png) @@ -18,6 +18,6 @@ ![4](assets/4.png) -### 5. Your liked videos will be in `Activity\Like List.txt`. Rename the file as `Likes.txt` +### 5. Your liked videos will be inside the compressed file. Extract the file to the software folder. ![5](assets/5.png) \ No newline at end of file diff --git a/docs/assets/3.png b/docs/assets/3.png index da571ea..e1ee879 100644 Binary files a/docs/assets/3.png and b/docs/assets/3.png differ diff --git a/docs/assets/5.png b/docs/assets/5.png index 1dead58..9f4d896 100644 Binary files a/docs/assets/5.png and b/docs/assets/5.png differ diff --git a/main.py b/main.py index 40d0704..4683b0f 100644 --- a/main.py +++ b/main.py @@ -153,13 +153,13 @@ except ValueError: log("The user entered an invalid non-numeric choice, and the software exited") print("The option you chose isn't valid.") - # Error handling for missing Likes.txt file + # Error handling for missing user_data.json file except FileNotFoundError: log( - "The user does not have a Likes.txt file, but chose an option that depends on it, so the software exited" + "The user does not have a user_data.json file, but chose an option that depends on it, so the software exited" ) print( - "The 'Likes.txt' file was not found. Make sure it is in the program folder and try again." + "The 'user_data.json' file was not found. Make sure it is in the program folder and try again." ) # Error handling for MPV media player or MPV not found in PATH diff --git a/src/functions.py b/src/functions.py index 7980b51..fe691aa 100644 --- a/src/functions.py +++ b/src/functions.py @@ -4,8 +4,8 @@ import random import requests from log import logtofile as log - -def listas(): +## DEPRECATED - USE user_data.json instead +def listas_deprecated(): # Retrieves tiktok links and dates from Likes.txt i = 0 arquivo = open("Likes.txt", "r", encoding="utf-8") @@ -32,6 +32,21 @@ def listas(): log("Likes.txt file was processed sucessfully") return listalinks, listadatas +def listas(): + # Retrieves tiktok likes and dates from user_data.json + import json + f = open('user_data.json') + linklist = [] + datelist = [] + data = json.load(f) + + for i in data['Activity']["Like List"]['ItemFavoriteList']: + linklist.append(i['Link']) + datelist.append(i['Date']) + f.close() + log("user_data.json file was processed sucessfully") + return linklist, datelist + # Unused function - Might be useful in future iterations of the project # https://github.com/nanometer5088/CLI-TikTok/commit/ad589d7b324042ee85a270625df3ad9f6f82ab8a @@ -53,7 +68,7 @@ def detect_dead_link(url): def url_redirection(url): - # Tiktok links from the Likes.txt are shortened. They need to be redirected to the final link, which is done here. + # Tiktok links from the user_data.json are shortened. They need to be redirected to the final link, which is done here. headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; rv:109.0) Gecko/20100101 Firefox/109.0" } @@ -62,5 +77,5 @@ def url_redirection(url): def randomvideo(urls): - # Chooses a random video from Likes.txt - Optional Feature + # Chooses a random video from user_data.json - Optional Feature return random.randint(0, (len(urls) - 1))