Merge pull request 'removing cache folder and view and json files are no longer used.' (#1) from development into main

Reviewed-on: #1
This commit is contained in:
2025-06-27 15:46:19 -04:00
4 changed files with 0 additions and 218 deletions
View File
-89
View File
@@ -1,89 +0,0 @@
import os
import progressbar
from pathlib import Path
from time import sleep
from tqdm import tqdm
class Cacher(object):
def __init__(self):
pass
def process(self, options, jget, new_updates, ROOTDIR, URLS):
SERIESCACHE = str(ROOTDIR) + '/cache/series/'
EPISODECACHE = str(ROOTDIR) + '/cache/episodes/'
CASTCACHE = str(ROOTDIR) + '/cache/cast/'
CREWCACHE = str(ROOTDIR) + '/cache/crew/'
TEMPDIR = ROOTDIR + '/temp/'
available_updates = {}
updateList = []
if options['refreshcache'] == '1':
print('Refreshing cache directory.')
print('Checking cache directory for missing files.')
for update in new_updates:
available_updates[update[0]] = update[1]
updateList = [str(key) for key in available_updates.keys()]
for series in tqdm(range(len(new_updates)), desc='Checking cache', unit='series'):
seriesid = new_updates[series][0]
cachefile = str(seriesid) + '.json'
seriescachefile = f'{SERIESCACHE}{cachefile}'
episodecachefile = f'{EPISODECACHE}{cachefile}'
castcachefile = f'{CASTCACHE}{cachefile}'
crewcachefile = f'{CREWCACHE}{cachefile}'
self.check_and_download(jget, URLS['showurl'], str(seriesid), new_updates[0], seriescachefile, 1500)
sleep(1)
self.check_and_download(jget, URLS['episodesurl'], str(seriesid), new_updates[0], episodecachefile, 1500)
sleep(1)
self.check_and_download(jget, URLS['casturl'], str(seriesid), new_updates[0], castcachefile, 500)
sleep(1)
self.check_and_download(jget, URLS['crewurl'], str(seriesid), new_updates[0], crewcachefile, 500)
sleep(1)
print('Refresh completed.')
def check_and_download(self, jget, url, SERIESID, series_id, cachefile, size_limit):
try:
my_abs_path = Path(cachefile).resolve(strict=True)
file_stats = os.stat(cachefile)
if file_stats.st_size <= size_limit:
#print(f'File Size for {cachefile} in Bytes is {file_stats.st_size}. File too small. Attempting to download.')
jget.fetch_json(url.replace(SERIESID, str(series_id)), series_id, cachefile)
except FileNotFoundError:
#print(f'{cachefile} does not exist. Attempting to download.')
jget.fetch_json(url.replace(SERIESID, str(series_id)), series_id, cachefile)
except Exception as e:
print(f'Unable to download {cachefile}. {e}')
def update_cache(self, jget, updateList, ROOTDIR, URLS, options, lprint):
if options['skipcache'] == '0':
SERIESCACHE = str(ROOTDIR) + '/cache/series/'
EPISODECACHE = str(ROOTDIR) + '/cache/episodes/'
CASTCACHE = str(ROOTDIR) + '/cache/cast/'
CREWCACHE = str(ROOTDIR) + '/cache/crew/'
TEMPDIR = ROOTDIR + '/temp/'
print('Now downloading updates.')
updaterange = len(updateList)
for seriesid in tqdm(range(updaterange), desc='Downloading updates', unit='seriesid'):
cachefile = f'{updateList[seriesid]}.json'
seriescachefile = SERIESCACHE + cachefile
episodecachefile = EPISODECACHE + cachefile
castcachefile = CASTCACHE + cachefile
crewcachefile = CREWCACHE + cachefile
self.download_json(jget, URLS['showurl'], updateList[seriesid], seriescachefile, lprint)
sleep(1)
self.download_json(jget, URLS['episodesurl'], updateList[seriesid], episodecachefile, lprint)
sleep(1)
self.download_json(jget, URLS['casturl'], updateList[seriesid], castcachefile, lprint)
sleep(1)
self.download_json(jget, URLS['crewurl'], updateList[seriesid], crewcachefile, lprint)
sleep(1)
def download_json(self, jget, url, seriesid, cachefile, lprint):
try:
jget.fetch_json(url.replace('<seriesid>', str(seriesid)), seriesid, cachefile)
except Exception as e:
lprint.logprint('info', f'Unable to acquire {cachefile}. {e}')
def __del__(self):
pass
-80
View File
@@ -1,80 +0,0 @@
__author__ = 'Wendell Jones'
from ast import Global
import json
import progressbar
class Process_View(object):
global seriesinfo
global episodeinfo
def __init__(self):
pass
def process_seriesdata(self, seriesdata):
seriesinfo = {}
seriesinfo['seriesid'] = seriesdata['id']
seriesinfo['seriesurl'] = seriesdata['url']
seriesinfo['seriesname'] = seriesdata['name']
seriesinfo['seriestype'] = seriesdata['type']
seriesinfo['series_language'] = seriesdata['language']
seriesinfo['series_genres'] = ', '.join(seriesdata['genres'])
seriesinfo['series_status'] = seriesdata['status']
seriesinfo['series_runtime'] = seriesdata['runtime']
seriesinfo['series_premiered'] = seriesdata['premiered']
seriesinfo['offcialsite'] = seriesdata['officialSite']
seriesinfo['air_day'] = ', '.join(seriesdata['schedule']['days'])
seriesinfo['air_time'] = seriesdata['schedule']['time']
seriesinfo['rating'] = seriesdata['rating']['average']
seriesinfo['weight'] = seriesdata['weight']
seriesinfo['networkid'] = seriesdata['network']['id']
seriesinfo['networkname'] = seriesdata['network']['name']
seriesinfo['tvrageid'] = seriesdata['externals']['tvrage']
seriesinfo['tvdbid'] = seriesdata['externals']['thetvdb']
seriesinfo['imdbid'] = seriesdata['externals']['imdb']
seriesinfo['countryname'] = seriesdata['network']['country']['name']
seriesinfo['countrycode'] = seriesdata['network']['country']['code']
seriesinfo['timezone'] = seriesdata['network']['country']['timezone']
self.print_seriesdata(seriesinfo)
def print_seriesdata(self, seriesinfo):
print(f"Series ID: {seriesinfo['seriesid']}")
print(f"Series URL: {seriesinfo['seriesurl']}")
print(f"Series Name: {seriesinfo['seriesname']}")
print(f"Type of Series: {seriesinfo['seriestype']}")
print(f"Lanuguage: {seriesinfo['series_language']}")
print(f"Genres: {seriesinfo['series_genres']}")
print(f"Series Status: {seriesinfo['series_status']}")
print(f"Run Time: {seriesinfo['series_runtime']}")
print(f"Premier Date: {seriesinfo['series_premiered']}")
print(f"Official Website: {seriesinfo['offcialsite']}")
print(f"Day Aired: {seriesinfo['air_day']}")
print(f"Time Aired: {seriesinfo['air_time']}")
print(f"Rating: {seriesinfo['rating']}")
print(f"Weight: {seriesinfo['weight']}")
print(f"Network ID: {seriesinfo['networkid']}")
print(f"Network Name: {seriesinfo['networkname']}")
print(f"TVRage ID: {seriesinfo['tvrageid']}")
print(f"TVDB ID: {seriesinfo['tvdbid']}")
print(f"IMDB ID: {seriesinfo['imdbid']}")
print(f"Country: {seriesinfo['countryname']}")
print(f"Country Code: {seriesinfo['countrycode']}")
print(f"Timezone: {seriesinfo['timezone']}")
def process_episodedata(self, episodeinfo):
episodeinfo = {}
def print_episodedata(self, episodeinfo):
for episode in episodeinfo:
print(f"Air Date: {episode['airdate']}")
print(f"Air Time: {episode['airtime']}")
print(f"Season: {episode['season']}")
print(f"Episode: {episode['number']}")
print(f"Episode Name: {episode['name']}")
print(f"Summary: {episode['summary']}")
print(f"Rating: {episode['rating']['average']}")
print(f"Medium Image: {episode['image']['medium']}")
print(f"Original Image: {episode['image']['original']}")
def __del__(self):
pass
-49
View File
@@ -1,49 +0,0 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import time
import json
from pathlib import Path
import db.sql
from jprocessor.process import Jsonload
from jprocessor.process_view import Process_View
import logs.Logger
from db.functions import settype, dbmongo
if __name__ == "__main__":
seriesid = input('Please enter seriesid: ')
#seriesname = input('Please enter series name: ')
ROOTDIR = os.getcwd()
directories = {}
if os.name == 'nt':
LOGDIR = f'{ROOTDIR}\\log'
directories['SERIESDIR'] = f'{ROOTDIR}\\cache\\series\\'
directories['EPISODEDIR'] =f'{ROOTDIR}\\cache\\episodes\\'
directories['CASTDIR'] = f'{ROOTDIR}\\cache\\cast\\'
directories['CREWDIR'] = f'{ROOTDIR}\\cache\\crew\\'
else:
LOGDIR = f'{ROOTDIR}/log'
directories['SERIESDIR'] = f'{ROOTDIR}/cache/series/'
directories['EPISODEDIR'] =f'{ROOTDIR}/cache/episodes/'
directories['CASTDIR'] = f'{ROOTDIR}/cache/cast/'
directories['CREWDIR'] = f'{ROOTDIR}/cache/crew/'
lprint = logs.Logger.lprint(LOGDIR, False)
lprint.startlog()
import settings.config
config_options = settings.config.Config(ROOTDIR)
options = config_options.config_options
mongodb = dbmongo(options)
jload = Jsonload()
viewprocess = Process_View()
#serieslist = mongodb.mgseries.find()
#for series in serieslist:
# print(series)
series = mongodb.mgseries.find_one({"id": int(seriesid)})
episodecursor = mongodb.mgepisodes.find({"seriesid": int(seriesid)})
episodes = []
for episode in episodecursor:
episodes.append(episode)
viewprocess.process_seriesdata(series)
viewprocess.print_episodedata(episodes)
exit()