mirror of
https://github.com/harry0703/MoneyPrinterTurbo.git
synced 2026-02-21 08:27:22 +08:00
add pexels.proxies
This commit is contained in:
parent
d8b3a1af49
commit
753ec011d8
@ -12,6 +12,8 @@ with open(config_file, mode="rb") as fp:
|
||||
|
||||
app = _cfg.get("app", {})
|
||||
whisper = _cfg.get("whisper", {})
|
||||
pexels = _cfg.get("pexels", {})
|
||||
|
||||
hostname = socket.gethostname()
|
||||
|
||||
log_level = _cfg.get("log_level", "DEBUG")
|
||||
|
||||
@ -33,12 +33,12 @@ def search_videos(search_term: str,
|
||||
headers = {
|
||||
"Authorization": round_robin_api_key()
|
||||
}
|
||||
|
||||
proxies = config.pexels.get("proxies", None)
|
||||
# Build URL
|
||||
query_url = f"https://api.pexels.com/videos/search?query={search_term}&per_page=15&orientation={video_orientation}&locale={locale}"
|
||||
logger.info(f"searching videos: {query_url}")
|
||||
logger.info(f"searching videos: {query_url}, with proxies: {proxies}")
|
||||
# Send the request
|
||||
r = requests.get(query_url, headers=headers)
|
||||
r = requests.get(query_url, headers=headers, proxies=proxies, verify=False)
|
||||
|
||||
# Parse the response
|
||||
response = r.json()
|
||||
@ -71,8 +71,9 @@ def search_videos(search_term: str,
|
||||
def save_video(video_url: str, save_dir: str) -> str:
|
||||
video_id = f"vid-{str(int(time.time() * 1000))}"
|
||||
video_path = f"{save_dir}/{video_id}.mp4"
|
||||
proxies = config.pexels.get("proxies", None)
|
||||
with open(video_path, "wb") as f:
|
||||
f.write(requests.get(video_url).content)
|
||||
f.write(requests.get(video_url, proxies=proxies, verify=False).content)
|
||||
|
||||
return video_path
|
||||
|
||||
|
||||
@ -50,4 +50,13 @@
|
||||
model_size="large-v3"
|
||||
# if you want to use GPU, set device="cuda"
|
||||
device="CPU"
|
||||
compute_type="int8"
|
||||
compute_type="int8"
|
||||
|
||||
[pexels]
|
||||
[pexels.proxies]
|
||||
### Use a proxy to access the Pexels API
|
||||
### Format: "http://<username>:<password>@<proxy>:<port>"
|
||||
### Example: "http://user:pass@proxy:1234"
|
||||
### Doc: https://requests.readthedocs.io/en/latest/user/advanced/#proxies
|
||||
# http = "http://10.10.1.10:3128"
|
||||
# https = "http://10.10.1.10:1080"
|
||||
Loading…
Reference in New Issue
Block a user