<s> import sqlite3 <EOL> import sys <EOL> import argparse <EOL> import os <EOL> import json <EOL> import operator <EOL> import shutil <EOL> import smtplib <EOL> import requests <EOL> import base64 <EOL> import cloudinary <EOL> import cloudinary . uploader <EOL> import cloudinary . api <EOL> import imghdr <EOL> import time <EOL> from base64 import b64encode <EOL> from collections import OrderedDict <EOL> from datetime import date , timedelta <EOL> from email . mime . multipart import MIMEMultipart <EOL> from email . mime . text import MIMEText <EOL> from email . MIMEImage import MIMEImage <EOL> from email . header import Header <EOL> from email . utils import formataddr <EOL> from xml . etree . ElementTree import XML <EOL> SCRIPT_VERSION = '<STR_LIT>' <EOL> def replaceConfigTokens ( ) : <EOL> if ( '<STR_LIT>' not in config . keys ( ) or config [ '<STR_LIT>' ] == "<STR_LIT>" ) : <EOL> config [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> if ( '<STR_LIT>' not in config . keys ( ) or config [ '<STR_LIT>' ] == "<STR_LIT>" ) : <EOL> config [ '<STR_LIT>' ] = False <EOL> if ( '<STR_LIT>' not in config . keys ( ) or config [ '<STR_LIT>' ] == "<STR_LIT>" ) : <EOL> config [ '<STR_LIT>' ] = False <EOL> if ( '<STR_LIT>' not in config . keys ( ) or config [ '<STR_LIT>' ] == "<STR_LIT>" ) : <EOL> config [ '<STR_LIT>' ] = False <EOL> if ( '<STR_LIT>' not in config . keys ( ) or config [ '<STR_LIT>' ] == "<STR_LIT>" ) : <EOL> config [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> if ( '<STR_LIT>' not in config . keys ( ) or config [ '<STR_LIT>' ] == "<STR_LIT>" ) : <EOL> config [ '<STR_LIT>' ] = False <EOL> if ( '<STR_LIT>' not in config . keys ( ) or config [ '<STR_LIT>' ] == "<STR_LIT>" ) : <EOL> config [ '<STR_LIT>' ] = False <EOL> if ( '<STR_LIT>' not in config . keys ( ) or config [ '<STR_LIT>' ] == "<STR_LIT>" ) : <EOL> config [ '<STR_LIT>' ] = False <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = True <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = True <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = False <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = { '<STR_LIT>' : { '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : False , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] } , '<STR_LIT>' : { '<STR_LIT>' : <NUM_LIT:2> , '<STR_LIT>' : True , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] } , '<STR_LIT>' : { '<STR_LIT>' : <NUM_LIT:3> , '<STR_LIT>' : True , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] } , '<STR_LIT>' : { '<STR_LIT>' : <NUM_LIT:4> , '<STR_LIT>' : False , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] } , '<STR_LIT>' : { '<STR_LIT>' : <NUM_LIT:5> , '<STR_LIT>' : False , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] } , '<STR_LIT>' : { '<STR_LIT>' : <NUM_LIT:6> , '<STR_LIT>' : False , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] } , '<STR_LIT>' : { '<STR_LIT>' : <NUM_LIT:7> , '<STR_LIT>' : True , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] } , '<STR_LIT>' : { '<STR_LIT>' : <NUM_LIT:8> , '<STR_LIT>' : False , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] } , '<STR_LIT>' : { '<STR_LIT>' : <NUM_LIT:9> , '<STR_LIT>' : True , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] } , '<STR_LIT>' : { '<STR_LIT>' : <NUM_LIT:10> , '<STR_LIT>' : False , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT:%>' , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] } , '<STR_LIT>' : { '<STR_LIT>' : <NUM_LIT:11> , '<STR_LIT>' : True , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] , '<STR_LIT>' : '<STR_LIT>' } , '<STR_LIT>' : { '<STR_LIT>' : <NUM_LIT:12> , '<STR_LIT>' : True , '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } } } <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = [ ] <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = [ ] <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = [ ] <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = [ ] <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = [ ] <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = [ ] <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = [ ] <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = [ ] <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = [ ] <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = [ ] <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = [ ] <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = [ ] <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = [ ] <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = [ ] <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = [ ] <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = False <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = False <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = True <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = False <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = True <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = [ ] <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = { '<STR_LIT>' : { '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : True , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] } , '<STR_LIT>' : { '<STR_LIT>' : <NUM_LIT:2> , '<STR_LIT>' : True , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] } , '<STR_LIT>' : { '<STR_LIT>' : <NUM_LIT:3> , '<STR_LIT>' : True , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] } , '<STR_LIT>' : { '<STR_LIT>' : <NUM_LIT:4> , '<STR_LIT>' : False , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] } , '<STR_LIT>' : { '<STR_LIT>' : <NUM_LIT:5> , '<STR_LIT>' : True , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] } , '<STR_LIT>' : { '<STR_LIT>' : <NUM_LIT:6> , '<STR_LIT>' : False , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] } , '<STR_LIT>' : { '<STR_LIT>' : <NUM_LIT:7> , '<STR_LIT>' : True , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] } , '<STR_LIT>' : { '<STR_LIT>' : <NUM_LIT:8> , '<STR_LIT>' : True , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] } , '<STR_LIT>' : { '<STR_LIT>' : <NUM_LIT:9> , '<STR_LIT>' : False , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] } , '<STR_LIT>' : { '<STR_LIT>' : <NUM_LIT:10> , '<STR_LIT>' : True , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT:%>' , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] } } <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = { '<STR_LIT>' : { '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : True , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] } , '<STR_LIT>' : { '<STR_LIT>' : <NUM_LIT:2> , '<STR_LIT>' : True , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] } , '<STR_LIT>' : { '<STR_LIT>' : <NUM_LIT:3> , '<STR_LIT>' : False , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] } , '<STR_LIT>' : { '<STR_LIT>' : <NUM_LIT:4> , '<STR_LIT>' : False , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] } , '<STR_LIT>' : { '<STR_LIT>' : <NUM_LIT:5> , '<STR_LIT>' : False , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] } , '<STR_LIT>' : { '<STR_LIT>' : <NUM_LIT:6> , '<STR_LIT>' : False , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] } , '<STR_LIT>' : { '<STR_LIT>' : <NUM_LIT:7> , '<STR_LIT>' : True , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] } , '<STR_LIT>' : { '<STR_LIT>' : <NUM_LIT:8> , '<STR_LIT>' : False , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] } , '<STR_LIT>' : { '<STR_LIT>' : <NUM_LIT:9> , '<STR_LIT>' : True , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] } , '<STR_LIT>' : { '<STR_LIT>' : <NUM_LIT:10> , '<STR_LIT>' : False , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT:%>' , '<STR_LIT>' : [ ] , '<STR_LIT>' : [ ] } } <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = False <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = True <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = True <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = True <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = True <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = <NUM_LIT:0> <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = False <EOL> if ( '<STR_LIT>' not in config ) : <EOL> config [ '<STR_LIT>' ] = False <EOL> if ( '<STR_LIT>' not in config and '<STR_LIT>' in config ) : <EOL> config [ '<STR_LIT>' ] = config [ '<STR_LIT>' ] <EOL> if ( '<STR_LIT>' not in config . keys ( ) or config [ '<STR_LIT>' ] == "<STR_LIT>" ) : <EOL> config [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> if ( '<STR_LIT>' not in config . keys ( ) or config [ '<STR_LIT>' ] == "<STR_LIT>" ) : <EOL> config [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> if ( '<STR_LIT>' not in config . keys ( ) or config [ '<STR_LIT>' ] == "<STR_LIT>" ) : <EOL> config [ '<STR_LIT>' ] = True <EOL> if ( '<STR_LIT>' not in config . keys ( ) or config [ '<STR_LIT>' ] == "<STR_LIT>" ) : <EOL> config [ '<STR_LIT>' ] = False <EOL> if ( '<STR_LIT>' not in config . keys ( ) or config [ '<STR_LIT>' ] == "<STR_LIT>" ) : <EOL> config [ '<STR_LIT>' ] = False <EOL> if ( '<STR_LIT>' not in config . keys ( ) or config [ '<STR_LIT>' ] == "<STR_LIT>" ) : <EOL> config [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> if ( '<STR_LIT>' not in config . keys ( ) or config [ '<STR_LIT>' ] == "<STR_LIT>" ) : <EOL> config [ '<STR_LIT>' ] = False <EOL> if ( '<STR_LIT>' not in config . keys ( ) or config [ '<STR_LIT>' ] == "<STR_LIT>" ) : <EOL> config [ '<STR_LIT>' ] = False <EOL> if ( '<STR_LIT>' not in config . keys ( ) or config [ '<STR_LIT>' ] == "<STR_LIT>" ) : <EOL> config [ '<STR_LIT>' ] = False <EOL> if ( '<STR_LIT>' not in config . keys ( ) or config [ '<STR_LIT>' ] == "<STR_LIT>" ) : <EOL> config [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> if ( '<STR_LIT>' not in config . keys ( ) or config [ '<STR_LIT>' ] == "<STR_LIT>" ) : <EOL> config [ '<STR_LIT>' ] = '<STR_LIT:index>' <EOL> if ( '<STR_LIT>' not in config . keys ( ) or config [ '<STR_LIT>' ] == "<STR_LIT>" ) : <EOL> config [ '<STR_LIT>' ] = False <EOL> if ( '<STR_LIT>' not in config . keys ( ) or config [ '<STR_LIT>' ] == "<STR_LIT>" ) : <EOL> config [ '<STR_LIT>' ] = False <EOL> if ( '<STR_LIT>' not in config . keys ( ) or config [ '<STR_LIT>' ] == "<STR_LIT>" ) : <EOL> config [ '<STR_LIT>' ] = False <EOL> if ( '<STR_LIT>' not in config . keys ( ) or config [ '<STR_LIT>' ] == "<STR_LIT>" ) : <EOL> config [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> if ( '<STR_LIT>' not in config . keys ( ) or config [ '<STR_LIT>' ] == "<STR_LIT>" ) : <EOL> config [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> if ( '<STR_LIT>' not in config . keys ( ) or config [ '<STR_LIT>' ] == "<STR_LIT>" ) : <EOL> config [ '<STR_LIT>' ] = '<STR_LIT:index>' <EOL> if ( '<STR_LIT>' not in config . keys ( ) or config [ '<STR_LIT>' ] == "<STR_LIT>" ) : <EOL> config [ '<STR_LIT>' ] = False <EOL> if ( '<STR_LIT>' not in config . keys ( ) or config [ '<STR_LIT>' ] == "<STR_LIT>" ) : <EOL> config [ '<STR_LIT>' ] = False <EOL> if ( '<STR_LIT>' not in config . keys ( ) or config [ '<STR_LIT>' ] == "<STR_LIT>" ) : <EOL> config [ '<STR_LIT>' ] = False <EOL> if ( config [ '<STR_LIT>' ] . rfind ( '<STR_LIT:/>' ) < len ( config [ '<STR_LIT>' ] ) - len ( '<STR_LIT:/>' ) ) : <EOL> config [ '<STR_LIT>' ] = config [ '<STR_LIT>' ] + '<STR_LIT:/>' <EOL> for value in config : <EOL> if ( isinstance ( config [ value ] , str ) ) : <EOL> config [ value ] = config [ value ] . replace ( '<STR_LIT>' , str ( ( date . today ( ) - timedelta ( days = config [ '<STR_LIT>' ] , hours = config [ '<STR_LIT>' ] , minutes = config [ '<STR_LIT>' ] ) ) . strftime ( config [ '<STR_LIT>' ] ) ) ) <EOL> config [ value ] = config [ value ] . replace ( '<STR_LIT>' , str ( date . today ( ) . strftime ( config [ '<STR_LIT>' ] ) ) ) <EOL> config [ value ] = config [ value ] . replace ( '<STR_LIT>' , config [ '<STR_LIT>' ] + config [ '<STR_LIT>' ] ) <EOL> config [ value ] = config [ value ] . replace ( '<STR_LIT>' , os . path . sep ) <EOL> if ( config [ '<STR_LIT>' ] . rfind ( os . path . sep ) < len ( config [ '<STR_LIT>' ] ) - len ( os . path . sep ) ) : <EOL> config [ '<STR_LIT>' ] = config [ '<STR_LIT>' ] + os . path . sep <EOL> if ( config [ '<STR_LIT>' ] . find ( '<STR_LIT>' ) >= <NUM_LIT:0> ) : <EOL> config [ '<STR_LIT>' ] = config [ '<STR_LIT>' ] [ <NUM_LIT:0> : config [ '<STR_LIT>' ] . find ( '<STR_LIT>' ) ] <EOL> if ( config [ '<STR_LIT>' ] . rfind ( os . path . sep ) < len ( config [ '<STR_LIT>' ] ) - len ( os . path . sep ) ) : <EOL> config [ '<STR_LIT>' ] = config [ '<STR_LIT>' ] + os . path . sep <EOL> if ( config [ '<STR_LIT>' ] != '<STR_LIT>' and config [ '<STR_LIT>' ] . rfind ( '<STR_LIT:/>' ) < len ( config [ '<STR_LIT>' ] ) - len ( '<STR_LIT:/>' ) ) : <EOL> config [ '<STR_LIT>' ] = config [ '<STR_LIT>' ] + '<STR_LIT:/>' <EOL> def convertToHumanReadable ( valuesToConvert ) : <EOL> convertedValues = { } <EOL> for value in valuesToConvert : <EOL> convertedValues [ value ] = valuesToConvert [ value ] <EOL> convertedValues [ value + '<STR_LIT>' ] = [ valuesToConvert [ value ] ] <EOL> if ( not valuesToConvert [ value ] ) : <EOL> continue <EOL> if ( value == '<STR_LIT>' ) : <EOL> if ( valuesToConvert [ '<STR_LIT>' ] ) : <EOL> convertedValues [ value ] = str ( valuesToConvert [ '<STR_LIT>' ] // <NUM_LIT:1000> // <NUM_LIT> ) <EOL> else : <EOL> convertedValues [ value ] = str ( valuesToConvert [ value ] // <NUM_LIT:1000> // <NUM_LIT> ) <EOL> elif ( value == '<STR_LIT>' ) : <EOL> convertedValues [ value ] = str ( int ( valuesToConvert [ value ] * <NUM_LIT:10> ) ) <EOL> elif ( value == '<STR_LIT>' or value == '<STR_LIT>' or value == '<STR_LIT>' ) : <EOL> convertedValues [ value + '<STR_LIT>' ] = valuesToConvert [ value ] . split ( '<STR_LIT:|>' ) <EOL> convertedValues [ value ] = valuesToConvert [ value ] . replace ( '<STR_LIT:|>' , '<STR_LIT:U+002CU+0020>' ) <EOL> return convertedValues <EOL> def getSharedUserEmails ( ) : <EOL> emails = [ ] <EOL> if ( config [ '<STR_LIT>' ] == '<STR_LIT>' or config [ '<STR_LIT>' ] == '<STR_LIT>' ) : <EOL> return emails <EOL> url = '<STR_LIT>' <EOL> base64string = '<STR_LIT>' + base64 . encodestring ( '<STR_LIT>' % ( config [ '<STR_LIT>' ] , config [ '<STR_LIT>' ] ) ) . replace ( '<STR_LIT:\n>' , '<STR_LIT>' ) <EOL> headers = { '<STR_LIT>' : base64string , '<STR_LIT>' : '<STR_LIT>' } <EOL> response = requests . post ( url , headers = headers ) <EOL> token = json . loads ( response . text ) [ '<STR_LIT:user>' ] [ '<STR_LIT>' ] ; <EOL> url = '<STR_LIT>' <EOL> headers = { '<STR_LIT>' : '<STR_LIT:application/json>' , '<STR_LIT>' : token } <EOL> response = requests . get ( url , headers = headers ) <EOL> parsed = XML ( response . text . encode ( '<STR_LIT:ascii>' , '<STR_LIT:ignore>' ) ) <EOL> for elem in parsed : <EOL> for name , value in sorted ( elem . attrib . items ( ) ) : <EOL> if ( name == '<STR_LIT:email>' ) : <EOL> emails . append ( value . lower ( ) ) <EOL> return emails <EOL> def deleteImages ( ) : <EOL> folder = config [ '<STR_LIT>' ] + config [ '<STR_LIT>' ] + os . path . sep + '<STR_LIT>' + os . path . sep <EOL> for file in os . listdir ( folder ) : <EOL> if ( file . endswith ( '<STR_LIT>' ) ) : <EOL> os . remove ( folder + file ) <EOL> def processImage ( imageHash , thumb , mediaType , seasonIndex , episodeIndex ) : <EOL> thumbObj = { } <EOL> imgLocation = '<STR_LIT>' <EOL> if ( not thumb or thumb == '<STR_LIT>' ) : <EOL> thumbObj [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> thumbObj [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> return thumbObj <EOL> if ( thumb . find ( '<STR_LIT>' ) >= <NUM_LIT:0> ) : <EOL> thumbObj [ '<STR_LIT>' ] = thumb <EOL> thumbObj [ '<STR_LIT>' ] = thumb <EOL> return thumbObj <EOL> else : <EOL> if ( thumb . find ( '<STR_LIT>' ) >= <NUM_LIT:0> ) : <EOL> thumb = thumb [ <NUM_LIT:8> : len ( thumb ) ] <EOL> imgName = thumb [ thumb . rindex ( '<STR_LIT:/>' ) + <NUM_LIT:1> : thumb . rindex ( '<STR_LIT:.>' ) ] + hash <EOL> imgLocation = config [ '<STR_LIT>' ] + '<STR_LIT>' + os . path . sep + '<STR_LIT>' + os . path . sep + '<STR_LIT:localhost>' + os . path . sep + '<STR_LIT>' + thumb <EOL> elif ( thumb . find ( '<STR_LIT>' ) >= <NUM_LIT:0> ) : <EOL> thumb = thumb [ <NUM_LIT:9> : len ( thumb ) ] <EOL> category = thumb [ <NUM_LIT:0> : thumb . index ( '<STR_LIT:/>' ) ] <EOL> imgName = thumb [ thumb . rindex ( '<STR_LIT:/>' ) + <NUM_LIT:1> : len ( thumb ) ] <EOL> if ( mediaType == '<STR_LIT>' ) : <EOL> type = "<STR_LIT>" <EOL> else : <EOL> type = "<STR_LIT>" <EOL> imgLocation = config [ '<STR_LIT>' ] + '<STR_LIT>' + os . path . sep + '<STR_LIT>' + os . path . sep + type + os . path . sep + imageHash [ <NUM_LIT:0> ] + os . path . sep + imageHash [ <NUM_LIT:1> : len ( imageHash ) ] + '<STR_LIT>' + os . path . sep + '<STR_LIT>' + os . path . sep + category + os . path . sep + imgName <EOL> else : <EOL> thumb = thumb [ <NUM_LIT:11> : len ( thumb ) ] <EOL> category = thumb [ <NUM_LIT:0> : thumb . index ( '<STR_LIT:/>' ) ] <EOL> imgName = thumb [ thumb . index ( '<STR_LIT:_>' ) + <NUM_LIT:1> : len ( thumb ) ] <EOL> if ( mediaType == '<STR_LIT>' ) : <EOL> indexer = thumb [ thumb . index ( '<STR_LIT:/>' ) + <NUM_LIT:1> : thumb . index ( '<STR_LIT:_>' ) ] <EOL> imgLocation = config [ '<STR_LIT>' ] + '<STR_LIT>' + os . path . sep + '<STR_LIT>' + os . path . sep + '<STR_LIT>' + os . path . sep + imageHash [ <NUM_LIT:0> ] + os . path . sep + imageHash [ <NUM_LIT:1> : len ( imageHash ) ] + '<STR_LIT>' + os . path . sep + '<STR_LIT>' + os . path . sep + indexer + os . path . sep + category + os . path . sep + imgName <EOL> elif ( mediaType == '<STR_LIT>' ) : <EOL> indexer = thumb [ thumb . index ( '<STR_LIT:/>' ) + <NUM_LIT:1> : thumb . index ( '<STR_LIT:_>' ) ] <EOL> imgLocation = config [ '<STR_LIT>' ] + '<STR_LIT>' + os . path . sep + '<STR_LIT>' + os . path . sep + '<STR_LIT>' + os . path . sep + imageHash [ <NUM_LIT:0> ] + os . path . sep + imageHash [ <NUM_LIT:1> : len ( imageHash ) ] + '<STR_LIT>' + os . path . sep + '<STR_LIT>' + os . path . sep + indexer + os . path . sep + category + os . path . sep + imgName <EOL> elif ( mediaType == '<STR_LIT>' ) : <EOL> indexer = thumb [ thumb . index ( '<STR_LIT>' ) + <NUM_LIT:8> : thumb . index ( '<STR_LIT:_>' ) ] <EOL> imgLocation = config [ '<STR_LIT>' ] + '<STR_LIT>' + os . path . sep + '<STR_LIT>' + os . path . sep + '<STR_LIT>' + os . path . sep + imageHash [ <NUM_LIT:0> ] + os . path . sep + imageHash [ <NUM_LIT:1> : len ( imageHash ) ] + '<STR_LIT>' + os . path . sep + '<STR_LIT>' + os . path . sep + indexer + os . path . sep + '<STR_LIT>' + os . path . sep + str ( seasonIndex ) + os . path . sep + '<STR_LIT>' + os . path . sep + imgName <EOL> elif ( mediaType == '<STR_LIT>' ) : <EOL> indexer = thumb [ thumb . index ( '<STR_LIT>' ) + <NUM_LIT:7> : thumb . index ( '<STR_LIT:_>' ) ] <EOL> imgLocation = config [ '<STR_LIT>' ] + '<STR_LIT>' + os . path . sep + '<STR_LIT>' + os . path . sep + '<STR_LIT>' + os . path . sep + imageHash [ <NUM_LIT:0> ] + os . path . sep + imageHash [ <NUM_LIT:1> : len ( imageHash ) ] + '<STR_LIT>' + os . path . sep + '<STR_LIT>' + os . path . sep + indexer + os . path . sep + '<STR_LIT>' + os . path . sep + str ( seasonIndex ) + os . path . sep + '<STR_LIT>' + os . path . sep + str ( episodeIndex ) + os . path . sep + '<STR_LIT>' + os . path . sep + imgName <EOL> elif ( mediaType == '<STR_LIT>' ) : <EOL> indexer = thumb [ thumb . index ( '<STR_LIT>' ) + <NUM_LIT:8> : thumb . index ( '<STR_LIT:_>' ) ] <EOL> imgLocation = config [ '<STR_LIT>' ] + '<STR_LIT>' + os . path . sep + '<STR_LIT>' + os . path . sep + '<STR_LIT>' + os . path . sep + imageHash [ <NUM_LIT:0> ] + os . path . sep + imageHash [ <NUM_LIT:1> : len ( imageHash ) ] + '<STR_LIT>' + os . path . sep + '<STR_LIT>' + os . path . sep + '<STR_LIT>' + os . path . sep + thumb <EOL> elif ( mediaType == '<STR_LIT>' ) : <EOL> indexer = thumb [ thumb . index ( '<STR_LIT>' ) + <NUM_LIT:8> : thumb . index ( '<STR_LIT:_>' ) ] <EOL> imgLocation = config [ '<STR_LIT>' ] + '<STR_LIT>' + os . path . sep + '<STR_LIT>' + os . path . sep + '<STR_LIT>' + os . path . sep + imageHash [ <NUM_LIT:0> ] + os . path . sep + imageHash [ <NUM_LIT:1> : len ( imageHash ) ] + '<STR_LIT>' + os . path . sep + '<STR_LIT>' + os . path . sep + '<STR_LIT>' + os . path . sep + thumb <EOL> imgName += '<STR_LIT:_>' + imageHash <EOL> webImgFullPath = config [ '<STR_LIT>' ] + config [ '<STR_LIT>' ] + '<STR_LIT>' + imgName + '<STR_LIT>' <EOL> img = config [ '<STR_LIT>' ] + config [ '<STR_LIT>' ] + os . path . sep + '<STR_LIT>' + os . path . sep + imgName + '<STR_LIT>' <EOL> cloudinaryURL = '<STR_LIT>' <EOL> if ( '<STR_LIT>' in config and config [ '<STR_LIT>' ] ) : <EOL> thumbObj [ '<STR_LIT>' ] = webImgFullPath <EOL> cloudinaryURL = uploadToCloudinary ( imgLocation ) <EOL> elif ( config [ '<STR_LIT>' ] and config [ '<STR_LIT>' ] ) : <EOL> thumbObj [ '<STR_LIT>' ] = webImgFullPath <EOL> elif ( os . path . isfile ( imgLocation ) ) : <EOL> imgNames [ '<STR_LIT>' + imgName ] = imgLocation <EOL> thumbObj [ '<STR_LIT>' ] = '<STR_LIT>' + imgName <EOL> else : <EOL> thumbObj [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> if ( cloudinaryURL != '<STR_LIT>' ) : <EOL> thumbObj [ '<STR_LIT>' ] = cloudinaryURL <EOL> thumbObj [ '<STR_LIT>' ] = cloudinaryURL <EOL> elif ( os . path . isfile ( imgLocation ) and config [ '<STR_LIT>' ] ) : <EOL> shutil . copy ( imgLocation , img ) <EOL> thumbObj [ '<STR_LIT>' ] = '<STR_LIT>' + imgName + '<STR_LIT>' <EOL> else : <EOL> thumbObj [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> return thumbObj <EOL> def uploadToImgur ( imgToUpload , nameOfUpload ) : <EOL> client_id = '<STR_LIT>' <EOL> headers = { "<STR_LIT>" : "<STR_LIT>" + client_id } <EOL> url = "<STR_LIT>" <EOL> if ( os . path . isfile ( imgToUpload ) ) : <EOL> response = requests . post ( <EOL> url , <EOL> headers = headers , <EOL> data = { <EOL> '<STR_LIT:image>' : b64encode ( open ( imgToUpload , '<STR_LIT:rb>' ) . read ( ) ) , <EOL> '<STR_LIT:type>' : '<STR_LIT>' , <EOL> '<STR_LIT:name>' : nameOfUpload + '<STR_LIT>' , <EOL> '<STR_LIT:title>' : nameOfUpload <EOL> } <EOL> ) <EOL> data = json . loads ( response . text ) [ '<STR_LIT:data>' ] ; <EOL> return data [ '<STR_LIT>' ] <EOL> else : <EOL> return '<STR_LIT>' <EOL> def uploadToCloudinary ( imgToUpload ) : <EOL> if ( os . path . isfile ( imgToUpload ) ) : <EOL> if ( os . path . islink ( imgToUpload ) ) : <EOL> imgToUpload = os . path . realpath ( imgToUpload ) <EOL> if ( imghdr . what ( imgToUpload ) ) : <EOL> response = cloudinary . uploader . upload ( imgToUpload ) <EOL> return response [ '<STR_LIT:url>' ] <EOL> else : <EOL> return '<STR_LIT>' <EOL> else : <EOL> return '<STR_LIT>' <EOL> def containsnonasciicharacters ( str ) : <EOL> return not all ( ord ( c ) < <NUM_LIT> for c in str ) <EOL> def addheader ( message , headername , headervalue ) : <EOL> if containsnonasciicharacters ( headervalue ) : <EOL> h = Header ( headervalue , '<STR_LIT:utf-8>' ) <EOL> message [ headername ] = h <EOL> else : <EOL> message [ headername ] = headervalue <EOL> return message <EOL> def sendMail ( email ) : <EOL> if email != '<STR_LIT>' and email [ <NUM_LIT:0> ] . upper ( ) in ( name . upper ( ) for name in config [ '<STR_LIT>' ] ) : <EOL> print email [ <NUM_LIT:0> ] + '<STR_LIT>' <EOL> return <NUM_LIT:0> ; <EOL> gmail_user = config [ '<STR_LIT>' ] <EOL> gmail_pwd = config [ '<STR_LIT>' ] <EOL> smtp_address = config [ '<STR_LIT>' ] <EOL> smtp_port = config [ '<STR_LIT>' ] <EOL> use_ssl = config [ '<STR_LIT>' ] <EOL> FROM = formataddr ( ( str ( Header ( config [ '<STR_LIT>' ] ) ) , config [ '<STR_LIT>' ] ) ) if ( '<STR_LIT>' in config ) else config [ '<STR_LIT>' ] <EOL> TO = email if ( email != '<STR_LIT>' ) else config [ '<STR_LIT>' ] <EOL> SUBJECT = config [ '<STR_LIT>' ] <EOL> msg = MIMEMultipart ( '<STR_LIT>' ) <EOL> msg = addheader ( msg , '<STR_LIT>' , SUBJECT ) <EOL> msg [ '<STR_LIT>' ] = FROM <EOL> text = config [ '<STR_LIT>' ] <EOL> if containsnonasciicharacters ( emailHTML ) : <EOL> htmltext = MIMEText ( emailHTML , '<STR_LIT:html>' , '<STR_LIT:utf-8>' ) <EOL> else : <EOL> htmltext = MIMEText ( emailHTML , '<STR_LIT:html>' ) <EOL> if ( containsnonasciicharacters ( text ) ) : <EOL> plaintext = MIMEText ( text , '<STR_LIT>' , '<STR_LIT:utf-8>' ) <EOL> else : <EOL> plaintext = MIMEText ( text , '<STR_LIT>' ) <EOL> for image in imgNames : <EOL> fp = open ( imgNames [ image ] , '<STR_LIT:rb>' ) <EOL> msgImage = MIMEImage ( fp . read ( ) , _subtype = "<STR_LIT>" ) <EOL> fp . close ( ) <EOL> msgImage . add_header ( '<STR_LIT>' , '<STR_LIT:<>' + image + '<STR_LIT:>>' ) <EOL> msg . attach ( msgImage ) <EOL> msg . attach ( plaintext ) <EOL> msg . attach ( htmltext ) <EOL> if ( not config [ '<STR_LIT>' ] ) : <EOL> msg [ '<STR_LIT>' ] = "<STR_LIT:U+002CU+0020>" . join ( TO ) <EOL> if ( not use_ssl ) : <EOL> server = smtplib . SMTP ( smtp_address , smtp_port ) <EOL> server . ehlo ( ) <EOL> server . starttls ( ) <EOL> server . login ( gmail_user , gmail_pwd ) <EOL> server . sendmail ( FROM , TO , msg . as_string ( ) ) <EOL> server . close ( ) <EOL> else : <EOL> server = smtplib . SMTP_SSL ( smtp_address , smtp_port ) <EOL> server . ehlo ( ) <EOL> server . login ( gmail_user , gmail_pwd ) <EOL> server . sendmail ( FROM , TO , msg . as_string ( ) ) <EOL> server . close ( ) <EOL> return <NUM_LIT:1> ; <EOL> def createEmailHTML ( ) : <EOL> emailText = """<STR_LIT>""" + config [ '<STR_LIT>' ] + """<STR_LIT>""" + config [ '<STR_LIT>' ] + """<STR_LIT>""" + config [ '<STR_LIT>' ] + """<STR_LIT>""" + config [ '<STR_LIT>' ] + """<STR_LIT>""" + config [ '<STR_LIT>' ] + """<STR_LIT>""" <EOL> emailText += emailNotice <EOL> if ( movieCount > <NUM_LIT:0> and config [ '<STR_LIT>' ] ) : <EOL> emailText += emailMovies + '<STR_LIT>' <EOL> if ( showCount > <NUM_LIT:0> and config [ '<STR_LIT>' ] ) : <EOL> emailText += emailTVShows + '<STR_LIT>' <EOL> if ( seasonCount > <NUM_LIT:0> and config [ '<STR_LIT>' ] ) : <EOL> emailText += emailTVSeasons + '<STR_LIT>' <EOL> if ( episodeCount > <NUM_LIT:0> and config [ '<STR_LIT>' ] ) : <EOL> emailText += emailTVEpisodes <EOL> if ( artistCount > <NUM_LIT:0> and config [ '<STR_LIT>' ] ) : <EOL> emailText += emailArtists + '<STR_LIT>' <EOL> if ( albumCount > <NUM_LIT:0> and config [ '<STR_LIT>' ] ) : <EOL> emailText += emailAlbums + '<STR_LIT>' <EOL> if ( songCount > <NUM_LIT:0> and config [ '<STR_LIT>' ] ) : <EOL> emailText += emailSongs <EOL> if ( not hasNewContent ) : <EOL> emailText += """<STR_LIT>""" + config [ '<STR_LIT>' ] + """<STR_LIT>""" <EOL> emailText += """<STR_LIT>""" <EOL> return emailText <EOL> def createWebHTML ( ) : <EOL> htmlText = """<STR_LIT>""" + config [ '<STR_LIT>' ] + """<STR_LIT>""" + config [ '<STR_LIT>' ] + """<STR_LIT>""" <EOL> if ( movieCount > <NUM_LIT:0> and config [ '<STR_LIT>' ] ) : <EOL> htmlText += """<STR_LIT>""" + config [ '<STR_LIT>' ] + """<STR_LIT>""" <EOL> if ( showCount > <NUM_LIT:0> and config [ '<STR_LIT>' ] ) : <EOL> htmlText += """<STR_LIT>""" + config [ '<STR_LIT>' ] + """<STR_LIT>""" <EOL> if ( seasonCount > <NUM_LIT:0> and config [ '<STR_LIT>' ] ) : <EOL> htmlText += """<STR_LIT>""" + config [ '<STR_LIT>' ] + """<STR_LIT>""" <EOL> if ( episodeCount > <NUM_LIT:0> and config [ '<STR_LIT>' ] ) : <EOL> htmlText += """<STR_LIT>""" + config [ '<STR_LIT>' ] + """<STR_LIT>""" <EOL> if ( artistCount > <NUM_LIT:0> and config [ '<STR_LIT>' ] ) : <EOL> htmlText += """<STR_LIT>""" + config [ '<STR_LIT>' ] + """<STR_LIT>""" <EOL> if ( albumCount > <NUM_LIT:0> and config [ '<STR_LIT>' ] ) : <EOL> htmlText += """<STR_LIT>""" + config [ '<STR_LIT>' ] + """<STR_LIT>""" <EOL> if ( songCount > <NUM_LIT:0> and config [ '<STR_LIT>' ] ) : <EOL> htmlText += """<STR_LIT>""" + config [ '<STR_LIT>' ] + """<STR_LIT>""" <EOL> htmlText += """<STR_LIT>""" + config [ '<STR_LIT>' ] + """<STR_LIT>""" + config [ '<STR_LIT>' ] + """<STR_LIT>""" <EOL> htmlText += htmlNotice <EOL> if ( movieCount > <NUM_LIT:0> and config [ '<STR_LIT>' ] ) : <EOL> htmlText += htmlMovies + '<STR_LIT>' <EOL> if ( showCount > <NUM_LIT:0> and config [ '<STR_LIT>' ] ) : <EOL> htmlText += htmlTVShows + '<STR_LIT>' <EOL> if ( seasonCount > <NUM_LIT:0> and config [ '<STR_LIT>' ] ) : <EOL> htmlText += htmlTVSeasons + '<STR_LIT>' <EOL> if ( episodeCount > <NUM_LIT:0> and config [ '<STR_LIT>' ] ) : <EOL> htmlText += htmlTVEpisodes <EOL> if ( artistCount > <NUM_LIT:0> and config [ '<STR_LIT>' ] ) : <EOL> htmlText += htmlArtists + '<STR_LIT>' <EOL> if ( albumCount > <NUM_LIT:0> and config [ '<STR_LIT>' ] ) : <EOL> htmlText += htmlAlbums + '<STR_LIT>' <EOL> if ( songCount > <NUM_LIT:0> and config [ '<STR_LIT>' ] ) : <EOL> htmlText += htmlSongs <EOL> if ( not hasNewContent ) : <EOL> htmlText += """<STR_LIT>""" + config [ '<STR_LIT>' ] + """<STR_LIT>""" <EOL> htmlText += """<STR_LIT>""" + config [ '<STR_LIT>' ] + """<STR_LIT>""" <EOL> return htmlText <EOL> parser = argparse . ArgumentParser ( description = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT:-c>' , '<STR_LIT>' , help = '<STR_LIT>' , default = os . path . dirname ( os . path . realpath ( sys . argv [ <NUM_LIT:0> ] ) ) + os . path . sep + '<STR_LIT>' , required = False ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , help = '<STR_LIT>' , action = '<STR_LIT:store_true>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , help = '<STR_LIT>' , action = '<STR_LIT:store_true>' ) <EOL> args = vars ( parser . parse_args ( ) ) <EOL> if ( '<STR_LIT:version>' in args and args [ '<STR_LIT:version>' ] ) : <EOL> print '<STR_LIT>' + SCRIPT_VERSION <EOL> sys . exit ( ) <EOL> testMode = False <EOL> if ( '<STR_LIT>' in args ) : <EOL> configFile = args [ '<STR_LIT>' ] <EOL> if ( '<STR_LIT:test>' in args ) : <EOL> testMode = args [ '<STR_LIT:test>' ] <EOL> if ( not os . path . isfile ( configFile ) ) : <EOL> print configFile + '<STR_LIT>' <EOL> sys . exit ( ) <EOL> config = { } <EOL> execfile ( configFile , config ) <EOL> replaceConfigTokens ( ) <EOL> if ( '<STR_LIT>' in args and args [ '<STR_LIT>' ] ) : <EOL> config [ '<STR_LIT>' ] = args [ '<STR_LIT>' ] <EOL> if ( '<STR_LIT>' in config and config [ '<STR_LIT>' ] ) : <EOL> cloudinary . config ( <EOL> cloud_name = config [ '<STR_LIT>' ] , <EOL> api_key = config [ '<STR_LIT>' ] , <EOL> api_secret = config [ '<STR_LIT>' ] <EOL> ) <EOL> plexWebLink = '<STR_LIT>' <EOL> if ( config [ '<STR_LIT>' ] ) : <EOL> DLNA_DB_FILE = config [ '<STR_LIT>' ] + '<STR_LIT>' + os . path . sep + '<STR_LIT>' + os . path . sep + '<STR_LIT>' + os . path . sep + '<STR_LIT>' <EOL> if ( os . path . isfile ( DLNA_DB_FILE ) ) : <EOL> con = sqlite3 . connect ( DLNA_DB_FILE ) <EOL> cur = con . cursor ( ) <EOL> cur . execute ( '<STR_LIT>' ) <EOL> for row in cur : <EOL> plexWebLink = '<STR_LIT>' + row [ <NUM_LIT:0> ] + '<STR_LIT>' <EOL> DATABASE_FILE = config [ '<STR_LIT>' ] + '<STR_LIT>' + os . path . sep + '<STR_LIT>' + os . path . sep + '<STR_LIT>' + os . path . sep + '<STR_LIT>' <EOL> if ( not os . path . isfile ( DATABASE_FILE ) ) : <EOL> print DATABASE_FILE + '<STR_LIT>' <EOL> sys . exit ( ) <EOL> con = sqlite3 . connect ( DATABASE_FILE ) <EOL> con . text_factory = str <EOL> with con : <EOL> libraryFilter = '<STR_LIT>' <EOL> if ( config [ '<STR_LIT>' ] ) : <EOL> cur = con . cursor ( ) <EOL> cur . execute ( '<STR_LIT>' ) <EOL> for row in cur : <EOL> if ( row [ <NUM_LIT:1> ] . lower ( ) in ( library . lower ( ) for library in config [ '<STR_LIT>' ] ) ) : <EOL> if ( libraryFilter == '<STR_LIT>' ) : <EOL> libraryFilter = '<STR_LIT>' <EOL> libraryFilter += '<STR_LIT>' + str ( row [ <NUM_LIT:0> ] ) <EOL> else : <EOL> libraryFilter += '<STR_LIT>' + str ( row [ <NUM_LIT:0> ] ) <EOL> if ( libraryFilter != '<STR_LIT>' ) : <EOL> libraryFilter += '<STR_LIT>' <EOL> dateSearch = '<STR_LIT>' + str ( config [ '<STR_LIT>' ] ) + '<STR_LIT>' + str ( config [ '<STR_LIT>' ] ) + '<STR_LIT>' + str ( config [ '<STR_LIT>' ] ) + '<STR_LIT>' <EOL> cur = con . cursor ( ) <EOL> cur . execute ( "<STR_LIT>" + dateSearch + "<STR_LIT>" + libraryFilter + "<STR_LIT>" ) <EOL> response = { } ; <EOL> for row in cur : <EOL> response [ row [ <NUM_LIT:0> ] ] = { '<STR_LIT:id>' : row [ <NUM_LIT:0> ] , '<STR_LIT>' : row [ <NUM_LIT:1> ] , '<STR_LIT>' : row [ <NUM_LIT:2> ] , '<STR_LIT:title>' : row [ <NUM_LIT:3> ] , '<STR_LIT>' : row [ <NUM_LIT:4> ] , '<STR_LIT>' : row [ <NUM_LIT:5> ] , '<STR_LIT>' : row [ <NUM_LIT:6> ] , '<STR_LIT>' : row [ <NUM_LIT:7> ] , '<STR_LIT>' : row [ <NUM_LIT:8> ] , '<STR_LIT>' : row [ <NUM_LIT:9> ] , '<STR_LIT>' : row [ <NUM_LIT:10> ] , '<STR_LIT>' : row [ <NUM_LIT:11> ] , '<STR_LIT>' : row [ <NUM_LIT:12> ] , '<STR_LIT>' : row [ <NUM_LIT> ] , '<STR_LIT>' : row [ <NUM_LIT> ] , '<STR_LIT>' : row [ <NUM_LIT:15> ] , '<STR_LIT>' : row [ <NUM_LIT:16> ] , '<STR_LIT:index>' : row [ <NUM_LIT> ] , '<STR_LIT>' : row [ <NUM_LIT> ] , '<STR_LIT>' : row [ <NUM_LIT> ] , '<STR_LIT>' : row [ <NUM_LIT:20> ] } <EOL> emailNotice = '<STR_LIT>' <EOL> htmlNotice = '<STR_LIT>' <EOL> if ( config [ '<STR_LIT>' ] ) : <EOL> emailNotice = """<STR_LIT>""" + config [ '<STR_LIT>' ] + """<STR_LIT>""" <EOL> htmlNotice = """<STR_LIT>""" + config [ '<STR_LIT>' ] + """<STR_LIT>""" <EOL> emailMovies = """<STR_LIT>""" + config [ '<STR_LIT>' ] + """<STR_LIT>""" <EOL> htmlMovies = """<STR_LIT>""" + config [ '<STR_LIT>' ] + """<STR_LIT>""" <EOL> emailTVShows = """<STR_LIT>""" + config [ '<STR_LIT>' ] + """<STR_LIT>""" <EOL> htmlTVShows = """<STR_LIT>""" + config [ '<STR_LIT>' ] + """<STR_LIT>""" <EOL> emailTVSeasons = """<STR_LIT>""" + config [ '<STR_LIT>' ] + """<STR_LIT>""" <EOL> htmlTVSeasons = """<STR_LIT>""" + config [ '<STR_LIT>' ] + """<STR_LIT>""" <EOL> emailTVEpisodes = """<STR_LIT>""" + config [ '<STR_LIT>' ] + """<STR_LIT>""" <EOL> htmlTVEpisodes = """<STR_LIT>""" + config [ '<STR_LIT>' ] + """<STR_LIT>""" <EOL> emailArtists = """<STR_LIT>""" + config [ '<STR_LIT>' ] + """<STR_LIT>""" <EOL> htmlArtists = """<STR_LIT>""" + config [ '<STR_LIT>' ] + """<STR_LIT>""" <EOL> emailAlbums = """<STR_LIT>""" + config [ '<STR_LIT>' ] + """<STR_LIT>""" <EOL> htmlAlbums = """<STR_LIT>""" + config [ '<STR_LIT>' ] + """<STR_LIT>""" <EOL> emailSongs = """<STR_LIT>""" + config [ '<STR_LIT>' ] + """<STR_LIT>""" <EOL> htmlSongs = """<STR_LIT>""" + config [ '<STR_LIT>' ] + """<STR_LIT>""" <EOL> movies = { } <EOL> tvShows = { } <EOL> tvSeasons = { } <EOL> tvEpisodes = { } <EOL> artists = { } <EOL> albums = { } <EOL> songs = { } <EOL> imgNames = { } <EOL> movieCount = <NUM_LIT:0> <EOL> showCount = <NUM_LIT:0> <EOL> seasonCount = <NUM_LIT:0> <EOL> episodeCount = <NUM_LIT:0> <EOL> artistCount = <NUM_LIT:0> <EOL> albumCount = <NUM_LIT:0> <EOL> songCount = <NUM_LIT:0> <EOL> if ( config [ '<STR_LIT>' ] and '<STR_LIT>' in config and config [ '<STR_LIT>' ] ) : <EOL> deleteImages ( ) <EOL> for item in response : <EOL> if ( response [ item ] [ '<STR_LIT>' ] == <NUM_LIT:1> ) : <EOL> movies [ response [ item ] [ '<STR_LIT:id>' ] ] = response [ item ] <EOL> if ( response [ item ] [ '<STR_LIT>' ] == <NUM_LIT:2> ) : <EOL> tvShows [ response [ item ] [ '<STR_LIT:id>' ] ] = response [ item ] <EOL> if ( response [ item ] [ '<STR_LIT>' ] == <NUM_LIT:3> ) : <EOL> tvSeasons [ response [ item ] [ '<STR_LIT:id>' ] ] = response [ item ] <EOL> if ( response [ item ] [ '<STR_LIT>' ] == <NUM_LIT:4> ) : <EOL> tvEpisodes [ response [ item ] [ '<STR_LIT:id>' ] ] = response [ item ] <EOL> if ( response [ item ] [ '<STR_LIT>' ] == <NUM_LIT:8> ) : <EOL> artists [ response [ item ] [ '<STR_LIT:id>' ] ] = response [ item ] <EOL> if ( response [ item ] [ '<STR_LIT>' ] == <NUM_LIT:9> ) : <EOL> albums [ response [ item ] [ '<STR_LIT:id>' ] ] = response [ item ] <EOL> if ( response [ item ] [ '<STR_LIT>' ] == <NUM_LIT:10> ) : <EOL> songs [ response [ item ] [ '<STR_LIT:id>' ] ] = response [ item ] <EOL> if ( '<STR_LIT>' in config and config [ '<STR_LIT>' ] != '<STR_LIT>' ) : <EOL> movies = OrderedDict ( sorted ( movies . iteritems ( ) , key = lambda t : t [ <NUM_LIT:1> ] [ config [ '<STR_LIT>' ] ] , reverse = config [ '<STR_LIT>' ] ) ) <EOL> if ( '<STR_LIT>' in config and config [ '<STR_LIT>' ] != '<STR_LIT>' ) : <EOL> movies = OrderedDict ( sorted ( movies . iteritems ( ) , key = lambda t : t [ <NUM_LIT:1> ] [ config [ '<STR_LIT>' ] ] , reverse = config [ '<STR_LIT>' ] ) ) <EOL> if ( '<STR_LIT>' in config and config [ '<STR_LIT>' ] != '<STR_LIT>' ) : <EOL> movies = OrderedDict ( sorted ( movies . iteritems ( ) , key = lambda t : t [ <NUM_LIT:1> ] [ config [ '<STR_LIT>' ] ] , reverse = config [ '<STR_LIT>' ] ) ) <EOL> for movie in movies : <EOL> movies [ movie ] = convertToHumanReadable ( movies [ movie ] ) <EOL> title = '<STR_LIT>' <EOL> if ( '<STR_LIT>' in movies [ movie ] and movies [ movie ] [ '<STR_LIT>' ] != '<STR_LIT>' ) : <EOL> title += movies [ movie ] [ '<STR_LIT>' ] + '<STR_LIT>' <EOL> title += movies [ movie ] [ '<STR_LIT:title>' ] <EOL> hash = str ( movies [ movie ] [ '<STR_LIT>' ] ) <EOL> imageInfo = { } <EOL> imageInfo [ '<STR_LIT>' ] = movies [ movie ] [ '<STR_LIT>' ] <EOL> imageInfo = processImage ( hash , imageInfo [ '<STR_LIT>' ] , '<STR_LIT>' , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> skipItem = False <EOL> emailText = '<STR_LIT>' <EOL> htmlText = '<STR_LIT>' <EOL> if ( config [ '<STR_LIT>' ] ) : <EOL> pwLink = plexWebLink + str ( movies [ movie ] [ '<STR_LIT:id>' ] ) <EOL> else : <EOL> pwLink = '<STR_LIT>' <EOL> emailText += '<STR_LIT>' <EOL> if ( config [ '<STR_LIT>' ] ) : <EOL> emailText += '<STR_LIT>' <EOL> emailText += '<STR_LIT>' + pwLink + '<STR_LIT>' + imageInfo [ '<STR_LIT>' ] . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> emailText += '<STR_LIT>' <EOL> emailText += '<STR_LIT>' + pwLink + '<STR_LIT>' + title . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> htmlText += '<STR_LIT>' <EOL> htmlText += '<STR_LIT>' + pwLink + '<STR_LIT>' + imageInfo [ '<STR_LIT>' ] . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> htmlText += '<STR_LIT>' + pwLink + '<STR_LIT>' + title . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> sections = config [ '<STR_LIT>' ] <EOL> for section in sorted ( sections . iteritems ( ) , key = lambda t : t [ <NUM_LIT:1> ] [ '<STR_LIT>' ] ) : <EOL> if ( movies [ movie ] [ section [ <NUM_LIT:0> ] ] in sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] or len ( set ( movies [ movie ] [ section [ <NUM_LIT:0> ] + '<STR_LIT>' ] ) . intersection ( sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] ) ) > <NUM_LIT:0> or ( sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] and movies [ movie ] [ section [ <NUM_LIT:0> ] ] not in sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] and len ( set ( movies [ movie ] [ section [ <NUM_LIT:0> ] + '<STR_LIT>' ] ) . intersection ( sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] ) ) == <NUM_LIT:0> ) ) : <EOL> skipItem = True <EOL> if ( sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] and movies [ movie ] [ section [ <NUM_LIT:0> ] ] and movies [ movie ] [ section [ <NUM_LIT:0> ] ] != '<STR_LIT>' ) : <EOL> displayText = str ( movies [ movie ] [ section [ <NUM_LIT:0> ] ] ) <EOL> if ( '<STR_LIT>' in sections [ section [ <NUM_LIT:0> ] ] and sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] != '<STR_LIT>' ) : <EOL> displayText = time . strftime ( sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] , time . strptime ( displayText , '<STR_LIT>' ) ) <EOL> emailText += '<STR_LIT>' + sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] . decode ( '<STR_LIT:utf-8>' ) + displayText . decode ( '<STR_LIT:utf-8>' ) + sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> htmlText += '<STR_LIT>' + sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] . decode ( '<STR_LIT:utf-8>' ) + displayText . decode ( '<STR_LIT:utf-8>' ) + sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> emailText += '<STR_LIT>' <EOL> htmlText += '<STR_LIT>' <EOL> titleFilter = [ ] <EOL> if ( movies [ movie ] [ '<STR_LIT:title>' ] in config [ '<STR_LIT>' ] or len ( set ( titleFilter ) . intersection ( config [ '<STR_LIT>' ] ) ) > <NUM_LIT:0> or ( config [ '<STR_LIT>' ] and movies [ movie ] [ '<STR_LIT:title>' ] not in config [ '<STR_LIT>' ] and len ( set ( titleFilter ) . intersection ( config [ '<STR_LIT>' ] ) ) == <NUM_LIT:0> ) ) : <EOL> skipItem = True <EOL> if ( not skipItem ) : <EOL> movieCount += <NUM_LIT:1> <EOL> emailMovies += emailText <EOL> htmlMovies += htmlText <EOL> if ( '<STR_LIT>' in config and config [ '<STR_LIT>' ] != '<STR_LIT>' ) : <EOL> tvShows = OrderedDict ( sorted ( tvShows . iteritems ( ) , key = lambda t : t [ <NUM_LIT:1> ] [ config [ '<STR_LIT>' ] ] , reverse = config [ '<STR_LIT>' ] ) ) <EOL> if ( '<STR_LIT>' in config and config [ '<STR_LIT>' ] != '<STR_LIT>' ) : <EOL> tvShows = OrderedDict ( sorted ( tvShows . iteritems ( ) , key = lambda t : t [ <NUM_LIT:1> ] [ config [ '<STR_LIT>' ] ] , reverse = config [ '<STR_LIT>' ] ) ) <EOL> if ( '<STR_LIT>' in config and config [ '<STR_LIT>' ] != '<STR_LIT>' ) : <EOL> tvShows = OrderedDict ( sorted ( tvShows . iteritems ( ) , key = lambda t : t [ <NUM_LIT:1> ] [ config [ '<STR_LIT>' ] ] , reverse = config [ '<STR_LIT>' ] ) ) <EOL> for show in tvShows : <EOL> tvShows [ show ] = convertToHumanReadable ( tvShows [ show ] ) <EOL> title = '<STR_LIT>' <EOL> if ( tvShows [ show ] [ '<STR_LIT>' ] != '<STR_LIT>' ) : <EOL> title += tvShows [ show ] [ '<STR_LIT>' ] + '<STR_LIT>' <EOL> title += tvShows [ show ] [ '<STR_LIT:title>' ] <EOL> hash = str ( tvShows [ show ] [ '<STR_LIT>' ] ) <EOL> imageInfo = { } <EOL> imageInfo [ '<STR_LIT>' ] = tvShows [ show ] [ '<STR_LIT>' ] <EOL> imageInfo = processImage ( hash , imageInfo [ '<STR_LIT>' ] , '<STR_LIT>' , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> skipItem = False <EOL> emailText = '<STR_LIT>' <EOL> htmlText = '<STR_LIT>' <EOL> if ( config [ '<STR_LIT>' ] ) : <EOL> pwLink = plexWebLink + str ( tvShows [ show ] [ '<STR_LIT:id>' ] ) <EOL> else : <EOL> pwLink = '<STR_LIT>' <EOL> emailText += '<STR_LIT>' <EOL> if ( config [ '<STR_LIT>' ] ) : <EOL> emailText += '<STR_LIT>' + pwLink + '<STR_LIT>' + imageInfo [ '<STR_LIT>' ] . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> emailText += '<STR_LIT>' + pwLink + '<STR_LIT>' + title . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> htmlText += '<STR_LIT>' <EOL> htmlText += '<STR_LIT>' + pwLink + '<STR_LIT>' + imageInfo [ '<STR_LIT>' ] . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> htmlText += '<STR_LIT>' + pwLink + '<STR_LIT>' + title . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> sections = config [ '<STR_LIT>' ] <EOL> for section in sorted ( sections . iteritems ( ) , key = lambda t : t [ <NUM_LIT:1> ] [ '<STR_LIT>' ] ) : <EOL> if ( tvShows [ show ] [ section [ <NUM_LIT:0> ] ] in sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] or len ( set ( tvShows [ show ] [ section [ <NUM_LIT:0> ] + '<STR_LIT>' ] ) . intersection ( sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] ) ) > <NUM_LIT:0> or ( sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] and tvShows [ show ] [ section [ <NUM_LIT:0> ] ] not in sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] and len ( set ( tvShows [ show ] [ section [ <NUM_LIT:0> ] + '<STR_LIT>' ] ) . intersection ( sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] ) ) == <NUM_LIT:0> ) ) : <EOL> skipItem = True <EOL> if ( sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] and tvShows [ show ] [ section [ <NUM_LIT:0> ] ] and tvShows [ show ] [ section [ <NUM_LIT:0> ] ] != '<STR_LIT>' ) : <EOL> displayText = str ( tvShows [ show ] [ section [ <NUM_LIT:0> ] ] ) <EOL> if ( '<STR_LIT>' in sections [ section [ <NUM_LIT:0> ] ] and sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] != '<STR_LIT>' ) : <EOL> displayText = time . strftime ( sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] , time . strptime ( displayText , '<STR_LIT>' ) ) <EOL> emailText += '<STR_LIT>' + sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] . decode ( '<STR_LIT:utf-8>' ) + displayText . decode ( '<STR_LIT:utf-8>' ) + sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> htmlText += '<STR_LIT>' + sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] . decode ( '<STR_LIT:utf-8>' ) + displayText . decode ( '<STR_LIT:utf-8>' ) + sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> emailText += '<STR_LIT>' <EOL> htmlText += '<STR_LIT>' <EOL> titleFilter = [ ] <EOL> if ( tvShows [ show ] [ '<STR_LIT:title>' ] in config [ '<STR_LIT>' ] or len ( set ( titleFilter ) . intersection ( config [ '<STR_LIT>' ] ) ) > <NUM_LIT:0> or ( config [ '<STR_LIT>' ] and tvShows [ show ] [ '<STR_LIT:title>' ] not in config [ '<STR_LIT>' ] and len ( set ( titleFilter ) . intersection ( config [ '<STR_LIT>' ] ) ) == <NUM_LIT:0> ) ) : <EOL> skipItem = True <EOL> if ( not skipItem ) : <EOL> showCount += <NUM_LIT:1> <EOL> emailTVShows += emailText <EOL> htmlTVShows += htmlText <EOL> for season in tvSeasons : <EOL> cur2 = con . cursor ( ) <EOL> cur2 . execute ( "<STR_LIT>" + str ( tvSeasons [ season ] [ '<STR_LIT>' ] ) + "<STR_LIT:;>" ) <EOL> for row in cur2 : <EOL> tvSeasons [ season ] [ '<STR_LIT:title>' ] = row [ <NUM_LIT:0> ] <EOL> tvSeasons [ season ] [ '<STR_LIT>' ] = row [ <NUM_LIT:1> ] <EOL> tvSeasons [ season ] [ '<STR_LIT>' ] = row [ <NUM_LIT:2> ] <EOL> tvSeasons [ season ] [ '<STR_LIT>' ] = row [ <NUM_LIT:3> ] <EOL> tvSeasons [ season ] [ '<STR_LIT>' ] = row [ <NUM_LIT:4> ] <EOL> tvSeasons [ season ] [ '<STR_LIT>' ] = row [ <NUM_LIT:5> ] <EOL> tvSeasons [ season ] [ '<STR_LIT>' ] = row [ <NUM_LIT:6> ] <EOL> tvSeasons [ season ] [ '<STR_LIT>' ] = row [ <NUM_LIT:7> ] <EOL> tvSeasons [ season ] [ '<STR_LIT>' ] = row [ <NUM_LIT:8> ] <EOL> tvSeasons [ season ] [ '<STR_LIT>' ] = row [ <NUM_LIT:9> ] <EOL> tvSeasons [ season ] [ '<STR_LIT>' ] = row [ <NUM_LIT:10> ] <EOL> tvSeasons [ season ] [ '<STR_LIT>' ] = row [ <NUM_LIT:11> ] <EOL> tvSeasons [ season ] [ '<STR_LIT>' ] = row [ <NUM_LIT:12> ] <EOL> tvSeasons [ season ] [ '<STR_LIT>' ] = row [ <NUM_LIT> ] <EOL> tvSeasons [ season ] [ '<STR_LIT>' ] = row [ <NUM_LIT> ] <EOL> if ( '<STR_LIT>' in config and config [ '<STR_LIT>' ] != '<STR_LIT>' ) : <EOL> tvSeasons = OrderedDict ( sorted ( tvSeasons . iteritems ( ) , key = lambda t : t [ <NUM_LIT:1> ] [ config [ '<STR_LIT>' ] ] , reverse = config [ '<STR_LIT>' ] ) ) <EOL> if ( '<STR_LIT>' in config and config [ '<STR_LIT>' ] != '<STR_LIT>' ) : <EOL> tvSeasons = OrderedDict ( sorted ( tvSeasons . iteritems ( ) , key = lambda t : t [ <NUM_LIT:1> ] [ config [ '<STR_LIT>' ] ] , reverse = config [ '<STR_LIT>' ] ) ) <EOL> if ( '<STR_LIT>' in config and config [ '<STR_LIT>' ] != '<STR_LIT>' ) : <EOL> tvSeasons = OrderedDict ( sorted ( tvSeasons . iteritems ( ) , key = lambda t : t [ <NUM_LIT:1> ] [ config [ '<STR_LIT>' ] ] , reverse = config [ '<STR_LIT>' ] ) ) <EOL> for season in tvSeasons : <EOL> tvSeasons [ season ] = convertToHumanReadable ( tvSeasons [ season ] ) <EOL> title = '<STR_LIT>' <EOL> if ( tvSeasons [ season ] [ '<STR_LIT>' ] != '<STR_LIT>' ) : <EOL> title += tvSeasons [ season ] [ '<STR_LIT>' ] + '<STR_LIT>' <EOL> title += tvSeasons [ season ] [ '<STR_LIT:title>' ] <EOL> hash = str ( tvSeasons [ season ] [ '<STR_LIT>' ] ) <EOL> imageInfo = { } <EOL> if ( tvSeasons [ season ] [ '<STR_LIT>' ] != '<STR_LIT>' ) : <EOL> imageInfo [ '<STR_LIT>' ] = tvSeasons [ season ] [ '<STR_LIT>' ] <EOL> imageInfo = processImage ( hash , imageInfo [ '<STR_LIT>' ] , '<STR_LIT>' , tvSeasons [ season ] [ '<STR_LIT:index>' ] , <NUM_LIT:0> ) <EOL> else : <EOL> imageInfo [ '<STR_LIT>' ] = tvSeasons [ season ] [ '<STR_LIT>' ] <EOL> imageInfo = processImage ( hash , imageInfo [ '<STR_LIT>' ] , '<STR_LIT>' , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> skipItem = False <EOL> emailText = '<STR_LIT>' <EOL> htmlText = '<STR_LIT>' <EOL> if ( config [ '<STR_LIT>' ] ) : <EOL> pwLink = plexWebLink + str ( tvSeasons [ season ] [ '<STR_LIT:id>' ] ) <EOL> else : <EOL> pwLink = '<STR_LIT>' <EOL> emailText += '<STR_LIT>' <EOL> if ( config [ '<STR_LIT>' ] ) : <EOL> emailText += '<STR_LIT>' + pwLink + '<STR_LIT>' + imageInfo [ '<STR_LIT>' ] . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> emailText += '<STR_LIT>' + pwLink + '<STR_LIT>' + title . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> emailText += '<STR_LIT>' + str ( tvSeasons [ season ] [ '<STR_LIT:index>' ] ) + '<STR_LIT>' <EOL> htmlText += '<STR_LIT>' <EOL> htmlText += '<STR_LIT>' + pwLink + '<STR_LIT>' + imageInfo [ '<STR_LIT>' ] . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> htmlText += '<STR_LIT>' + pwLink + '<STR_LIT>' + title . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> htmlText += '<STR_LIT>' + str ( tvSeasons [ season ] [ '<STR_LIT:index>' ] ) + '<STR_LIT>' <EOL> sections = config [ '<STR_LIT>' ] <EOL> for section in sorted ( sections . iteritems ( ) , key = lambda t : t [ <NUM_LIT:1> ] [ '<STR_LIT>' ] ) : <EOL> if ( tvSeasons [ season ] [ section [ <NUM_LIT:0> ] ] in sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] or len ( set ( tvSeasons [ season ] [ section [ <NUM_LIT:0> ] + '<STR_LIT>' ] ) . intersection ( sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] ) ) > <NUM_LIT:0> or ( sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] and tvSeasons [ season ] [ section [ <NUM_LIT:0> ] ] not in sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] and len ( set ( tvSeasons [ season ] [ section [ <NUM_LIT:0> ] + '<STR_LIT>' ] ) . intersection ( sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] ) ) == <NUM_LIT:0> ) ) : <EOL> skipItem = True <EOL> if ( sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] and tvSeasons [ season ] [ section [ <NUM_LIT:0> ] ] and tvSeasons [ season ] [ section [ <NUM_LIT:0> ] ] != '<STR_LIT>' ) : <EOL> displayText = str ( tvSeasons [ season ] [ section [ <NUM_LIT:0> ] ] ) <EOL> if ( '<STR_LIT>' in sections [ section [ <NUM_LIT:0> ] ] and sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] != '<STR_LIT>' ) : <EOL> displayText = time . strftime ( sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] , time . strptime ( displayText , '<STR_LIT>' ) ) <EOL> emailText += '<STR_LIT>' + sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] . decode ( '<STR_LIT:utf-8>' ) + displayText . decode ( '<STR_LIT:utf-8>' ) + sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> htmlText += '<STR_LIT>' + sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] . decode ( '<STR_LIT:utf-8>' ) + displayText . decode ( '<STR_LIT:utf-8>' ) + sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> emailText += '<STR_LIT>' <EOL> htmlText += '<STR_LIT>' <EOL> titleFilter = [ ] <EOL> if ( tvSeasons [ season ] [ '<STR_LIT:title>' ] in config [ '<STR_LIT>' ] or len ( set ( titleFilter ) . intersection ( config [ '<STR_LIT>' ] ) ) > <NUM_LIT:0> or ( config [ '<STR_LIT>' ] and tvSeasons [ season ] [ '<STR_LIT:title>' ] not in config [ '<STR_LIT>' ] and len ( set ( titleFilter ) . intersection ( config [ '<STR_LIT>' ] ) ) == <NUM_LIT:0> ) ) : <EOL> skipItem = True <EOL> if ( not skipItem ) : <EOL> seasonCount += <NUM_LIT:1> <EOL> emailTVSeasons += emailText <EOL> htmlTVSeasons += htmlText <EOL> for episode in tvEpisodes : <EOL> cur2 = con . cursor ( ) <EOL> cur2 . execute ( "<STR_LIT>" + str ( tvEpisodes [ episode ] [ '<STR_LIT>' ] ) + "<STR_LIT:;>" ) <EOL> for row in cur2 : <EOL> tvEpisodes [ episode ] [ '<STR_LIT>' ] = row [ <NUM_LIT:0> ] <EOL> parent_id = row [ <NUM_LIT:1> ] <EOL> tvEpisodes [ episode ] [ '<STR_LIT>' ] = row [ <NUM_LIT:2> ] <EOL> cur3 = con . cursor ( ) <EOL> cur3 . execute ( "<STR_LIT>" + str ( parent_id ) + "<STR_LIT:;>" ) <EOL> for row2 in cur3 : <EOL> tvEpisodes [ episode ] [ '<STR_LIT>' ] = row2 [ <NUM_LIT:0> ] <EOL> tvEpisodes [ episode ] [ '<STR_LIT>' ] = row2 [ <NUM_LIT:1> ] <EOL> tvEpisodes [ episode ] [ '<STR_LIT>' ] = row2 [ <NUM_LIT:2> ] <EOL> tvEpisodes [ episode ] [ '<STR_LIT>' ] = row2 [ <NUM_LIT:3> ] <EOL> tvEpisodes [ episode ] [ '<STR_LIT>' ] = row2 [ <NUM_LIT:4> ] <EOL> tvEpisodes [ episode ] [ '<STR_LIT>' ] = row2 [ <NUM_LIT:5> ] <EOL> tvEpisodes [ episode ] [ '<STR_LIT>' ] = row2 [ <NUM_LIT:6> ] <EOL> tvEpisodes [ episode ] [ '<STR_LIT>' ] = row2 [ <NUM_LIT:7> ] <EOL> tvEpisodes [ episode ] [ '<STR_LIT>' ] = row2 [ <NUM_LIT:8> ] <EOL> tvEpisodes [ episode ] [ '<STR_LIT>' ] = row2 [ <NUM_LIT:9> ] <EOL> if ( '<STR_LIT>' in config and config [ '<STR_LIT>' ] != '<STR_LIT>' ) : <EOL> tvEpisodes = OrderedDict ( sorted ( tvEpisodes . iteritems ( ) , key = lambda t : t [ <NUM_LIT:1> ] [ config [ '<STR_LIT>' ] ] , reverse = config [ '<STR_LIT>' ] ) ) <EOL> if ( '<STR_LIT>' in config and config [ '<STR_LIT>' ] != '<STR_LIT>' ) : <EOL> tvEpisodes = OrderedDict ( sorted ( tvEpisodes . iteritems ( ) , key = lambda t : t [ <NUM_LIT:1> ] [ config [ '<STR_LIT>' ] ] , reverse = config [ '<STR_LIT>' ] ) ) <EOL> if ( '<STR_LIT>' in config and config [ '<STR_LIT>' ] != '<STR_LIT>' ) : <EOL> tvEpisodes = OrderedDict ( sorted ( tvEpisodes . iteritems ( ) , key = lambda t : t [ <NUM_LIT:1> ] [ config [ '<STR_LIT>' ] ] , reverse = config [ '<STR_LIT>' ] ) ) <EOL> for episode in tvEpisodes : <EOL> if ( tvEpisodes [ episode ] [ '<STR_LIT>' ] not in tvSeasons ) : <EOL> tvEpisodes [ episode ] = convertToHumanReadable ( tvEpisodes [ episode ] ) <EOL> showTitle = '<STR_LIT>' <EOL> if ( tvEpisodes [ episode ] [ '<STR_LIT>' ] != '<STR_LIT>' ) : <EOL> showTitle += tvEpisodes [ episode ] [ '<STR_LIT>' ] + '<STR_LIT>' <EOL> showTitle += tvEpisodes [ episode ] [ '<STR_LIT>' ] <EOL> title = '<STR_LIT>' <EOL> if ( tvEpisodes [ episode ] [ '<STR_LIT>' ] != '<STR_LIT>' ) : <EOL> title += tvEpisodes [ episode ] [ '<STR_LIT>' ] + '<STR_LIT>' <EOL> title += tvEpisodes [ episode ] [ '<STR_LIT:title>' ] <EOL> hash = str ( tvEpisodes [ episode ] [ '<STR_LIT>' ] ) <EOL> imageInfo = { } <EOL> imageTypeToUse = '<STR_LIT>' if ( tvEpisodes [ episode ] [ '<STR_LIT>' ] != '<STR_LIT>' and config [ '<STR_LIT>' ] == '<STR_LIT>' ) else '<STR_LIT>' if ( tvEpisodes [ episode ] [ '<STR_LIT>' ] != '<STR_LIT>' and config [ '<STR_LIT>' ] == '<STR_LIT>' ) else '<STR_LIT>' if ( tvEpisodes [ episode ] [ '<STR_LIT>' ] != '<STR_LIT>' ) else '<STR_LIT>' <EOL> if ( imageTypeToUse == '<STR_LIT>' ) : <EOL> imageInfo [ '<STR_LIT>' ] = tvEpisodes [ episode ] [ '<STR_LIT>' ] <EOL> imageInfo = processImage ( hash , imageInfo [ '<STR_LIT>' ] , '<STR_LIT>' , tvEpisodes [ episode ] [ '<STR_LIT>' ] , tvEpisodes [ episode ] [ '<STR_LIT:index>' ] ) <EOL> elif ( imageTypeToUse == '<STR_LIT>' ) : <EOL> imageInfo [ '<STR_LIT>' ] = tvEpisodes [ episode ] [ '<STR_LIT>' ] <EOL> imageInfo = processImage ( hash , imageInfo [ '<STR_LIT>' ] , '<STR_LIT>' , tvEpisodes [ episode ] [ '<STR_LIT>' ] , <NUM_LIT:0> ) <EOL> elif ( imageTypeToUse == '<STR_LIT>' ) : <EOL> imageInfo [ '<STR_LIT>' ] = tvEpisodes [ episode ] [ '<STR_LIT>' ] <EOL> imageInfo = processImage ( hash , imageInfo [ '<STR_LIT>' ] , '<STR_LIT>' , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> skipItem = False <EOL> emailText = '<STR_LIT>' <EOL> htmlText = '<STR_LIT>' <EOL> if ( config [ '<STR_LIT>' ] ) : <EOL> pwLink = plexWebLink + str ( tvEpisodes [ episode ] [ '<STR_LIT:id>' ] ) <EOL> else : <EOL> pwLink = '<STR_LIT>' <EOL> emailText += '<STR_LIT>' <EOL> if ( config [ '<STR_LIT>' ] ) : <EOL> emailText += '<STR_LIT>' + pwLink + '<STR_LIT>' + imageInfo [ '<STR_LIT>' ] . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> emailText += '<STR_LIT>' + pwLink + '<STR_LIT>' + showTitle . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> emailText += '<STR_LIT>' + str ( tvEpisodes [ episode ] [ '<STR_LIT>' ] ) + '<STR_LIT>' + str ( tvEpisodes [ episode ] [ '<STR_LIT:index>' ] ) + '<STR_LIT>' + title . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> htmlText += '<STR_LIT>' <EOL> htmlText += '<STR_LIT>' + pwLink + '<STR_LIT>' + imageInfo [ '<STR_LIT>' ] . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> htmlText += '<STR_LIT>' + pwLink + '<STR_LIT>' + showTitle . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> htmlText += '<STR_LIT>' + str ( tvEpisodes [ episode ] [ '<STR_LIT>' ] ) + '<STR_LIT>' + str ( tvEpisodes [ episode ] [ '<STR_LIT:index>' ] ) + '<STR_LIT>' + title . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> sections = config [ '<STR_LIT>' ] <EOL> for section in sorted ( sections . iteritems ( ) , key = lambda t : t [ <NUM_LIT:1> ] [ '<STR_LIT>' ] ) : <EOL> if ( tvEpisodes [ episode ] [ section [ <NUM_LIT:0> ] ] in sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] or len ( set ( tvEpisodes [ episode ] [ section [ <NUM_LIT:0> ] + '<STR_LIT>' ] ) . intersection ( sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] ) ) > <NUM_LIT:0> or ( sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] and tvEpisodes [ episode ] [ section [ <NUM_LIT:0> ] ] not in sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] and len ( set ( tvEpisodes [ episode ] [ section [ <NUM_LIT:0> ] + '<STR_LIT>' ] ) . intersection ( sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] ) ) == <NUM_LIT:0> ) ) : <EOL> skipItem = True <EOL> if ( sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] and tvEpisodes [ episode ] [ section [ <NUM_LIT:0> ] ] and tvEpisodes [ episode ] [ section [ <NUM_LIT:0> ] ] != '<STR_LIT>' ) : <EOL> displayText = str ( tvEpisodes [ episode ] [ section [ <NUM_LIT:0> ] ] ) <EOL> if ( '<STR_LIT>' in sections [ section [ <NUM_LIT:0> ] ] and sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] != '<STR_LIT>' ) : <EOL> displayText = time . strftime ( sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] , time . strptime ( displayText , '<STR_LIT>' ) ) <EOL> emailText += '<STR_LIT>' + sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] . decode ( '<STR_LIT:utf-8>' ) + displayText . decode ( '<STR_LIT:utf-8>' ) + sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> htmlText += '<STR_LIT>' + sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] . decode ( '<STR_LIT:utf-8>' ) + displayText . decode ( '<STR_LIT:utf-8>' ) + sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> emailText += '<STR_LIT>' <EOL> htmlText += '<STR_LIT>' <EOL> titleFilter = [ ] <EOL> if ( tvEpisodes [ episode ] [ '<STR_LIT>' ] in config [ '<STR_LIT>' ] or len ( set ( titleFilter ) . intersection ( config [ '<STR_LIT>' ] ) ) > <NUM_LIT:0> or ( config [ '<STR_LIT>' ] and tvEpisodes [ episode ] [ '<STR_LIT>' ] not in config [ '<STR_LIT>' ] and len ( set ( titleFilter ) . intersection ( config [ '<STR_LIT>' ] ) ) == <NUM_LIT:0> ) ) : <EOL> skipItem = True <EOL> if ( not skipItem ) : <EOL> episodeCount += <NUM_LIT:1> <EOL> emailTVEpisodes += emailText <EOL> htmlTVEpisodes += htmlText <EOL> if ( '<STR_LIT>' in config and config [ '<STR_LIT>' ] != '<STR_LIT>' ) : <EOL> artists = OrderedDict ( sorted ( artists . iteritems ( ) , key = lambda t : t [ <NUM_LIT:1> ] [ config [ '<STR_LIT>' ] ] , reverse = config [ '<STR_LIT>' ] ) ) <EOL> if ( '<STR_LIT>' in config and config [ '<STR_LIT>' ] != '<STR_LIT>' ) : <EOL> artists = OrderedDict ( sorted ( artists . iteritems ( ) , key = lambda t : t [ <NUM_LIT:1> ] [ config [ '<STR_LIT>' ] ] , reverse = config [ '<STR_LIT>' ] ) ) <EOL> if ( '<STR_LIT>' in config and config [ '<STR_LIT>' ] != '<STR_LIT>' ) : <EOL> artists = OrderedDict ( sorted ( artists . iteritems ( ) , key = lambda t : t [ <NUM_LIT:1> ] [ config [ '<STR_LIT>' ] ] , reverse = config [ '<STR_LIT>' ] ) ) <EOL> for artist in artists : <EOL> artists [ artist ] = convertToHumanReadable ( artists [ artist ] ) <EOL> title = '<STR_LIT>' <EOL> if ( artists [ artist ] [ '<STR_LIT>' ] != '<STR_LIT>' ) : <EOL> title += artists [ artist ] [ '<STR_LIT>' ] + '<STR_LIT>' <EOL> title += artists [ artist ] [ '<STR_LIT:title>' ] <EOL> hash = str ( artists [ artist ] [ '<STR_LIT>' ] ) <EOL> imageInfo = { } <EOL> imageInfo [ '<STR_LIT>' ] = artists [ artist ] [ '<STR_LIT>' ] <EOL> imageInfo = processImage ( hash , imageInfo [ '<STR_LIT>' ] , '<STR_LIT>' , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> skipItem = False <EOL> emailText = '<STR_LIT>' <EOL> htmlText = '<STR_LIT>' <EOL> if ( config [ '<STR_LIT>' ] ) : <EOL> pwLink = plexWebLink + str ( artists [ artist ] [ '<STR_LIT:id>' ] ) <EOL> else : <EOL> pwLink = '<STR_LIT>' <EOL> emailText += '<STR_LIT>' <EOL> if ( config [ '<STR_LIT>' ] ) : <EOL> emailText += '<STR_LIT>' + pwLink + '<STR_LIT>' + imageInfo [ '<STR_LIT>' ] . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> emailText += '<STR_LIT>' + pwLink + '<STR_LIT>' + title . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> htmlText += '<STR_LIT>' <EOL> htmlText += '<STR_LIT>' + pwLink + '<STR_LIT>' + imageInfo [ '<STR_LIT>' ] . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> htmlText += '<STR_LIT>' + pwLink + '<STR_LIT>' + title . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> sections = config [ '<STR_LIT>' ] <EOL> for section in sorted ( sections . iteritems ( ) , key = lambda t : t [ <NUM_LIT:1> ] [ '<STR_LIT>' ] ) : <EOL> if ( section [ <NUM_LIT:0> ] != '<STR_LIT>' ) : <EOL> if ( artists [ artist ] [ section [ <NUM_LIT:0> ] ] in sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] or len ( set ( artists [ artist ] [ section [ <NUM_LIT:0> ] + '<STR_LIT>' ] ) . intersection ( sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] ) ) > <NUM_LIT:0> or ( sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] and artists [ artist ] [ section [ <NUM_LIT:0> ] ] not in sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] and len ( set ( artists [ artist ] [ section [ <NUM_LIT:0> ] + '<STR_LIT>' ] ) . intersection ( sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] ) ) == <NUM_LIT:0> ) ) : <EOL> skipItem = True <EOL> if ( sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] and artists [ artist ] [ section [ <NUM_LIT:0> ] ] and artists [ artist ] [ section [ <NUM_LIT:0> ] ] != '<STR_LIT>' ) : <EOL> displayText = str ( artists [ artist ] [ section [ <NUM_LIT:0> ] ] ) <EOL> if ( '<STR_LIT>' in sections [ section [ <NUM_LIT:0> ] ] and sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] != '<STR_LIT>' ) : <EOL> displayText = time . strftime ( sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] , time . strptime ( displayText , '<STR_LIT>' ) ) <EOL> emailText += '<STR_LIT>' + sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] . decode ( '<STR_LIT:utf-8>' ) + displayText . decode ( '<STR_LIT:utf-8>' ) + sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> htmlText += '<STR_LIT>' + sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] . decode ( '<STR_LIT:utf-8>' ) + displayText . decode ( '<STR_LIT:utf-8>' ) + sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> emailText += '<STR_LIT>' <EOL> htmlText += '<STR_LIT>' <EOL> titleFilter = [ ] <EOL> if ( artists [ artist ] [ '<STR_LIT:title>' ] in config [ '<STR_LIT>' ] or len ( set ( titleFilter ) . intersection ( config [ '<STR_LIT>' ] ) ) > <NUM_LIT:0> or ( config [ '<STR_LIT>' ] and artists [ artist ] [ '<STR_LIT:title>' ] not in config [ '<STR_LIT>' ] and len ( set ( titleFilter ) . intersection ( config [ '<STR_LIT>' ] ) ) == <NUM_LIT:0> ) ) : <EOL> skipItem = True <EOL> if ( not skipItem ) : <EOL> artistCount += <NUM_LIT:1> <EOL> emailArtists += emailText <EOL> htmlArtists += htmlText <EOL> for album in albums : <EOL> cur2 = con . cursor ( ) <EOL> cur2 . execute ( "<STR_LIT>" + str ( albums [ album ] [ '<STR_LIT>' ] ) + "<STR_LIT:;>" ) <EOL> for row in cur2 : <EOL> albums [ album ] [ '<STR_LIT:title>' ] = row [ <NUM_LIT:0> ] + '<STR_LIT>' + albums [ album ] [ '<STR_LIT:title>' ] <EOL> albums [ album ] [ '<STR_LIT>' ] = row [ <NUM_LIT:1> ] + '<STR_LIT>' + albums [ album ] [ '<STR_LIT>' ] <EOL> albums [ album ] [ '<STR_LIT>' ] = row [ <NUM_LIT:2> ] <EOL> albums [ album ] [ '<STR_LIT>' ] = row [ <NUM_LIT:3> ] <EOL> albums [ album ] [ '<STR_LIT>' ] = row [ <NUM_LIT:4> ] <EOL> albums [ album ] [ '<STR_LIT>' ] = row [ <NUM_LIT:5> ] <EOL> albums [ album ] [ '<STR_LIT>' ] = row [ <NUM_LIT:6> ] <EOL> albums [ album ] [ '<STR_LIT>' ] = row [ <NUM_LIT:7> ] <EOL> albums [ album ] [ '<STR_LIT>' ] = row [ <NUM_LIT:8> ] <EOL> albums [ album ] [ '<STR_LIT>' ] = row [ <NUM_LIT:9> ] <EOL> albums [ album ] [ '<STR_LIT>' ] = row [ <NUM_LIT:10> ] <EOL> albums [ album ] [ '<STR_LIT>' ] = row [ <NUM_LIT:11> ] <EOL> albums [ album ] [ '<STR_LIT>' ] = row [ <NUM_LIT:12> ] <EOL> albums [ album ] [ '<STR_LIT>' ] = row [ <NUM_LIT> ] <EOL> albums [ album ] [ '<STR_LIT>' ] = row [ <NUM_LIT> ] <EOL> cur2 = con . cursor ( ) <EOL> cur2 . execute ( "<STR_LIT>" + str ( albums [ album ] [ '<STR_LIT:id>' ] ) + "<STR_LIT:;>" ) <EOL> albums [ album ] [ '<STR_LIT>' ] = { } <EOL> for row in cur2 : <EOL> duration = row [ <NUM_LIT:5> ] / <NUM_LIT:1000> <EOL> seconds = duration % <NUM_LIT> <EOL> duration /= <NUM_LIT> <EOL> minutes = duration % <NUM_LIT> <EOL> duration /= <NUM_LIT> <EOL> hours = duration <EOL> duration = str ( hours ) + '<STR_LIT::>' if ( hours > <NUM_LIT:0> ) else '<STR_LIT>' <EOL> duration += str ( minutes ) . zfill ( <NUM_LIT:2> ) + '<STR_LIT::>' + str ( seconds ) . zfill ( <NUM_LIT:2> ) <EOL> albums [ album ] [ '<STR_LIT>' ] [ row [ <NUM_LIT:4> ] ] = { '<STR_LIT:id>' : row [ <NUM_LIT:0> ] , '<STR_LIT:title>' : row [ <NUM_LIT:1> ] , '<STR_LIT>' : row [ <NUM_LIT:2> ] , '<STR_LIT>' : row [ <NUM_LIT:3> ] , '<STR_LIT:index>' : row [ <NUM_LIT:4> ] , '<STR_LIT>' : duration , '<STR_LIT>' : row [ <NUM_LIT:6> ] } <EOL> if ( '<STR_LIT>' in config and config [ '<STR_LIT>' ] != '<STR_LIT>' ) : <EOL> albums = OrderedDict ( sorted ( albums . iteritems ( ) , key = lambda t : t [ <NUM_LIT:1> ] [ config [ '<STR_LIT>' ] ] , reverse = config [ '<STR_LIT>' ] ) ) <EOL> if ( '<STR_LIT>' in config and config [ '<STR_LIT>' ] != '<STR_LIT>' ) : <EOL> albums = OrderedDict ( sorted ( albums . iteritems ( ) , key = lambda t : t [ <NUM_LIT:1> ] [ config [ '<STR_LIT>' ] ] , reverse = config [ '<STR_LIT>' ] ) ) <EOL> if ( '<STR_LIT>' in config and config [ '<STR_LIT>' ] != '<STR_LIT>' ) : <EOL> albums = OrderedDict ( sorted ( albums . iteritems ( ) , key = lambda t : t [ <NUM_LIT:1> ] [ config [ '<STR_LIT>' ] ] , reverse = config [ '<STR_LIT>' ] ) ) <EOL> for album in albums : <EOL> albums [ album ] = convertToHumanReadable ( albums [ album ] ) <EOL> title = '<STR_LIT>' <EOL> if ( albums [ album ] [ '<STR_LIT>' ] != '<STR_LIT>' ) : <EOL> title += albums [ album ] [ '<STR_LIT>' ] + '<STR_LIT>' <EOL> title += albums [ album ] [ '<STR_LIT:title>' ] <EOL> imageInfo = { } <EOL> if ( albums [ album ] [ '<STR_LIT>' ] != '<STR_LIT>' ) : <EOL> imageInfo [ '<STR_LIT>' ] = albums [ album ] [ '<STR_LIT>' ] <EOL> imageInfo = processImage ( str ( albums [ album ] [ '<STR_LIT>' ] ) , imageInfo [ '<STR_LIT>' ] , '<STR_LIT>' , albums [ album ] [ '<STR_LIT:index>' ] , <NUM_LIT:0> ) <EOL> else : <EOL> imageInfo [ '<STR_LIT>' ] = albums [ album ] [ '<STR_LIT>' ] <EOL> imageInfo = processImage ( str ( albums [ album ] [ '<STR_LIT>' ] ) , imageInfo [ '<STR_LIT>' ] , '<STR_LIT>' , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> skipItem = False <EOL> emailText = '<STR_LIT>' <EOL> htmlText = '<STR_LIT>' <EOL> if ( config [ '<STR_LIT>' ] ) : <EOL> pwLink = plexWebLink + str ( albums [ album ] [ '<STR_LIT:id>' ] ) <EOL> else : <EOL> pwLink = '<STR_LIT>' <EOL> emailText += '<STR_LIT>' <EOL> if ( config [ '<STR_LIT>' ] ) : <EOL> emailText += '<STR_LIT>' + pwLink + '<STR_LIT>' + imageInfo [ '<STR_LIT>' ] . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> emailText += '<STR_LIT>' + pwLink + '<STR_LIT>' + title . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> htmlText += '<STR_LIT>' <EOL> htmlText += '<STR_LIT>' + pwLink + '<STR_LIT>' + imageInfo [ '<STR_LIT>' ] . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> htmlText += '<STR_LIT>' + pwLink + '<STR_LIT>' + title . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> tracklistEmailText = '<STR_LIT>' <EOL> tracklistHTMLText = '<STR_LIT>' <EOL> sections = config [ '<STR_LIT>' ] <EOL> trackCount = <NUM_LIT:0> <EOL> for section in sorted ( sections . iteritems ( ) , key = lambda t : t [ <NUM_LIT:1> ] [ '<STR_LIT>' ] ) : <EOL> if ( section [ <NUM_LIT:0> ] == '<STR_LIT>' ) : <EOL> if ( sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] ) : <EOL> tracklistEmailText += '<STR_LIT>' + sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] + '<STR_LIT>' + sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] + '<STR_LIT>' + sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] + '<STR_LIT>' + sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] + '<STR_LIT>' <EOL> tracklistHTMLText += '<STR_LIT>' + sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] + '<STR_LIT>' + sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] + '<STR_LIT>' + sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] + '<STR_LIT>' + sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] + '<STR_LIT>' <EOL> for track in albums [ album ] [ '<STR_LIT>' ] : <EOL> tracklistEmailText += '<STR_LIT>' + str ( albums [ album ] [ '<STR_LIT>' ] [ track ] [ '<STR_LIT:index>' ] ) . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' + albums [ album ] [ '<STR_LIT>' ] [ track ] [ '<STR_LIT:title>' ] . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' + albums [ album ] [ '<STR_LIT>' ] [ track ] [ '<STR_LIT>' ] . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' + str ( albums [ album ] [ '<STR_LIT>' ] [ track ] [ '<STR_LIT>' ] ) . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> tracklistHTMLText += '<STR_LIT>' + str ( albums [ album ] [ '<STR_LIT>' ] [ track ] [ '<STR_LIT:index>' ] ) . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' + albums [ album ] [ '<STR_LIT>' ] [ track ] [ '<STR_LIT:title>' ] . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' + albums [ album ] [ '<STR_LIT>' ] [ track ] [ '<STR_LIT>' ] . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' + str ( albums [ album ] [ '<STR_LIT>' ] [ track ] [ '<STR_LIT>' ] ) . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> trackCount += <NUM_LIT:1> <EOL> tracklistEmailText += '<STR_LIT>' <EOL> tracklistHTMLText += '<STR_LIT>' <EOL> else : <EOL> if ( albums [ album ] [ section [ <NUM_LIT:0> ] ] in sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] or len ( set ( albums [ album ] [ section [ <NUM_LIT:0> ] + '<STR_LIT>' ] ) . intersection ( sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] ) ) > <NUM_LIT:0> or ( sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] and albums [ album ] [ section [ <NUM_LIT:0> ] ] not in sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] and len ( set ( albums [ album ] [ section [ <NUM_LIT:0> ] + '<STR_LIT>' ] ) . intersection ( sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] ) ) == <NUM_LIT:0> ) ) : <EOL> skipItem = True <EOL> if ( sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] and albums [ album ] [ section [ <NUM_LIT:0> ] ] and albums [ album ] [ section [ <NUM_LIT:0> ] ] != '<STR_LIT>' ) : <EOL> displayText = str ( albums [ album ] [ section [ <NUM_LIT:0> ] ] ) <EOL> if ( '<STR_LIT>' in sections [ section [ <NUM_LIT:0> ] ] and sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] != '<STR_LIT>' ) : <EOL> displayText = time . strftime ( sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] , time . strptime ( displayText , '<STR_LIT>' ) ) <EOL> emailText += '<STR_LIT>' + sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] . decode ( '<STR_LIT:utf-8>' ) + displayText . decode ( '<STR_LIT:utf-8>' ) + sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> htmlText += '<STR_LIT>' + sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] . decode ( '<STR_LIT:utf-8>' ) + displayText . decode ( '<STR_LIT:utf-8>' ) + sections [ section [ <NUM_LIT:0> ] ] [ '<STR_LIT>' ] . decode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' <EOL> emailText += '<STR_LIT>' <EOL> emailText += tracklistEmailText if ( trackCount > <NUM_LIT:0> ) else '<STR_LIT>' <EOL> emailText += '<STR_LIT>' <EOL> htmlText += '<STR_LIT>' <EOL> htmlText += tracklistHTMLText if ( trackCount > <NUM_LIT:0> ) else '<STR_LIT>' <EOL> htmlText += '<STR_LIT>' <EOL> titleFilter = [ ] <EOL> if ( albums [ album ] [ '<STR_LIT:title>' ] in config [ '<STR_LIT>' ] or len ( set ( titleFilter ) . intersection ( config [ '<STR_LIT>' ] ) ) > <NUM_LIT:0> or ( config [ '<STR_LIT>' ] and albums [ album ] [ '<STR_LIT:title>' ] not in config [ '<STR_LIT>' ] and len ( set ( titleFilter ) . intersection ( config [ '<STR_LIT>' ] ) ) == <NUM_LIT:0> ) ) : <EOL> skipItem = True <EOL> if ( not skipItem ) : <EOL> albumCount += <NUM_LIT:1> <EOL> emailAlbums += emailText <EOL> htmlAlbums += htmlText <EOL> if ( ( movieCount > <NUM_LIT:0> and config [ '<STR_LIT>' ] ) or ( showCount > <NUM_LIT:0> and config [ '<STR_LIT>' ] ) or ( seasonCount > <NUM_LIT:0> and config [ '<STR_LIT>' ] ) or ( episodeCount > <NUM_LIT:0> and config [ '<STR_LIT>' ] ) or ( artistCount > <NUM_LIT:0> and config [ '<STR_LIT>' ] ) or ( albumCount > <NUM_LIT:0> and config [ '<STR_LIT>' ] ) or ( songCount > <NUM_LIT:0> and config [ '<STR_LIT>' ] ) ) : <EOL> hasNewContent = True <EOL> else : <EOL> hasNewContent = False <EOL> emailHTML = createEmailHTML ( ) <EOL> webHTML = createWebHTML ( ) <EOL> if ( config [ '<STR_LIT>' ] and not config [ '<STR_LIT>' ] and ( not config [ '<STR_LIT>' ] or hasNewContent ) ) : <EOL> with open ( config [ '<STR_LIT>' ] + config [ '<STR_LIT>' ] + os . path . sep + '<STR_LIT>' , '<STR_LIT:w>' ) as text_file : <EOL> text_file . write ( webHTML . encode ( '<STR_LIT:utf-8>' ) ) <EOL> print '<STR_LIT>' <EOL> elif ( not config [ '<STR_LIT>' ] or ( config [ '<STR_LIT>' ] and config [ '<STR_LIT>' ] ) ) : <EOL> print '<STR_LIT>' <EOL> else : <EOL> print '<STR_LIT>' <EOL> if ( config [ '<STR_LIT>' ] and ( not config [ '<STR_LIT>' ] or hasNewContent ) ) : <EOL> if ( config [ '<STR_LIT>' ] ) : <EOL> sharedEmails = getSharedUserEmails ( ) <EOL> config [ '<STR_LIT>' ] . extend ( x for x in sharedEmails if x not in config [ '<STR_LIT>' ] ) <EOL> emailCount = <NUM_LIT:0> <EOL> if ( testMode ) : <EOL> success = sendMail ( [ config [ '<STR_LIT>' ] ] ) <EOL> emailCount += success <EOL> elif ( config [ '<STR_LIT>' ] ) : <EOL> for emailAdd in config [ '<STR_LIT>' ] : <EOL> email = [ emailAdd ] <EOL> success = sendMail ( email ) <EOL> emailCount += success <EOL> else : <EOL> success = sendMail ( '<STR_LIT>' ) <EOL> emailCount += success <EOL> print '<STR_LIT>' % emailCount <EOL> elif ( not config [ '<STR_LIT>' ] ) : <EOL> print '<STR_LIT>' <EOL> else : <EOL> print '<STR_LIT>' </s>
