diff options
| author | Pinapelz <donaldshan1@outlook.com> | 2023-05-06 21:59:20 -0700 |
|---|---|---|
| committer | Pinapelz <donaldshan1@outlook.com> | 2023-05-06 21:59:20 -0700 |
| commit | 2c55d6f17d2f3888d1697c01b2a3f465063a1e0f (patch) | |
| tree | eaa0269d2cb9ee49268427ebe45d4a1e6ec9fdfa | |
| parent | 7b0157a79378847bd3aa4e10e30f0a929ca27c53 (diff) | |
Add manually pulling channel files from an external URL
| -rw-r--r-- | fileutil.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/fileutil.py b/fileutil.py index 0124a06..6cc1351 100644 --- a/fileutil.py +++ b/fileutil.py @@ -1,4 +1,5 @@ import os.path +import urllib.request import json import time @@ -74,3 +75,14 @@ def check_diff_refresh(): with open(os.path.join("data","last_refresh.txt"), "w", encoding="utf-8") as file: file.write(time.strftime("%Y-%m-%d")) return True + +def update_data_files(url: str) -> None: + # Updates the local txt channel data stored in data folder + if not os.path.exists(os.path.join("data","channels.txt")): + open(os.path.join("data","channels.txt"), "w").close() + urllib.request.urlretrieve(url+"channels.txt", os.path.join("data","channels.txt")) + # downloaded txt file from url and write to channels.txt + + if not os.path.exists(os.path.join("data","exclude_channel.txt")): + open(os.path.join("data","exclude_channel.txt"), "w").close() + urllib.request.urlretrieve(url+"exclude_channel.txt", os.path.join("data","exclude_channel.txt")) |
