Fix twitter not working on fresh installations

There was a problem with cache not being created
This commit is contained in:
pluja 2020-10-10 09:41:14 +02:00
parent 46fc7ae832
commit 53586d0195
2 changed files with 13 additions and 4 deletions

View File

@ -77,8 +77,10 @@ def twitter(page=0):
posts = []
cache_file = glob.glob("app/cache/{}_*".format(current_user.username))
time_diff = round(time.time()-os.path.getmtime(cache_file[0]))
if(len(cache_file) > 0):
time_diff = round(time.time()-os.path.getmtime(cache_file[0]))
else:
time_diff = 999
# If cache file is more than 1 minute old
if page == 0 and time_diff > 60:
if cache_file:
@ -663,6 +665,7 @@ def importYoutubeSubscriptions(file):
def importYotterSubscriptions(file):
filename = secure_filename(file.filename)
data = json.load(file)
print(data)
for acc in data['twitter']:
r = followTwitterAccount(acc['username'])

View File

@ -259,8 +259,14 @@ def get_video_info(id):
jsonIni = response[start:end1]
dataInitial = json.loads(jsonIni)
jsonDet = response[start2:end2]
dataDetails = json.loads(jsonDet)
try:
jsonDet = response[start2:end2]
dataDetails = json.loads(jsonDet)
except:
response = requests.get(url, headers=headers).json()
jsonDet = response[start2:end2]
dataDetails = json.loads(jsonDet)
#title, views, date
videoInfo = get_video_primary_info(dataDetails, dataInitial)