#from sys import version_info
#import datetime
#import locale
#import operator
#import sickgear
#from sickgear import config,  metadata
#from sickgear.metadata.generic import GenericMetadata
#from sickgear.common import *
#from sickgear.db import db_supports_backup
#from sickgear.helpers import anon_url, maybe_plural
#from sickgear.logger import reverseNames as file_logging_presets
#from sickgear.piper import check_pip_env
#from sickgear.sgdatetime import *
<% def sg_var(varname, default=False): return getattr(sickgear, varname, default) %>#slurp#
<% def sg_str(varname, default=''): return getattr(sickgear, varname, default) %>#slurp#
##
#set global $title  = 'Config - General'
#set global $header = 'General Settings'
#set global $sbPath = '../..'
#set global $topmenu = 'config'
##
#import os.path
#include $os.path.join($sg_str('PROG_DIR'), 'gui/slick/interfaces/default/inc_top.tmpl')

#if $varExists('header')
	<h1 class="header">$header</h1>
#else
	<h1 class="title">$title</h1>
#end if
##
#set $checked = ' checked="checked"'
#set $selected = ' selected="selected"'
##

<script type="text/javascript" src="$sbRoot/js/config.js?v=$sbPID"></script>
<script type="text/javascript" src="$sbRoot/js/rootDirs.js?v=$sbPID"></script>

<div id="config">
	<div id="config-content">

		<form id="configForm" action="save_general" method="post">
			$xsrf_form_html

			<div id="config-components">

				<ul>
					<li><a href="#core-component-group1">Misc</a></li>
					<li><a href="#core-component-group2">Interface</a></li>
					<li><a href="#core-component-group3">Advanced</a></li>
				</ul>

				<div id="core-component-group1">
				<div class="component-group">

					<div class="component-group-desc">
						<h3>Misc</h3>
						<p>Startup options. TV info source options. Log and show file locations.</p>
						<p><b>Some options may require a manual restart to take effect.</b></p>
					</div>

					<fieldset class="component-group-list">
						<div class="field-pair">
							<label for="launch_browser">
								<span class="component-title">Launch browser</span>
								<span class="component-desc">
									<input type="checkbox" name="launch_browser" id="launch_browser"#echo ('', $checked)[$sg_var('LAUNCH_BROWSER')]#>
									<p>open the SickGear home page on startup</p>
								</span>
							</label>
						</div>

						<div class="field-pair">
							<label for="update_shows_on_start">
								<span class="component-title">Update shows on startup</span>
								<span class="component-desc">
									<input type="checkbox" name="update_shows_on_start" id="update_shows_on_start"#echo ('', $checked)[$sg_var('UPDATE_SHOWS_ON_START')]#>
									<p>with show data; episode plot, images, air and end dates, etc. Disable for a quicker startup. Show data is scheduled to update during hour <span class="show_update_hour_value">$sg_var('SHOW_UPDATE_HOUR', 3)</span></p>
								</span>
							</label>
						</div>

						<div class="field-pair">
							<label for="show_update_hour">
								<span class="component-title">Update shows during hour</span>
								<span class="component-desc">
									<input type="number" name="show_update_hour" id="show_update_hour" value="$sg_var('SHOW_UPDATE_HOUR', 3)" class="form-control input-sm input75">
									<p>(0 ... 23) with show data; episode plot, images, air and end dates, etc.</p>
								</span>
							</label>
						</div>

						<div class="field-pair">
							<span class="component-title">Send to trash for actions</span>
							<span class="component-desc">
								<label for="trash_remove_show" class="nextline-block">
									<input type="checkbox" name="trash_remove_show" id="trash_remove_show"#echo ('', $checked)[$sg_var('TRASH_REMOVE_SHOW')]#>
									<p>when using show "Remove" and delete files</p>
								</label>
								<label for="trash_rotate_logs" class="nextline-block">
									<input type="checkbox" name="trash_rotate_logs" id="trash_rotate_logs"#echo ('', $checked)[$sg_var('TRASH_ROTATE_LOGS')]#>
									<p>on scheduled deletes of the oldest log files</p>
								</label>
								<div class="clear-left"><p>selected actions use trash (recycle bin) instead of the default permanent delete</p></div>
							</span>
						</div>

						<div class="field-pair">
							<label for="log_dir">
								<span class="component-title">Log file folder location</span>
								<span class="component-desc">
									<input type="text" name="log_dir" id="log_dir" value="$sg_str('ACTUAL_LOG_DIR')" class="form-control input-sm input350">
								</span>
							</label>
						</div>
#set $def_isrc = 0
#if $sg_var('TVINFO_DEFAULT')
    #set $def_isrc = $sg_var('TVINFO_DEFAULT')
#end if
#if $getVar('infosrc', None) and 1 < $len($infosrc)
						<div class="field-pair">
							<label for="indexer_default">
								<span class="component-title">Set initial TV info source as</span>
								<span class="component-desc">
									<select id="indexer_default" name="indexer_default" class="form-control input-sm">
										<option value="0"#echo ('', $selected)[0 == $def_isrc]#>All Sources</option>
    #for $isrc in $infosrc
										<option value="$isrc"#echo ('', $selected)[$isrc == $sg_var('TVINFO_DEFAULT', 0)]#>$sickgear.TVInfoAPI().sources[$isrc]</option>
    #end for
									</select>
									<span>as the default selection when adding new shows</span>
								</span>
							</label>
						</div>
#end if
						<div class="field-pair">
							<label for="indexer_timeout">
								<span class="component-title">Timeout TV info source at</span>
								<span class="component-desc">
									<input type="text" name="indexer_timeout" id="indexer_timeout" value="$sg_var('TVINFO_TIMEOUT', 20)" class="form-control input-sm input75">
									<p>seconds of inactivity when finding new shows (default:10)</p>
								</span>
							</label>
						</div>

						<div class="field-pair">
							<label>
								<span class="component-title">Show root directories</span>
								<span class="component-desc">
									<p>where the files of shows are located</p>
#include $os.path.join($sg_str('PROG_DIR'), 'gui/slick/interfaces/default/inc_rootDirs.tmpl')
								</span>
							</label>
						</div>

						<div class="field-pair">
							<label for="show_dirs_with_dots">
								<span class="component-title">Use dots in show.name path</span>
								<span class="component-desc">
									<input type="checkbox" name="show_dirs_with_dots" id="show_dirs_with_dots"#echo ('', $checked)[$sg_var('SHOW_DIRS_WITH_DOTS')]#>
									<p>or use space i.e. "show name" (default:unset)</p>
								</span>
							</label>
						</div>

						<input type="submit" class="btn config_submitter" value="Save Changes">
					</fieldset>
				</div>
				<div class="component-group">

					<div class="component-group-desc">
						<h3>Updates</h3>
						<p>Options for software, package and alternative shownames/numbers.</p>
					</div>
					<fieldset class="component-group-list">
#set $git_unsafe = 'git' == $sickgear.update_software_scheduler.action.install_type and $sickgear.update_software_scheduler.action.updater.unsafe
#if $git_unsafe
						<div class="field-pair">
							<span class="component-title">Built-in updates disabled</span>
							<span class="component-desc"><p>SickGear directory is not marked as safe in git settings.
								Tip: Use 'install-path' <code>$sg_str('PROG_DIR').replace('\\', '/')</code> to enable git updates in...</p>
								<code>git config --global --add safe.directory install-path</code>
							</span>
						</div>
#end if
#if not $sg_var('EXT_UPDATES')
    #if not $git_unsafe
						<div class="field-pair">
							<span class="component-title">Software updates</span>
							<span class="component-desc">
								<label class="nextline-block">
									<input type="checkbox" class="views-if-interval1" name="update_notify"#echo ('', $checked)[$sg_var('UPDATE_NOTIFY', True)]#>
									<p>display message for outdated software, run checks at startup and at interval<sup>1</sup></p>
								</label>

								<label class="nextline-block">
									<input type="checkbox" class="views-if-interval1" name="update_auto"#echo ('', $checked)[$sg_var('UPDATE_AUTO')]#>
									<p>update software automatically at startup and at interval<sup>1</sup></p>
								</label>

        #set $hide_interval1 = not ($sg_var('UPDATE_NOTIFY') or $sg_var('UPDATE_AUTO'))
								<label class="nextline-block show-if-interval1" style="#if $hide_interval1#display:none;#end if#padding:6px 0">
									<input type="text" name="update_interval" value="$sg_var('UPDATE_INTERVAL', 12)" class="form-control input-sm input75">
									<p>hours interval<sup>1</sup> (default:$sg_var('DEFAULT_UPDATE_INTERVAL', 'n/a'))</p>
								</label>

								<label class="nextline-block show-if-interval1"#if $hide_interval1# style="display:none"#end if#>
									<input type="checkbox" name="notify_on_update"#echo ('', $checked)[$sg_var('NOTIFY_ON_UPDATE')]#>
									<p>send a message to all enabled notifiers when SickGear is updated</p>
								</label>
							</span>
						</div>
    #end if

						<div class="field-pair">
							<span class="component-title">Package updates</span>
							<span class="component-desc">
								<label class="nextline-block">
									<input type="checkbox" class="views-if-package-table views-if-interval2" name="update_packages_notify" #echo ('', $checked)[$sg_var('UPDATE_PACKAGES_NOTIFY')]#>
									<p>display message for outdated packages, run checks at startup and at interval<sup>2</sup></p>
								</label>

								<label class="nextline-block">
									<input type="checkbox" class="views-if-package-table views-if-interval2" name="update_packages_auto"#echo ('', $checked)[$sg_var('UPDATE_PACKAGES_AUTO')]#>
									<p>update packages automatically at startup and at interval<sup>2</sup></p>
								</label>

    #set $hide_interval2 = not ($sg_var('UPDATE_PACKAGES_NOTIFY') or $sg_var('UPDATE_PACKAGES_AUTO'))
								<label class="nextline-block show-if-interval2" style="#if $hide_interval2#display:none;#end if#padding:6px 0">
									<input type="text" name="update_packages_interval" value="$sg_var('UPDATE_PACKAGES_INTERVAL', 24)" class="form-control input-sm input75">
									<p>hours interval<sup>2</sup> (default:$sg_var('DEFAULT_UPDATE_PACKAGES_INTERVAL', 'n/a'))</p>
								</label>

								<label class="nextline-block">
									<input type="checkbox" class="views-if-package-table" name="update_packages_menu"#echo ('', $checked)[$sg_var('UPDATE_PACKAGES_MENU')]#>
									<p>include in 'Check for Updates' menu action</p>
								</label>
    #set $hide_package_tbl = not ($sg_var('UPDATE_PACKAGES_NOTIFY') or $sg_var('UPDATE_PACKAGES_AUTO') or $sg_var('UPDATE_PACKAGES_MENU'))
								<div class="show-if-package-table">
    #try
        #set $installed, $extra_info, $known_failed = $check_pip_env()
    #except
        #set $installed, $extra_info, $known_failed = ([], None, [])
    #end try

<style>
.extras{padding-top:10px}
.extras p{margin-bottom:3px}
.extras th{padding:0 2px}
.extras td{white-space:nowrap}
.extras .center{text-align:center}
.extras .package-col{width:135px;padding-left:0}
.extras .info-col{min-width:135px;padding-left:30px}
</style>
									<div class="extras">
										<table cellspacing="0" border="0" cellpadding="0">
											<thead>
												<tr class="grey-text">
													<th class="package-col">package (py #echo '.'.join('%s' % n for n in sys.version_info[0:3])#)</th>
													<th class="center">version in use</th>
													<th class="info-col">extra info</th>
												</tr>
											</thead>
											<tbody>
    #for $item in $installed
												<tr><td class="package-col">$item[0].lower()</td><td class="center">#echo $item[1] or '-'#</td><td class="info-col">#echo $sg_var('UPDATES_TODO', {}).get($item[0]) and 'update ready' or $extra_info.get($item[0], 'filled optional')#</td></tr>
    #end for
    #set $update_link = '<a href="%s/home/check-update">check update (clear failed)</a>' % $sbRoot
    #for $item in $known_failed
												<tr class="grey-text"><td>$item.lower()</td><td class="center">failed</td><td class="info-col">$update_link</td></tr>
        #set $update_link = ''
    #end for
											</tbody>
										</table>
										<p class="extras">the above info may help with packages that don't update internally<br>manual installation tip: <code>python -m pip install -U #echo $pip_user_arg#package</code></p>
									</div>
								</div>
							</span>
						</div>
#else
						<div class="field-pair">
							<span class="component-title">Built-in updates disabled</span>
							<span class="component-desc"><p>using #echo $sg_var('EXT_UPDATES') or 'other'# update method instead</p>
							</span>
						</div>
#end if

						<div class="field-pair">
							<span class="component-title">Alias show names/numbers</span>
							<span class="component-desc" style="line-height:20px">
								<input id="alias" class="btn btn-inline" type="button" value="Process">
								<p>updates for alternative show names and numbers</p>
								<span id="alias-result"></span>
							</span>
						</div>

#if not $sg_var('EXT_UPDATES')
						<input type="submit" class="btn config_submitter" value="Save Changes">
#end if
					</fieldset>

				</div>
				</div><!-- /component-group1 //-->


				<div id="core-component-group2">
				<div class="component-group">

					<div class="component-group-desc">
						<h3>User Interface</h3>
						<p>Options for visual appearance.</p>
					</div>

					<fieldset class="component-group-list">

						<div class="field-pair">
							<label for="theme_name">
								<span class="component-title">Display theme:</span>
								<span class="component-desc">
									<select id="theme_name" name="theme_name" class="form-control input-sm">
										<option value="dark"#echo ('', $selected)['dark' == $sg_str('THEME_NAME', 'dark')]#>Dark</option>
										<option value="light"#echo ('', $selected)['light' == $sg_str('THEME_NAME')]#>Light</option>
									</select>
									<span class="red-text">for appearance to take effect, save then refresh your browser</span>
								</span>
							</label>
						</div>

						<div class="field-pair">
							<label for="default_home">
								<span class="component-title">Use as default home page:</span>
								<span class="component-desc">
									<select id="default_home" name="default_home" class="form-control input-sm">
										<option value="shows"#echo ('', $selected)['shows' == $sg_str('DEFAULT_HOME')]#>Show List</option>
										<option value="episodes"#echo ('', $selected)['episodes' == $sg_str('DEFAULT_HOME')]#>Daily Sch.</option>
										<option value="history"#echo ('', $selected)['history' == $sg_str('DEFAULT_HOME')]#>History</option>
									</select>
								</span>
							</label>
						</div>

#if not hasattr($sickgear, 'FANART_LIMIT')#<span class="red-text">Restart SickGear to reveal new options here</span>#else#
						<div class="field-pair">
							<label for="fanart_limit">
								<span class="component-title">Maximum fanart image files</span>
								<span class="component-desc">
									<input type="text" name="fanart_limit" id="fanart_limit" value="$sg_var('FANART_LIMIT', 3)" class="form-control input-sm input75">
									<span>per show to cache (0 ... 500)</span>
								</span>
							</label>
						</div>
#end if
						<div class="field-pair">
							<label for="showlist_tagview">
								<span class="component-title">Group show list shows into:</span>
								<span class="component-desc">
									<select id="showlist_tagview" name="showlist_tagview" class="form-control input-sm">
										<option value="standard"#echo ('', $selected)['standard' == $sg_str('SHOWLIST_TAGVIEW', 'standard')]#>One Show List</option>
										<option value="anime"#echo ('', $selected)['anime' == $sg_str('SHOWLIST_TAGVIEW')]#>Show / Anime Lists</option>
										<option value="custom"#echo ('', $selected)['custom' == $sg_str('SHOWLIST_TAGVIEW')]#>Custom Lists</option>
									</select>
									#set $hidden = ' class="hidden"'
									<span id="showlist_tagview_standard"#echo ('', $hidden)['standard' not in $sg_str('SHOWLIST_TAGVIEW', 'standard')]#>that contains all shows (default)</span>
									<span id="showlist_tagview_anime"#echo ('', $hidden)['anime' not in $sg_str('SHOWLIST_TAGVIEW')]#>two groups, the show list and anime</span>
									<span id="showlist_tagview_custom"#echo ('', $hidden)['custom' not in $sg_str('SHOWLIST_TAGVIEW')]#>multiple custom<sup>1</sup> named groups and a "Show List"</span>
								</span>
							</label>
						</div>

						<div id="showlist_tagview_custom_config" class="field-pair#if $sg_str('SHOWLIST_TAGVIEW') != 'custom' then ' hidden' else ''#">
							<label for="show_tags">
								<span class="component-title">Group names for show list<sup>1</sup></span>
								<span class="component-desc">
									<input type="text" name="show_tags" id="show_tags" value="$show_tags" class="form-control input-sm input300">
									<span>comma separated names</span>
									<p class="clear-left note">group shows to the order of this custom list (add shows to groups with <a href="$sbRoot/manage/">mass edit</a>)</p>
								</span>
							</label>
						</div>

						<div class="field-pair">
							<label for="home_search_focus">
								<span class="component-title">Give show list search focus</span>
								<span class="component-desc">
									<input type="checkbox" name="home_search_focus" id="home_search_focus"#echo ('', $checked)[$sg_var('HOME_SEARCH_FOCUS', True)]#>
									<p>page refresh on "Show List" will start search box focused</p>
								</span>
							</label>
						</div>

						<div class="field-pair">
							<label for="use_imdb_info">
								<span class="component-title">Enable IMDb info</span>
								<span class="component-desc">
									<input type="checkbox" name="use_imdb_info" id="use_imdb_info"#echo ('', $checked)[$sg_var('USE_IMDB_INFO', True)]#>
									<p>for ui links, display show; ratings, country flag, year, runtime, and genre tags</p>
								</span>
							</label>
						</div>

						<div class="field-pair">
							<label for="imdb-accounts">
								<span class="component-title">Public IMDb watchlists:</span>
#if not hasattr($sickgear, 'IMDB_ACCOUNTS')#<span class="red-text">Restart SickGear to reveal new options here</span>#else#
								<span class="component-desc">
									<select id="imdb-accounts" class="pull-left form-control input-sm">
										<option value="new" selected="selected">Add watchlist ...</option>
    #for $i, $v in $enumerate($sg_str('IMDB_ACCOUNTS'))
        #if not $i % 2
            #set $id = $v
        #else
										<option value="$id">#echo '%s%s' % ($v, ('\'s', '')['your' == $v.replace('(Off) ', '').lower()])# list</option>
        #end if
    #end for
									</select>
									<input type="button" class="btn btn-inline" value="Delete" id="imdb-list-del" disabled="disabled" />
								</span>
							</label>
							<label for="imdb-url">
								<span class="component-title">&nbsp</span>
								<span class="component-desc">
									<input type="text" id="imdb-url" value="" class="form-control input-sm input250" />
									<input type="button" class="btn btn-inline" value="Enable" id="imdb-list-onoff" />
									<div class="clear-left">
									<p><code>imdb.com/user/ur64552276</code> or <code>ur64552276</code> to <span id="view-list">view list</span><a class="hide" id="link-list" href="$sbRoot/add-shows/watchlist-imdb?account=64552276">view list</a> at "Add from IMDb"
									</p></div>
#end if
								</span>
							</label>
						</div>

#if not hasattr($sickgear, 'DISPLAY_FREESPACE')#<span class="red-text">Restart SickGear to reveal new option here</span>#else#
						<div class="field-pair">
							<label for="display-freespace">
								<span class="component-title">Display freespace</span>
								<span class="component-desc">
									<input type="checkbox" name="display_freespace" id="display-freespace"#echo ('', $checked)[$sg_var('DISPLAY_FREESPACE', True)]#>
									<p>free space of parent locations is refreshed into any page footer request</p>
								</span>
							</label>
						</div>
#end if
						<div class="field-pair">
							<label for="sort_article">
								<span class="component-title">Sort with "The", "A", "An"</span>
								<span class="component-desc">
									<input type="checkbox" name="sort_article" id="sort_article"#echo ('', $checked)[$sg_var('SORT_ARTICLE')]#>
									<p>include articles ("The", "A", "An") when sorting show lists</p>
								</span>
							</label>
						</div>

#if not $SGDatetime.is_locale_eng()
						<input type="hidden" name="fuzzy_dating" id="fuzzy_dating" value="false">
						<input type="hidden" name="trim_zero" id="trim_zero" value="false">
#else
						<div class="field-pair">
							<label for="fuzzy_dating">
								<span class="component-title">Display fuzzy dates</span>
								<span class="component-desc">
									<input type="checkbox" name="fuzzy_dating" id="fuzzy_dating" class="view-if datePresets"#echo ('', $checked)[$sg_var('FUZZY_DATING') == True]#>
									<p>move absolute dates into tooltips and display e.g. "Last Thu", "On Tue"</p>
								</span>
							</label>
						</div>
						<div class="field-pair show-if-fuzzy_dating#echo (' metadataDiv', '')[$sg_var('FUZZY_DATING')]#">
							<label for="trim_zero">
								<span class="component-title">Trim date and time</span>
								<span class="component-desc">
									<input type="checkbox" name="trim_zero" id="trim_zero"#echo ('', $checked)[True == $sg_var('TRIM_ZERO')]#>
									<p>display minimalist date and time i.e. <del>02:00</del> = 2:00, <del>02:00pm</del> = 2pm, <del>03 Jan</del> = 3 Jan</p>
								</span>
							</label>
						</div>
#end if
						<div class="field-pair">
							<label for="date_presets">
								<span class="component-title">Date style:</span>
								<span class="component-desc">
									<select class="form-control input-sm#echo (' metadataDiv', '')[$sg_var('FUZZY_DATING')]#" id="date_presets#echo ('_na', '')[$sg_var('FUZZY_DATING')]#" name="date_preset#echo ('_na', '')[$sg_var('FUZZY_DATING')]#">
#for $cur_preset in $date_presets
										<option value="$cur_preset" #echo ('', $selected)[$cur_preset == $sg_str('DATE_PRESET', '%x') or ('%x' == $sg_str('DATE_PRESET', '%x') and '$cur_preset' == '%a, %b %d, %Y')]#>$datetime.datetime($datetime.datetime.now().year, 12, 31, 14, 30, 47).strftime($cur_preset)</option>
#end for
									</select>

									<select class="form-control input-sm#echo ('', ' metadataDiv')[$sg_var('FUZZY_DATING')]#" id="date_presets#echo ('', '_na')[$sg_var('FUZZY_DATING')]#" name="date_preset#echo ('', '_na')[$sg_var('FUZZY_DATING')]#">
										<option value="%x"#echo ('', $selected)['%x' == $sg_str('DATE_PRESET', '%x')]#>Use System Default</option>
#for $cur_preset in $date_presets
										<option value="$cur_preset"#echo ('', $selected)[$cur_preset == $sg_str('DATE_PRESET', '%x')]#>$datetime.datetime($datetime.datetime.now().year, 12, 31, 14, 30, 47).strftime($cur_preset)</option>
#end for
									</select>
								</span>
							</label>
						</div>

						<div class="field-pair">
							<label for="time_presets">
								<span class="component-title">Time style:</span>
								<span class="component-desc">
									<select id="time_presets" name="time_preset" class="form-control input-sm">
#for $cur_preset in $time_presets
    #set $show_seconds = not $sg_var('FUZZY_DATING')
										<option value="$cur_preset"#echo ('', $selected)[$cur_preset == $sg_str('TIME_PRESET_W_SECONDS', '%I:%M:%S %p')]#>$SGDatetime.now().sbftime(show_seconds=$show_seconds, t_preset=$cur_preset)</option>
#end for
									</select>
									<span id="trim_info_seconds"><b>note:</b> seconds are only shown on the History page</span>
								</span>
							</label>
						</div>

						<div class="field-pair">
							<span class="component-title">Timezone:</span>
							<span class="component-desc">
								<label for="local" class="space-right">
									<input type="radio" name="timezone_display" id="local" value="local"#echo ('', $checked)['local' == $sg_str('TIMEZONE_DISPLAY')]#>local
								</label>
								<label for="network">
									<input type="radio" name="timezone_display" id="network" value="network"#echo ('', $checked)['network' == $sg_str('TIMEZONE_DISPLAY', 'network')]#>network
								</label>
								<div class="clear-left"><p>display dates and times in either your timezone or the shows network timezone</p></div>
							</span>
						</div>

						<input type="submit" class="btn config_submitter" value="Save Changes">

					</fieldset>

				</div><!-- /User interface component-group -->

				<div class="component-group">

					<div class="component-group-desc">
						<h3>Web Interface</h3>
						<p>It is recommended that you enable a username and password to secure SickGear from being tampered with remotely.</p>
						<p><b>These options require a manual restart to take effect.</b></p>
					</div>

					<fieldset class="component-group-list">

						<div class="field-pair">
							<label for="web_username">
								<span class="component-title">Username</span>
								<span class="component-desc">
									<input type="text" name="web_username" id="web_username" value="$sg_str('WEB_USERNAME')" class="form-control input-sm input300">
									<p>blank for none</p>
								</span>
							</label>
						</div>

						<div class="field-pair">
							<label for="web_password">
								<span class="component-title">Password</span>
								<span class="component-desc">
									<input type="password" autocomplete="nope" name="web_password" id="web_password" value="#echo '*' * len($sg_str('WEB_PASSWORD'))#" class="form-control input-sm input300">
									<p>blank for none</p>
									<span class="clear-left">check autoProcessTV.cfg is set up for external apps to use post processing scripts</span>
								</span>
							</label>
						</div>

						<div class="field-pair">
							<label for="calendar_unprotected">
								<span class="component-title">Unprotected calendar</span>
								<span class="component-desc">
									<input type="checkbox" name="calendar_unprotected" id="calendar_unprotected"#echo ('', $checked)[$sg_var('CALENDAR_UNPROTECTED')]#>
									<p>permit subscribing to the calendar without username and password.
									Some services like Google Calendar will only work with <b class="boldest">no</b> authentication</p>
								</span>

							</label>
						</div>

						<div class="field-pair">
							<label for="use_api">
								<span class="component-title">API enable</span>
								<span class="component-desc">
									<input type="checkbox" name="use_api" class="enabler" id="use_api"#echo ('', $checked)[$sg_var('USE_API')]#>
									<p>permit the use of the SickGear (and legacy sickgear) API</p>
								</span>
							</label>
						</div>
						<div id="content_use_api">
							<div class="field-pair">
								<label for="api_key">
									<span class="component-title">API key</span>
									<span class="component-desc">
										<input id="app-name" type="text" placeholder="enter app name" class="form-control input-sm input150">
										<input id="generate-api-key" value="Generate" type="button" class="btn btn-inline">
										<span id="generate-result">&nbsp;</span>
										<p class="clear-left">apps using SickGear API calls gain full access, legacy sickgear endpoints are limited to thetvdb.com shows</p>
										<div id="api-keys" class="clear-left">
											<div class="new-key highlight-text" style="display:none"><span class="qr-btn"><a data-src="#qr-body" rel="" name="qr" title="API key QR code"><span class="glyphicon glyphicon-qrcode"></span></a></span><span class="api-key"></span><span class="app-name"></span><input value="Revoke" type="button" class="revoke btn btn-inline"></div>
											<div id="qr-body"></div>
#set $tip_addkeys = ''
#for $appname, $uid in $api_keys
    #if $appname and $uid
											<div class="grey-text"><span class="qr-btn"><a data-src="#qr-body" data-api-name="$appname" data-api-key="$uid" rel="qr" name="qr" title="API key QR code"><span class="glyphicon glyphicon-qrcode"></span></a></span><span class="api-key">$uid</span><span class="app-name">$appname</span><input value="Revoke" type="button" class="revoke btn btn-inline"></div>
        #set $tip_addkeys = ' style="display:none"'
    #end if
#end for
											<div id="tip-addkeys"$tip_addkeys>Keys used by 3rd party programs to access SickGear will list here when generated</div>
										</div>
									</span>
								</label>
							</div>
						</div>

						<div class="field-pair">
							<label for="web_port">
								<span class="component-title">HTTP port</span>
								<span class="component-desc">
									<input type="text" name="web_port" id="web_port" value="$sg_var('WEB_PORT', 8081)" class="form-control input-sm input100">
									<p>web port to access and browse SickGear (default:8081)</p>
								</span>
							</label>
						</div>

						<div class="field-pair">
							<label for="web_log">
								<span class="component-title">HTTP logs</span>
								<span class="component-desc">
									<input type="checkbox" name="web_log" id="web_log"#echo ('', $checked)[$sg_var('WEB_LOG')]#>
									<p>enable logs from the internal web server</p>
								</span>
							</label>
						</div>

						<div class="field-pair">
							<label for="enable_https">
								<span class="component-title">SSL enable</span>
								<span class="component-desc">
									<input type="checkbox" name="enable_https" class="enabler" id="enable_https"#echo ('', $checked)[$sg_var('ENABLE_HTTPS')]#>
									<p>use a HTTPS address to access the web interface</p>
								</span>
							</label>
						</div>
						<div id="content_enable_https">
							<div class="field-pair">
								<label for="https_cert">
									<span class="component-title">HTTPS certificate</span>
									<span class="component-desc">
										<input type="text" name="https_cert" id="https_cert" value="$sg_str('HTTPS_CERT')" class="form-control input-sm input300">
										<div class="clear-left"><p>file name or path to a <b class="boldest">server.crt</b> certificate file</p></div>
									</span>
								</label>
							</div>
							<div class="field-pair">
								<label for="https_key">
									<span class="component-title">HTTPS key</span>
									<span class="component-desc">
										<input type="text" name="https_key" id="https_key" value="$sg_str('HTTPS_KEY')" class="form-control input-sm input300">
										<div class="clear-left"><p>file name or path to a <b class="boldest">server.key</b> file</p></div>
									</span>
								</label>
							</div>
						</div>

						<div class="field-pair">
							<label for="web_ipv6">
								<span class="component-title">Listen on IPv6</span>
								<span class="component-desc">
									<input type="checkbox" name="web_ipv6" id="web_ipv6" class="enabler"#echo ('', $checked)[$sg_var('WEB_IPV6')]#>
									<p>attempt binding to any available IPv6 address</p>
								</span>
							</label>
						</div>
						<div id="content_web_ipv6">
							<div class="field-pair" style="margin-top:-24px">
								<label for="web_ipv64">
									<span class="component-desc">
										<input type="checkbox" name="web_ipv64" id="web_ipv64"#echo ('', $checked)[$sg_var('WEB_IPV64')]#>
										<p>also listen on IPv4</p>
									</span>
								</label>
							</div>
						</div>

						<div class="field-pair">
							<label for="handle_reverse_proxy">
								<span class="component-title">Reverse proxy headers</span>
								<span class="component-desc">
									<input type="checkbox" name="handle_reverse_proxy" id="handle_reverse_proxy"#echo ('', $checked)[$sg_var('HANDLE_REVERSE_PROXY')]#>
									<p>accept the following reverse proxy headers (advanced)...<br />(X-Forwarded-For, X-Forwarded-Host, and X-Forwarded-Proto)</p>
								</span>
							</label>
						</div>

						<div class="field-pair">
							<label for="send_security_headers">
								<span class="component-title">Send security headers</span>
								<span class="component-desc">
									<input type="checkbox" name="send_security_headers" id="send_security_headers"#echo ('', $checked)[$sg_var('SEND_SECURITY_HEADERS')]#>
									<p>send the following headers to increase browser security...<br />(X-Frame-Options:SAMEORIGIN)</p>
								</span>
							</label>
						</div>

						<div class="field-pair">
							<label for="allow_anyip">
								<span class="component-title">Allow IP use for connections</span>
								<span class="component-desc">
									<input type="checkbox" name="allow_anyip" id="allow_anyip"#echo ('', $checked)[$sg_var('ALLOW_ANYIP')]#>
									<p>disable to only accept "Allowed browser hostnames" for connections<br>
									Warning: Kodi Add-on requires IP and will correctly fail with this disabled</p>
								</span>
							</label>
						</div>

						<div class="field-pair">
							<label for="allowed_hosts">
								<span class="component-title">Allowed browser hostnames</span>
								<span class="component-desc">
									<input type="text" name="allowed_hosts" id="allowed-hosts" value="$sg_str('ALLOWED_HOSTS')" class="form-control input-sm input300">
									<p>blank for insecure allow all</p>
									<div class="clear-left"><p>allowed names that browse the interface (e.g. $request_host, my_hostname)</p></div>
								</span>
							</label>
						</div>

						<input type="submit" class="btn config_submitter" value="Save Changes">

					</fieldset>

				</div><!-- /component-group2 //-->
				</div>


				<div id="core-component-group3" class="component-group">

					<div class="component-group-desc">
						<h3>Advanced</h3>

					</div>

					<fieldset class="component-group-list">

#if not $sg_var('EXT_UPDATES')
						<div class="field-pair">
							<label>
								<span class="component-title">Branch version:</span>
								<span class="component-desc">
									<select id="branchVersion" class="form-control form-control-inline input-sm pull-left max300">
										<option>Loading list from github</option>
									</select>
									<input class="btn btn-inline" style="margin-left:6px" type="button" id="branch-checkout" value="Checkout Branch" disabled="disabled">
									<div class="clear-left"><p>select branch to use (restart required)</p></div>
								</span>
							</label>
						</div>

#if $sg_str('BRANCH', 'main') != 'main'
							<div class="field-pair">
								<label>
									<span class="component-title">Pull request:</span>
									<span class="component-desc">
										<select id="pullRequestVersion" class="form-control form-control-inline input-sm pull-left max300">
											<option>Loading list from github</option>
										</select>
										<input class="btn btn-inline" style="margin-left: 6px;" type="button" id="pull-request-checkout" value="Checkout Pull Request" disabled="disabled">
										<div class="clear-left"><p>select pull request to test (restart required)</p></div>
									</span>
								</label>
							</div>
#end if

						<div class="field-pair">
							<label for="git_remote">
								<span class="component-title">Git remote for branch</span>
								<span class="component-desc">
									<input type="text" name="git_remote" id="git_remote" value="$sg_str('GIT_REMOTE')" class="form-control input-sm input300">
									<div class="clear-left"><p>default:origin. Access repo configured remotes (save then refresh browser)</p></div>
								</span>
							</label>
						</div>

						<div class="field-pair">
							<label>
								<span class="component-title">Git executable path</span>
								<span class="component-desc">
									<input type="text" name="git_path" value="$sg_str('GIT_PATH')" class="form-control input-sm input300">
									<div class="clear-left"><p>only needed if OS is unable to locate git from env</p></div>
								</span>
							</label>
						</div>
#end if

						<div class="field-pair">
							<label>
								<span class="component-title">CPU throttling:</span>
								<span class="component-desc">
									<select id="cpu_presets" name="cpu_preset" class="form-control input-sm">
#for $cur_preset in $sorted($cpu_presets.items(), key=$operator.itemgetter(1), reverse=True)
										<option value="$cur_preset[0]"#echo ('', $selected)[$cur_preset[0] == $sg_str('CPU_PRESET', 'DISABLED')]#>$cur_preset[0].capitalize()</option>
#end for
									</select>
									<span>Disabled (default). High is lower and Low is higher CPU use</span>
								</span>
							</label>
						</div>

						<div class="field-pair">
							<label>
								<span class="component-title">Anonymous redirect</span>
								<span class="component-desc">
									<input type="text" name="anon_redirect" value="$sg_str('ANON_REDIRECT')" class="form-control input-sm input300">
									<div class="clear-left"><p>backlink protection via anonymizer service, must end in "?"</p></div>
								</span>
							</label>
						</div>

						<div class="field-pair">
							<label for="encryption_version">
								<span class="component-title">Encrypt passwords</span>
								<span class="component-desc">
									<input type="checkbox" name="encryption_version" id="encryption_version"#echo ('', $checked)[$sg_var('ENCRYPTION_VERSION')]#>
									<p>in the <code>config.ini</code> file.
									<b>Warning:</b> Passwords must only contain <a target="_blank" href="<%= anon_url('http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters') %>">ASCII characters</a></p>
								</span>
							</label>
						</div>

						<div class="field-pair">
							<label>
								<span class="component-title">Proxy host</span>
								<span class="component-desc">
									<input type="text" name="proxy_setting" value="$sg_str('PROXY_SETTING')" class="form-control input-sm input300">
									<p>blank to disable</p>
									<div class="clear-left"><p>proxy address for connecting to providers (use 'PAC:Url' for PAC support)<br>
									e.g. socks5://host:port, socks5://user:pass@host:port, socks4a://user:pass@host:port</p></div>
								</span>
							</label>
						</div>

						<div class="field-pair">
							<label for="proxy_indexers">
								<span class="component-title">Use proxy for indexers</span>
								<span class="component-desc">
									<input type="checkbox" name="proxy_indexers" id="proxy_indexers"#echo ('', $checked)[True == $sg_var('PROXY_INDEXERS')]#>
									<p>use proxy host for TV info source connections</p>
								</span>
							</label>
						</div>

						<div class="field-pair">
							<label>
								<span class="component-title">File logging level:</span>
								<span class="component-desc">
									<select id="file_logging_presets" name="file_logging_preset" class="form-control input-sm">
#set $levels = $list(file_logging_presets)
#set void = $levels.sort(key=lambda x: $file_logging_presets[$x])
#set $level_count = len($levels)
#for $level in $levels
    #set $level_title = $level.title().upper()
    #set $level_count -= 1
    #if 'DB' == $level_title
        #continue
    #end if
    #set $level_text = '%s%s' % ($level.title(), (('', ' only')[0 == $level_count], ' and the next%s level%s' % ((' ' + str($level_count), '')[1 == $level_count], maybe_plural($level_count)))[0 < $level_count])
										<option value="$level_title"#echo ('', $selected)[$level_title == $sg_str('FILE_LOGGING_PRESET', 'DB')]#>$level_text</option>
#end for
									</select>
									<span>(default: Debug)</span>
									<p>enable Debug to pin down an issue, the others are for light use</p>
								</span>
							</label>
						</div>
#if $db_supports_backup
						<div class="field-pair">
							<label for="backup_db_oneday">
								<span class="component-title">Backup database plan</span>
								<span class="component-desc">
									<input type="checkbox" name="backup_db_oneday" id="backup_db_oneday"#echo ('', $checked)[True == $sg_var('BACKUP_DB_ONEDAY')]#>
									<p>backup one day instead of multiple days (helps existing backup strategies)</p>
								</span>
							</label>
						</div>
#end if

						<input type="submit" class="btn config_submitter" value="Save Changes">
					</fieldset>
				</div><!-- /component-group3 //-->

				<br/>
				<h6 class="pull-right"><b>All non-absolute folder locations are relative to <span class="path">$sg_str('DATA_DIR')</span></b></h6>
				<input type="submit" class="btn pull-left config_submitter button" value="Save Changes">

			</div><!-- /config-components -->

		</form>
	</div>
</div>

<div></div>

<script type="text/javascript" charset="utf-8">
<!--
	jQuery('#log_dir').fileBrowser({ title: 'Select log file folder location' });
	jQuery('#config-components').tabs();
//-->
</script>

#include $os.path.join($sg_str('PROG_DIR'), 'gui/slick/interfaces/default/inc_bottom.tmpl')