-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
newsfeed_functions.py
37 lines (25 loc) · 1.22 KB
/
newsfeed_functions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import bpy
import os
from .addon_prefs import get_addon_preferences
from .global_variables import newsfeed_file, newsfeed_url
from .internet_functions import download_file
from .json_functions import read_json, load_json_in_collection
from .print_functions import print_and_report
# download newsfeed file if needed
def download_newsfeed(manifest_dataset):
newsfeed_path = os.path.join(get_addon_preferences().download_folder, newsfeed_file)
if not os.path.isfile(newsfeed_path):
download_file(newsfeed_url, newsfeed_path)
print_and_report(None, "Downloading Newsfeed", "INFO") #debug
return True
elif manifest_dataset["newsfeed_hash"] != read_json(newsfeed_path)["newsfeed_hash"]:
download_file(newsfeed_url, newsfeed_path)
print_and_report(None, "Downloading Newsfeed", "INFO") #debug
return True
return False
# reload newsfeed datas
def reload_newsfeed():
print_and_report(None, "Loading Newsfeed", "INFO") #debug
newsfeed_path = os.path.join(get_addon_preferences().download_folder, newsfeed_file)
properties_coll = bpy.data.window_managers[0].an_templates_properties
load_json_in_collection(read_json(newsfeed_path), properties_coll.news, 'news')