Added logging.

This commit is contained in:
Matthew Welch 2019-08-23 21:34:42 -07:00
parent 0041ad4b3b
commit f478c29f34
15 changed files with 231 additions and 81 deletions

View File

@ -1,4 +1,4 @@
from flask import Blueprint, render_template, request, make_response
from flask import Blueprint, render_template, request, make_response, current_app
from flask_login import login_required
from urllib import parse
@ -25,7 +25,8 @@ def index():
end = len(publishers) if len(publishers) < max_items*page else max_items*page
return render_template("comics/index.html", title="Comics", publishers=publishers, page=page, max_items=max_items, start=start, end=end, item_count=len(publishers))
except Exception as e:
print(inspect.stack()[0][3], type(e), e)
current_app.logger.info(inspect.stack()[0][3] + " " + str(type(e)) + " " + str(e))
# print(inspect.stack()[0][3], type(e), e)
return str(type(e)) + " " + str(e)
@ -68,7 +69,8 @@ def search():
publisher_start=publisher_start, series_start=series_start, comics_start=comics_start,
publisher_end=publisher_end, series_end=series_end, comics_end=comics_end)
except Exception as e:
print(inspect.stack()[0][3], type(e), e)
current_app.logger.info(inspect.stack()[0][3] + " " + str(type(e)) + " " + str(e))
# print(inspect.stack()[0][3], type(e), e)
return str(type(e))+" "+str(e)
@ -99,7 +101,8 @@ def comics_publisher(publisher):
return render_template("comics/publisherSeriesView.html", title="Comics", publisher_series=publisher_series,
start=start, end=end, page=page, max_items=max_items, item_count=len(publisher_series))
except Exception as e:
print(inspect.stack()[0][3], type(e), e)
current_app.logger.info(inspect.stack()[0][3] + " " + str(type(e)) + " " + str(e))
# print(inspect.stack()[0][3], type(e), e)
return str(type(e)) + " " + str(e)
@ -125,7 +128,8 @@ def comic_viewer(publisher, series, series_year, issue):
title = "Comics: "+meta["series"]+": #"+meta["issueText"]+" "+(meta["title"] or "")
return render_template("comics/comicView.html", title=title, on_mobile=on_mobile, prev_url=prev_url, next_url=next_url, comic=meta, page_number=page_number)
except Exception as e:
print(inspect.stack()[0][3], type(e), e)
current_app.logger.info(inspect.stack()[0][3] + " " + str(type(e)) + " " + str(e))
# print(inspect.stack()[0][3], type(e), e)
return str(type(e)) + " " + str(e)
@ -138,7 +142,8 @@ def comic_gallery(publisher, series, series_year, issue):
end = meta["pageCount"] if meta["pageCount"] < max_items*page else max_items*page
return render_template("comics/comicGallery.html", title="Comics", comic=meta, start=start, end=end, page=page, max_items=max_items, item_count=meta["pageCount"])
except Exception as e:
print(inspect.stack()[0][3], type(e), e)
current_app.logger.info(inspect.stack()[0][3] + " " + str(type(e)) + " " + str(e))
# print(inspect.stack()[0][3], type(e), e)
return str(type(e)) + " " + str(e)

View File

@ -1,5 +1,6 @@
from flask import Blueprint, render_template, request, make_response, send_file, send_from_directory
from flask import Blueprint, render_template, request, make_response, send_file, send_from_directory, current_app
from flask_login import login_required
import inspect
from scripts import database, func
@ -17,7 +18,8 @@ def index():
end = len(movies) if len(movies) < max_items*page else max_items*page
return render_template("movies/index.html", title="Movies", movies=movies, page=page, max_items=max_items, start=start, end=end, item_count=len(movies))
except Exception as e:
print(type(e), e)
current_app.logger.info(inspect.stack()[0][3] + " " + str(type(e)) + " " + str(e))
# print(type(e), e)
return str(type(e)) + " " + str(e)
@ -37,7 +39,8 @@ def search():
end = len(results) if len(results) < max_items*page else max_items*page
return render_template("movies/search.html", title="Movies", movies=results, page=page, max_items=max_items, start=start, end=end, item_count=len(results))
except Exception as e:
print(type(e), e)
current_app.logger.info(inspect.stack()[0][3] + " " + str(type(e)) + " " + str(e))
# print(type(e), e)
return str(type(e)) + " " + str(e)
@ -48,7 +51,8 @@ def movie_view(imdb_id):
movie_data = database.db_get_movie_by_imdb_id(imdb_id)
return render_template("movies/movieViewer.html", title="Movies: " + movie_data["title"], movie=movie_data)
except Exception as e:
print(type(e), e)
current_app.logger.info(inspect.stack()[0][3] + " " + str(type(e)) + " " + str(e))
# print(type(e), e)
return str(type(e)) + " " + str(e)
@ -59,7 +63,8 @@ def movie_view_extended(imdb_id):
movie_data = database.db_get_movie_by_imdb_id(imdb_id, extended=1)
return render_template("movies/movieViewer.html", title="Movies: " + movie_data["title"], movie=movie_data)
except Exception as e:
print(type(e), e)
current_app.logger.info(inspect.stack()[0][3] + " " + str(type(e)) + " " + str(e))
# print(type(e), e)
return str(type(e)) + " " + str(e)
@ -70,7 +75,8 @@ def movie_view_directors_cut(imdb_id):
movie_data = database.db_get_movie_by_imdb_id(imdb_id, directors_cut=1)
return render_template("movies/movieViewer.html", title="Movies: " + movie_data["title"], movie=movie_data)
except Exception as e:
print(type(e), e)
current_app.logger.info(inspect.stack()[0][3] + " " + str(type(e)) + " " + str(e))
# print(type(e), e)
return str(type(e)) + " " + str(e)

View File

@ -1,5 +1,5 @@
from flask import Flask
from flask import render_template, request, g, redirect, url_for, flash
from flask import render_template, request, g, redirect, url_for, flash, current_app
from flask_login import LoginManager, current_user, login_user, logout_user, login_required
from flask_log import Logging
@ -33,6 +33,7 @@ app.register_blueprint(movies.Movies)
app.register_blueprint(tv.TV)
app.config["SECRET_KEY"] = "***REMOVED***"
app.config["FLASK_LOG_LEVEL"] = "DEBUG"
app.config["FLASK_LOG_FACILITY"] = "daemon"
flask_log = Logging(app)
login_manager = LoginManager(app)
@ -73,6 +74,7 @@ def get_tv_shows():
with app.app_context():
current_app.logger.info("server start")
database.initialize_db()
thread = threading.Thread(target=get_comics, args=())
thread.daemon = True
@ -96,14 +98,16 @@ def update_comic_db(sender, **kw):
try:
database.add_comics(kw["meta"], kw["thumbnails"])
except Exception as e:
print(inspect.stack()[0][3], type(e), e)
current_app.logger.info(inspect.stack()[0][3] + " " + str(type(e)) + " " + str(e))
# print(inspect.stack()[0][3], type(e), e)
def update_movie_db(sender, **kw):
try:
database.add_movies(kw["movies"])
except Exception as e:
print(inspect.stack()[0][3], type(e), e)
current_app.logger.info(inspect.stack()[0][3] + " " + str(type(e)) + " " + str(e))
# print(inspect.stack()[0][3], type(e), e)
def update_tv_show_db(sender, **kw):
@ -112,14 +116,16 @@ def update_tv_show_db(sender, **kw):
if kw["tv_episodes"]:
database.add_tv_episodes(kw["tv_episodes"])
except Exception as e:
print(inspect.stack()[0][3], type(e), e)
current_app.logger.info(inspect.stack()[0][3] + " " + str(type(e)) + " " + str(e))
# print(inspect.stack()[0][3], type(e), e)
def update_tv_episodes_db(sender, **kw):
try:
database.add_tv_episodes(kw["tv_episodes"])
except Exception as e:
print(inspect.stack()[0][3], type(e), e)
current_app.logger.info(inspect.stack()[0][3] + " " + str(type(e)) + " " + str(e))
# print(inspect.stack()[0][3], type(e), e)
func.comic_loaded.connect(update_comic_db)
@ -150,6 +156,7 @@ def login():
return redirect(next_page)
return render_template("login.html", title="login")
except Exception as e:
current_app.logger.info(inspect.stack()[0][3] + " " + str(type(e)) + " " + str(e))
return str(e)
@ -159,6 +166,7 @@ def logout():
logout_user()
return redirect(url_for("login"))
except Exception as e:
current_app.logger.info(inspect.stack()[0][3] + " " + str(type(e)) + " " + str(e))
return str(e)
@ -173,6 +181,7 @@ def home():
try:
return render_template("home.html", title="Hello World", current_user=current_user)
except Exception as e:
current_app.logger.info(inspect.stack()[0][3] + " " + str(type(e)) + " " + str(e))
return str(e)

View File

@ -1,17 +1,17 @@
from flask import Flask
from flask import g
from flask import g, current_app
from flask_login import UserMixin
from werkzeug.security import generate_password_hash, check_password_hash
from werkzeug.security import check_password_hash
from io import BytesIO
from wand.image import Image
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import create_engine
from sqlalchemy import orm
from sqlalchemy import Column, Integer, String, BLOB, Boolean
from sqlalchemy import Column, Integer, String, BLOB, Boolean, Table, MetaData, DateTime
from sqlalchemy.orm import sessionmaker
import sqlite3
import os, time, inspect
import os
import inspect
from comicapi.issuestring import IssueString
@ -28,7 +28,7 @@ IMDB_DATABASE = RPI_IMDB_DATABASE if os.path.exists(RPI_IMDB_DATABASE) else MC_I
engine = create_engine("sqlite:///"+DATABASE+"?check_same_thread=False")
Session =sessionmaker(bind=engine)
Session = sessionmaker(bind=engine)
session = Session()
Base = declarative_base()
@ -83,7 +83,8 @@ class Comic(Base):
setattr(self, column.name, data[i])
i += 1
except Exception as e:
print(inspect.stack()[0][3], type(e), e)
current_app.logger.info(inspect.stack()[0][3] + " " + str(type(e)) +" "+ str(e))
#print(inspect.stack()[0][3], type(e), e)
def __repr__(self):
return "<Comic: {series} {issue}>".format(series=self.series, issue=self.issueText)
@ -107,7 +108,8 @@ class ComicThumbnail(Base):
setattr(self, column.name, data[i])
i += 1
except Exception as e:
print(inspect.stack()[0][3], type(e), e)
current_app.logger.info(inspect.stack()[0][3] + " " + str(type(e)) +" "+ str(e))
#print(inspect.stack()[0][3], type(e), e)
class Movie(Base):
@ -132,7 +134,8 @@ class Movie(Base):
setattr(self, column.name, data[i])
i += 1
except Exception as e:
print(inspect.stack()[0][3], type(e), e)
current_app.logger.info(inspect.stack()[0][3] + " " + str(type(e)) +" "+ str(e))
#print(inspect.stack()[0][3], type(e), e)
class TvShow(Base):
@ -153,7 +156,8 @@ class TvShow(Base):
setattr(self, column.name, data[i])
i += 1
except Exception as e:
print(inspect.stack()[0][3], type(e), e)
current_app.logger.info(inspect.stack()[0][3] + " " + str(type(e)) + " " + str(e))
# print(inspect.stack()[0][3], type(e), e)
class TvEpisode(Base):
@ -176,7 +180,8 @@ class TvEpisode(Base):
setattr(self, column.name, data[i])
i += 1
except Exception as e:
print(inspect.stack()[0][3], type(e), e)
current_app.logger.info(inspect.stack()[0][3] + " " + str(type(e)) + " " + str(e))
# print(inspect.stack()[0][3], type(e), e)
class User(Base, UserMixin):
@ -191,10 +196,80 @@ class User(Base, UserMixin):
for column in self.__table__.columns:
setattr(self, column.name, data[i])
i += 1
self.init_user_data()
@orm.reconstructor
def get_user_data(self):
pass
def init_user_data(self):
meta = MetaData()
self.comics = Table(
"comics", meta,
Column("comic_id", Integer, primary_key=True),
Column("viewed", Boolean, default=False),
Column("date", DateTime)
)
self.movies = Table(
"movies", meta,
Column("imdb_id", Integer, primary_key=True),
Column("viewed", Boolean, default=False),
Column("date", DateTime)
)
self.tv_episodes = Table(
"tv_episodes", meta,
Column("imdb_id", Integer, primary_key=True),
Column("viewed", Boolean, default=False),
Column("date", DateTime)
)
self.tv_shows = Table(
"tv_shows", meta,
Column("imdb_id", Integer, primary_key=True),
Column("viewed", Boolean, default=False),
Column("date", DateTime)
)
user_engine = create_engine("sqlite:///" + "user_" + self.username + ".db" + "?check_same_thread=False")
self.conn = engine.connect()
meta.create_all(user_engine)
def set_comic_viewed(self, comic_id, val=True):
self.conn.execute(self.comics.insert().values(comic_id=comic_id, viewed=val))
def is_comic_viewed(self, comic_id):
q = self.comics.select().where(self.comics.c.comic_id == comic_id)
result = self.conn.execute(q).fetchone()
if result:
return result["viewed"]
def set_movie_viewed(self, imdb_id, val=True):
self.conn.execute(self.movies.insert().values(comic_id=imdb_id, viewed=val))
def is_movie_viewed(self, imdb_id):
q = self.movies.select().where(self.movies.c.imdb_id == imdb_id)
result = self.conn.execute(q).fetchone()
if result:
return result["viewed"]
def set_tv_episode_viewed(self, imdb_id, val=True):
self.conn.execute(self.tv_episodes.insert().values(comic_id=imdb_id, viewed=val))
def is_tv_episode_viewed(self, imdb_id):
q = self.tv_episodes.select().where(self.tv_episodes.c.imdb_id == imdb_id)
result = self.conn.execute(q).fetchone()
if result:
return result["viewed"]
def set_tv_show_viewed(self, imdb_id, val=True):
self.conn.execute(self.tv_shows.insert().values(comic_id=imdb_id, viewed=val))
def is_tv_show_viewed(self, imdb_id):
q = self.tv_shows.select().where(self.tv_shows.c.imdb_id == imdb_id)
result = self.conn.execute(q).fetchone()
if result:
return result["viewed"]
def get_id(self):
return self.username
@ -336,7 +411,8 @@ def add_tv_shows(tv_show_data):
session.add(tv_show)
session.commit()
except Exception as e:
print(inspect.stack()[0][3], type(e), e)
current_app.logger.info(inspect.stack()[0][3] + " " + str(type(e)) + " " + str(e))
# print(inspect.stack()[0][3], type(e), e)
def add_tv_episodes(episodes):
@ -347,7 +423,8 @@ def add_tv_episodes(episodes):
session.add(episode)
session.commit()
except Exception as e:
print(inspect.stack()[0][3], type(e), e)
current_app.logger.info(inspect.stack()[0][3] + " " + str(type(e)) + " " + str(e))
# print(inspect.stack()[0][3], type(e), e)
def add_comics(meta, thumbnails):
@ -374,6 +451,7 @@ def add_comics(meta, thumbnails):
thumbnail = ComicThumbnail([comic_id, index, images[index][0], images[index][1]])
session.add(thumbnail)
session.commit()
current_app.logger.info("{} comic{} added".format(len(meta), "s" if len(meta)>1 else ""))
print("#"*18)
print("# {} comic{} added #".format(len(meta), "s" if len(meta)>1 else ""))
print("#"*18)
@ -424,8 +502,10 @@ def comic_path_in_db(path):
if result:
return True
except Exception as e:
print(path)
print(inspect.stack()[0][3], type(e), e)
# print(path)
current_app.logger.info(path)
current_app.logger.info(inspect.stack()[0][3] + " " + str(type(e)) + " " + str(e))
# print(inspect.stack()[0][3], type(e), e)
return False
@ -435,8 +515,10 @@ def movie_path_in_db(path):
if result:
return True
except Exception as e:
print(path)
print(inspect.stack()[0][3], type(e), e)
# print(path)
current_app.logger.info(path)
current_app.logger.info(inspect.stack()[0][3] + " " + str(type(e)) + " " + str(e))
# print(inspect.stack()[0][3], type(e), e)
return False
@ -446,8 +528,10 @@ def tv_show_path_in_db(path):
if result:
return True
except Exception as e:
print(path)
print(inspect.stack()[0][3], type(e), e)
# print(path)
current_app.logger.info(path)
current_app.logger.info(inspect.stack()[0][3] + " " + str(type(e)) + " " + str(e))
# print(inspect.stack()[0][3], type(e), e)
return False
@ -457,8 +541,10 @@ def tv_episode_path_in_db(path):
if result:
return True
except Exception as e:
print(path)
print(inspect.stack()[0][3], type(e), e)
# print(path)
current_app.logger.info(path)
current_app.logger.info(inspect.stack()[0][3] + " " + str(type(e)) + " " + str(e))
# print(inspect.stack()[0][3], type(e), e)
return False
@ -517,7 +603,7 @@ def tmdb_get_tv_episode_by_imdb_id(imdb_id):
def db_get_all_movies():
movies = session.query(Movie).all()
movies = session.query(Movie).order_by(Movie.title, Movie.year).all()
return movies

View File

@ -1,9 +1,11 @@
from flask import current_app
from comicapi import comicarchive
from blinker import Namespace
from io import BytesIO
from wand.image import Image
import os, sys, re
import inspect
from scripts import database
@ -51,13 +53,15 @@ def get_comics():
try:
test_path = path.encode("utf8")
except Exception as e:
print("encoding failed on:", path)
current_app.logger.info("encoding failed on: "+path)
# print("encoding failed on:", path)
continue
archive = open_comic(path)
md = archive.readCIX()
if md.publisher in publishers_to_ignore:
continue
print(path)
current_app.logger.info(path)
# print(path)
meta.append((path, md))
thumbnails.append(get_comic_thumbnails(archive))
comics_added += 1
@ -68,9 +72,12 @@ def get_comics():
thumbnails.clear()
i = 0
comics_in_db += 1
print("total number of comics:", total_comics)
print("comics in database:", comics_in_db)
print("number of comics added:", comics_added)
current_app.logger.info("total number of comics: "+str(total_comics))
current_app.logger.info("comics in database: "+str(comics_in_db))
current_app.logger.info("number of comics added: "+str(comics_added))
# print("total number of comics:", total_comics)
# print("comics in database:", comics_in_db)
# print("number of comics added:", comics_added)
comic_loaded.send("anonymous", meta=meta, thumbnails=thumbnails)
@ -82,13 +89,15 @@ def get_comic(path):
try:
test_path = path.encode("utf8")
except Exception as e:
print("encoding failed on:", path)
current_app.logger.info("encoding failed on: "+path)
# print("encoding failed on:", path)
return
archive = open_comic(path)
md = archive.readCIX()
if md.publisher in publishers_to_ignore:
return
print(path)
current_app.logger.info(path)
# print(path)
meta.append((path, md))
thumbnails.append(get_comic_thumbnails(archive))
comic_loaded.send("anonymous", meta=meta, thumbnails=thumbnails)
@ -121,7 +130,8 @@ def open_comic(path):
def get_movies():
print("start load movies")
current_app.logger.info("start load movies")
# print("start load movies")
pattern = r"(.+) \((....)\)(\(extended\))?( Director's Cut)?(\.mkv)"
movies = []
total_movies = 0
@ -136,11 +146,14 @@ def get_movies():
try:
match = re.fullmatch(pattern, f)
if not match:
print(f, "did not match regex.")
current_app.logger.info(f+" did not match regex.")
# print(f, "did not match regex.")
continue
print("movie path:", path)
current_app.logger.info("movie path: "+path)
# print("movie path:", path)
title = match.group(1)
print("movie title:", title)
current_app.logger.info("movie title: "+title)
# print("movie title:", title)
year = int(match.group(2))
extended = False
directors_cut = False
@ -153,14 +166,16 @@ def get_movies():
else:
imdb_data = database.imdb_get_movie(title, year)
if not imdb_data:
print("could not get imdb data for:", title, year)
current_app.logger.info("could not get imdb data for: "+title+" "+str(year))
# print("could not get imdb data for:", title, year)
continue
imdb_id = imdb_data["tconst"]
length = imdb_data["runtimeMinutes"]
tmdb_data = database.tmdb_get_movie_by_imdb_id(imdb_id)
if not tmdb_data:
print("could not get tmdb data")
current_app.logger.info("could not get tmdb data")
# print("could not get tmdb data")
continue
tmdb_id = tmdb_data[0]
description = tmdb_data[1]
@ -173,13 +188,18 @@ def get_movies():
movie_loaded.send("anonymous", movies=movies.copy())
movies.clear()
except Exception as e:
print(e)
current_app.logger.info(inspect.stack()[0][3] + " " + str(type(e)) +" "+ str(e))
# print(e)
movies_in_db += 1
movie_loaded.send("anonymous", movies=movies)
print("finish load movies")
print("total movies:", total_movies)
print("movies in database:", movies_in_db)
print("movies added:", movies_added)
current_app.logger.info("finish load movies")
current_app.logger.info("total movies: "+str(total_movies))
current_app.logger.info("movies in database: "+str(movies_in_db))
current_app.logger.info("movies added: "+str(movies_added))
# print("finish load movies")
# print("total movies:", total_movies)
# print("movies in database:", movies_in_db)
# print("movies added:", movies_added)
def get_tv_shows():
@ -193,12 +213,14 @@ def get_tv_shows():
series_year = int(dir_match.group(2))
imdb_data = database.imdb_get_tv_show(series_name, series_year)
if not imdb_data:
print("could not get imdb data for:", series_name, series_year)
current_app.logger.info("could not get imdb data for:"+series_name+" "+str(series_year))
# print("could not get imdb data for:", series_name, series_year)
continue
imdb_id = imdb_data["tconst"]
tmdb_data = database.tmdb_get_tv_show_by_imdb_id(imdb_id)
if not tmdb_data:
print("could not get tmdb data for:", series_name, series_year)
current_app.logger.info("could not get tmdb data for:" + series_name + " " + str(series_year))
# print("could not get tmdb data for:", series_name, series_year)
with open("/var/lib/rpiWebApp/log.txt", "a") as f:
f.write("could not get tmdb data for: " + imdb_id + " " + series_name + " " + str(series_year)+"\n")
continue
@ -207,7 +229,8 @@ def get_tv_shows():
poster_path = tmdb_data[2]
tv_show_data = (imdb_id, tmdb_id, series_name, series_year, description, poster_path, path)
tv_show_loaded.send("anonymous", tv_show=tv_show_data)
print("finished load tv shows.")
current_app.logger.info("finished load tv shows.")
# print("finished load tv shows.")
def get_tv_episodes():
@ -225,12 +248,14 @@ def get_tv_episodes():
episode_name = video_match.group(3)
episode_imdb_data = database.imdb_get_tv_episode(tv_show.imdb_id, season, episode)
if not episode_imdb_data:
current_app.logger.info("could not get imdb data for: "+tv_show.title+" "+str(tv_show.year)+" "+str(season)+" "+str(episode))
print("could not get imdb data for:", tv_show.title, tv_show.year, season, episode)
continue
episode_imdb_id = episode_imdb_data["tconst"]
episode_tmdb_data = database.tmdb_get_tv_episode_by_imdb_id(episode_imdb_id)
if not episode_tmdb_data:
print("could not get tmdb data for:", tv_show.title, tv_show.year, season, episode)
current_app.logger.info("could not get tmdb data for: "+tv_show.title+" "+str(tv_show.year)+" "+str(season)+" "+str(episode))
# print("could not get tmdb data for:", tv_show.title, tv_show.year, season, episode)
with open("/var/lib/rpiWebApp/log.txt", "a") as f:
f.write("could not get tmdb data for: " + episode_imdb_id + " " + tv_show.title + " " + str(
tv_show.year) + " " + str(season) + " " + str(episode) + "\n")
@ -241,4 +266,5 @@ def get_tv_episodes():
episodes.append((episode_imdb_id, tv_show.imdb_id, episode_tmdb_id, episode_name, season, episode,
episode_description, episode_still_path, path))
tv_episodes_loaded.send("anonymous", tv_episodes=episodes)
print("finish load tv episodes.")
current_app.logger.info("finished load tv episodes.")
# print("finish load tv episodes.")

View File

@ -1,3 +1,4 @@
from flask import current_app
import requests
import logging
import inspect
@ -20,12 +21,15 @@ def get_movie_data(imdb_id):
r = requests.get(TMDB_FIND_URL+imdb_id, data=data)
info = dict(r.json())
if "status_code" in info.keys():
print("error getting tmdb data, status code:", info["status_code"])
current_app.logger.info("error getting tmdb data, status code: "+str(info["status_code"]))
# print("error getting tmdb data, status code:", info["status_code"])
return None
if info["movie_results"] == []:
print("no tmdb results for:", imdb_id)
current_app.logger.info("no tmdb results for: " + str(imdb_id))
# print("no tmdb results for:", imdb_id)
return None
print("tmdb movie title:", info["movie_results"][0]["title"])
current_app.logger.info("tmdb movie title: " + str(info["movie_results"][0]["title"]))
# print("tmdb movie title:", info["movie_results"][0]["title"])
movie_id = info["movie_results"][0]["id"]
overview = info["movie_results"][0]["overview"]
poster_path = info["movie_results"][0]["poster_path"]
@ -33,7 +37,8 @@ def get_movie_data(imdb_id):
return movie_id, overview, poster_path, backdrop_path
except Exception as e:
print(inspect.stack()[0][3], type(e), e)
current_app.logger.info(inspect.stack()[0][3] + " " + str(type(e)) + " " + str(e))
# print(inspect.stack()[0][3], type(e), e)
def get_tv_show_data(imdb_id):
@ -46,19 +51,23 @@ def get_tv_show_data(imdb_id):
r = requests.get(TMDB_FIND_URL+imdb_id, data=data)
info = dict(r.json())
if "status_code" in info.keys():
print("error getting tmdb data, status code:", info["status_code"])
current_app.logger.info("error getting tmdb data, status code: " + str(info["status_code"]))
# print("error getting tmdb data, status code:", info["status_code"])
return None
if info["tv_results"] == []:
print("no tmdb results for:", imdb_id)
current_app.logger.info("no tmdb results for: " + str(imdb_id))
# print("no tmdb results for:", imdb_id)
return None
print("tmdb tv show title:", info["tv_results"][0]["name"])
current_app.logger.info("tmdb tv show title: " + str(info["tv_results"][0]["name"]))
# print("tmdb tv show title:", info["tv_results"][0]["name"])
tv_show_id = info["tv_results"][0]["id"]
overview = info["tv_results"][0]["overview"]
poster_path = info["tv_results"][0]["poster_path"]
return tv_show_id, overview, poster_path
except Exception as e:
print(inspect.stack()[0][3], type(e), e)
current_app.logger.info(inspect.stack()[0][3] + " " + str(type(e)) + " " + str(e))
# print(inspect.stack()[0][3], type(e), e)
def get_tv_episode_data(imdb_id):
@ -71,12 +80,15 @@ def get_tv_episode_data(imdb_id):
r = requests.get(TMDB_FIND_URL+imdb_id, data=data)
info = dict(r.json())
if "status_code" in info.keys():
print("error getting tmdb data, status code:", info["status_code"])
current_app.logger.info("error getting tmdb data, status code: " + str(info["status_code"]))
# print("error getting tmdb data, status code:", info["status_code"])
return None
if info["tv_episode_results"] == []:
print("no tmdb results for:", imdb_id)
current_app.logger.info("no tmdb results for: " + str(imdb_id))
# print("no tmdb results for:", imdb_id)
return None
print("tmdb tv episode title:", info["tv_episode_results"][0]["name"])
current_app.logger.info("tmdb tv_episode title: " + str(info["tv_episode_results"][0]["name"]))
# print("tmdb tv episode title:", info["tv_episode_results"][0]["name"])
tv_episode_id = info["tv_episode_results"][0]["id"]
name = info["tv_episode_results"][0]["name"]
overview = info["tv_episode_results"][0]["overview"]
@ -84,4 +96,5 @@ def get_tv_episode_data(imdb_id):
return tv_episode_id, overview, still_path
except Exception as e:
print(inspect.stack()[0][3], type(e), e)
current_app.logger.info(inspect.stack()[0][3] + " " + str(type(e)) + " " + str(e))
# print(inspect.stack()[0][3], type(e), e)

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

BIN
static/images/Oni Press.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

BIN
static/images/Top Cow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View File

@ -1,4 +1,4 @@
from flask import Blueprint, render_template, request, make_response, send_file, send_from_directory
from flask import Blueprint, render_template, request, make_response, send_file, send_from_directory, current_app
from flask_login import login_required
from scripts import database, func
@ -18,7 +18,8 @@ def index():
end = len(tv_shows) if len(tv_shows) < max_items * page else max_items * page
return render_template("tv/index.html", title="Tv", tv_shows=tv_shows, page=page, max_items=max_items, start=start, end=end, item_count=len(tv_shows))
except Exception as e:
print(inspect.stack()[0][3], type(e), e)
current_app.logger.info(inspect.stack()[0][3] + " " + str(type(e)) + " " + str(e))
# print(inspect.stack()[0][3], type(e), e)
return str(type(e))+" "+str(e)
@ -39,7 +40,8 @@ def search():
return render_template("tv/search.html", title="Tv", tv_shows=tv_shows, page=page, max_items=max_items,
start=start, end=end, item_count=len(tv_shows))
except Exception as e:
print(inspect.stack()[0][3], type(e), e)
current_app.logger.info(inspect.stack()[0][3] + " " + str(type(e)) + " " + str(e))
# print(inspect.stack()[0][3], type(e), e)
return str(type(e))+" "+str(e)
@ -52,7 +54,8 @@ def episode_viewer(imdb_id):
episode = request.args.get("episode", type=int, default=episodes[0].episode)
return render_template("tv/episodeViewer.html", title="Tv", episodes=episodes, season_num=season, episode_num=episode)
except Exception as e:
print(inspect.stack()[0][3], type(e), e)
current_app.logger.info(inspect.stack()[0][3] + " " + str(type(e)) + " " + str(e))
# print(inspect.stack()[0][3], type(e), e)
return str(type(e)) + " " + str(e)

View File

@ -1,8 +1,10 @@
#!/usr/bin/python3
from flup.server.fcgi import WSGIServer
from app import app
from rpiWebApp import app
import logging
if __name__ == '__main__':
app.debug = True
logging.basicConfig(filename="app.log", format="%(levelname)s:%(name)s:%(message)s")
WSGIServer(app, bindAddress='/run/matt/rpiWebApp/fcgi.sock').run()