mirror of
https://github.com/ovosimpatico/CLI-TikTok.git
synced 2026-01-15 11:52:52 -03:00
Using JSON instead of TXT Likes!
Unlike TXT, JSON is a machine-readable file, meaning it'll be easier to get information and more reliable against changes by TikTok!
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -130,6 +130,8 @@ dmypy.json
|
||||
|
||||
#Project files
|
||||
Likes.txt
|
||||
user_data.json
|
||||
features-missing.txt
|
||||
/video
|
||||
/logs
|
||||
/logs
|
||||
test.py
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
## How to get your `Likes.txt` file:
|
||||
## How to get your `user_data.json` file:
|
||||
|
||||
#
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||

|
||||
|
||||
### 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.
|
||||
|
||||

|
||||
|
||||
@@ -18,6 +18,6 @@
|
||||
|
||||

|
||||
|
||||
### 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.
|
||||
|
||||

|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 98 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 24 KiB |
6
main.py
6
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
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user