mirror of
https://github.com/ovosimpatico/CLI-TikTok.git
synced 2026-01-15 11:52:52 -03:00
code cleanup + trending videos amount
Signed-off-by: nanometer5088 <code.deleo@simplelogin.com>
This commit is contained in:
21
main.py
21
main.py
@@ -145,13 +145,9 @@ def main():
|
||||
## Stream trending videos
|
||||
if watchquestion == 3:
|
||||
log("The user chose to stream trending videos\n")
|
||||
print(
|
||||
"Due to specific limitations of the current data method, watching by creator will only get the latest 24 videos."
|
||||
)
|
||||
print(
|
||||
"This limitation is being actively researched, any contributions will be welcome."
|
||||
)
|
||||
streamtrending(24) # need to implement asking how many trending videos the user wants
|
||||
videos = int(input("How many videos do you want to see? "))
|
||||
if videos >= 1:
|
||||
streamtrending(videos)
|
||||
sys.exit()
|
||||
|
||||
# Error handling for invalid number (3, 4, 6, 133)
|
||||
@@ -224,14 +220,9 @@ def arguments(args):
|
||||
|
||||
elif args.streamtrending:
|
||||
log("The user chose to stream trending videos\n")
|
||||
print(
|
||||
"Due to specific limitations of the current data method, watching by creator will only get the latest 24 videos."
|
||||
)
|
||||
print(
|
||||
"This limitation is being actively researched, any contributions will be welcome."
|
||||
)
|
||||
streamtrending(24) # need to implement asking how many trending videos the user wants
|
||||
|
||||
videos = int(args.streamtrending)
|
||||
if videos >= 1:
|
||||
streamtrending(videos)
|
||||
if silent:
|
||||
arguments(args)
|
||||
else:
|
||||
|
||||
@@ -20,7 +20,7 @@ def streamuser(username):
|
||||
|
||||
|
||||
def proxitok_scraper(username: str) -> list[str]:
|
||||
print("Obtaining URLs - this can take a while with users with many posts.")
|
||||
print("\nObtaining URLs - this can take a while with users with many posts.")
|
||||
session = requests.Session()
|
||||
direct_links = []
|
||||
next_href = ""
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP = {
|
||||
"name": "CLI TikTok",
|
||||
"version": 0.6
|
||||
"version": 0.75
|
||||
}
|
||||
@@ -4,34 +4,6 @@ import random
|
||||
import requests
|
||||
from log import logtofile as log
|
||||
|
||||
## 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")
|
||||
linhas = arquivo.readlines()
|
||||
tamanho = len(linhas)
|
||||
arquivo.close()
|
||||
|
||||
vet = []
|
||||
listalinks = []
|
||||
listadatas = []
|
||||
arquivo = open("Likes.txt", "r", encoding="utf-8")
|
||||
|
||||
while i <= tamanho:
|
||||
lelinha = arquivo.readline().rstrip()
|
||||
vet.append(lelinha.split())
|
||||
i += 1
|
||||
arquivo.close()
|
||||
|
||||
for i in range(2, len(vet), 3):
|
||||
listalinks.append(vet[i - 1][1])
|
||||
|
||||
for i in range(2, len(vet), 3):
|
||||
listadatas.append(vet[i - 2][1] + " " + vet[i - 2][2])
|
||||
log("Likes.txt file was processed sucessfully")
|
||||
return listalinks, listadatas
|
||||
|
||||
def listas():
|
||||
# Retrieves tiktok likes and dates from user_data.json
|
||||
import json
|
||||
@@ -48,13 +20,6 @@ def listas():
|
||||
return linklist, datelist
|
||||
|
||||
|
||||
# Unused function - Might be useful in future iterations of the project
|
||||
# https://github.com/nanometer5088/CLI-TikTok/commit/ad589d7b324042ee85a270625df3ad9f6f82ab8a
|
||||
def removevideo():
|
||||
if os.path.exists(os.getcwd() + "/video/video"):
|
||||
os.remove(os.getcwd() + "/video/video")
|
||||
|
||||
|
||||
# Broken as of 2023-02-03
|
||||
# A workaround has been put in place
|
||||
def detect_dead_link(url):
|
||||
@@ -70,7 +35,8 @@ def detect_dead_link(url):
|
||||
def url_redirection(url):
|
||||
# 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"
|
||||
# Chrome 113 on Windows 10 - Common useragent to reduce chances of a captcha
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36"
|
||||
}
|
||||
response = requests.get(url, headers=headers)
|
||||
return response.url
|
||||
|
||||
@@ -30,7 +30,7 @@ def init(silent):
|
||||
input("Press ENTER to proceed")
|
||||
|
||||
log("Started dependency test")
|
||||
required_libraries = ["atoma", "requests", "yt_dlp", "distro"]
|
||||
required_libraries = ["atoma", "requests", "yt_dlp", "distro", "bs4"]
|
||||
missing_libraries = [library for library in required_libraries if not _library_exists(library)]
|
||||
if missing_libraries:
|
||||
log("Dependency test failed - Missing libraries: " + ", ".join(missing_libraries))
|
||||
|
||||
@@ -22,7 +22,7 @@ def streamtrending(amount:int = 24):
|
||||
|
||||
|
||||
def proxitok_trending(amount: int = 24) -> list[str]:
|
||||
print("Obtaining URLs - this can take a while when requesting many posts.")
|
||||
print("\nObtaining URLs - this can take a while when requesting many posts.")
|
||||
session = requests.Session()
|
||||
direct_links = []
|
||||
next_href = ""
|
||||
|
||||
Reference in New Issue
Block a user