Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mass refactor tv.py #8706

Merged
merged 31 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
83e529a
refactor: lowercase and typo function, parameter, and variable names …
miigotu Feb 3, 2024
a3055a7
fix: use property decorators instead of accessors to avoid type check…
miigotu Feb 3, 2024
e36b6fb
black
miigotu Feb 3, 2024
8a67418
chore: update release workflow
miigotu Feb 3, 2024
89546f4
refactor: missed changes
miigotu Feb 3, 2024
6989d8c
additional time error capture
BKSteve Feb 3, 2024
7ba09ac
refactor: more renaming and fixing types
miigotu Feb 3, 2024
0bcd73f
fix: can't add init to tornado base class? causes PageTemplate initia…
miigotu Feb 3, 2024
6850259
fix: try to fix airdate modify timestamp, remove some unneded mako co…
miigotu Feb 4, 2024
846aa4a
chore:black formatting
miigotu Feb 4, 2024
754e34f
air date tm_isdst
BKSteve Feb 4, 2024
c20da34
air date tm_isdst clean
BKSteve Feb 4, 2024
ae3e0ff
Merge branch 'develop' into wtf-is-wrong-with-me-lol
miigotu Feb 6, 2024
cb4c31b
backlog page variables - log reduction
BKSteve Feb 11, 2024
2a6deff
backlog page variables lowercase 2
BKSteve Feb 11, 2024
4735005
trending add - redirectable
BKSteve Feb 11, 2024
9614388
searchBacklog needs int
BKSteve Feb 11, 2024
0ac7c4c
subtitles remove legendastv
BKSteve Feb 11, 2024
7b58831
add shows redirect allowed
BKSteve Feb 12, 2024
18c4a7d
regex single char alternation - Qodana
BKSteve Feb 12, 2024
b44dc29
docstring parameters - Qodana
BKSteve Feb 12, 2024
6340a58
fstring logs
BKSteve Feb 12, 2024
212444f
fstring logs 2
BKSteve Feb 12, 2024
dacdd68
wordle
BKSteve Feb 12, 2024
140482a
remove show get*
BKSteve Feb 12, 2024
8e44069
snaking vars
BKSteve Feb 12, 2024
735ea0a
home unused var removal
BKSteve Feb 12, 2024
0fb6c6b
t.render layout
BKSteve Feb 12, 2024
bae210c
Failed download + params
BKSteve Feb 12, 2024
a6ed3a4
revert (_(f
BKSteve Feb 12, 2024
b96ea86
Merge branch 'develop' into wtf-is-wrong-with-me-lol
miigotu Feb 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
# and trailing whitespace removed
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

# Matches multiple files with brace expansion notation
# Set default charset
[*.{py,mako}]
charset = utf-8
indent_style = space
Expand All @@ -20,12 +15,9 @@ charset = utf-8
indent_style = space
indent_size = 4

# Matches configuration files for services like Travis, AppVeyor and Codecov
[*.yml]
indent_style = space
indent_size = 2

[{package.json, bower.json, webpack.config.js}]
charset = utf-8
indent_style = space
[{package.json,bower.json,webpack.config.js}]
indent_size = 2
miigotu marked this conversation as resolved.
Show resolved Hide resolved
8 changes: 3 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ name: Build develop branch

on:
workflow_run:
workflows: [Python Packaging]
branches: |
- develop
types:
- completed
workflows: [ Python Packaging ]
branches: [ develop ]
types: [ completed, requested ]

jobs:
version:
Comment on lines 2 to 10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [21-21]

Using cache: 'yarn' with actions/setup-node@v4 while running npm install -g yarn seems redundant. If Yarn is being used, consider removing the npm install -g yarn command or clarify the necessity of this approach.

Expand Down
11 changes: 6 additions & 5 deletions SickChill.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3

import datetime
import mimetypes
import os
import platform
import shutil
Expand Down Expand Up @@ -28,14 +29,12 @@

setup_gettext()

import mimetypes

mimetypes.add_type("text/css", ".css")
mimetypes.add_type("application/sfont", ".otf")
mimetypes.add_type("application/sfont", ".ttf")
mimetypes.add_type("application/javascript", ".js")
mimetypes.add_type("application/font-woff", ".woff")
# Not sure about this one, but we also have halflings in .woff so I think it wont matter
# Not sure about this one, but we also have halflings in .woff, so I think it won't matter
# mimetypes.add_type("application/font-woff2", ".woff2")

from configobj import ConfigObj
Expand Down Expand Up @@ -67,6 +66,8 @@ def __init__(self):
self.run_as_daemon = False

# web server constants
self.flask_server = None

self.web_server = None
self.forced_port = None
self.no_launch = False
Expand Down Expand Up @@ -253,7 +254,7 @@ def load_shows_from_db():
for sql_show in sql_results:
try:
cur_show = TVShow(sql_show["indexer"], sql_show["indexer_id"])
cur_show.nextEpisode()
cur_show.next_episode()
settings.showList.append(cur_show)
except Exception as error:
logger.exception("There was an error creating the show in {}: Error {}".format(sql_show["location"], error))
Expand Down Expand Up @@ -301,7 +302,7 @@ def shutdown(self, event):
"""
if settings.started:
sickchill.start.halt() # stop all tasks
sickchill.start.saveAll() # save all shows to DB
sickchill.start.save_all() # save all shows to DB

# shutdown web server
if self.web_server:
Expand Down
68 changes: 34 additions & 34 deletions sickchill/gui/slick/views/config_providers.mako

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions sickchill/gui/slick/views/displayShow.mako
Original file line number Diff line number Diff line change
Expand Up @@ -404,9 +404,9 @@
(season_number, episode_number) = (default_season, default_episode)
default_episode_numbering = True

epLoc = epResult["location"]
if epLoc and show._location and epLoc.lower().startswith(show._location.lower()):
epLoc = epLoc[len(show._location)+1:]
episode_location = epResult["location"]
if episode_location and show.get_location and episode_location.lower().startswith(show.get_location.lower()):
episode_location = episode_location[len(show.get_location)+1:]
%>
% if int(epResult["season"]) != curSeason:
% if epResult["season"] != sql_results[0]["season"]:
Expand Down Expand Up @@ -485,8 +485,8 @@
<td class="text-center episode">
<%
text = str(epResult['episode'])
if epLoc:
text = '<span title="' + epLoc + '" class="addQTip">' + text + "</span>"
if episode_location:
text = '<span title="' + episode_location + '" class="addQTip">' + text + "</span>"
Comment on lines +488 to +489
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable episode_location is used within an HTML attribute without proper escaping, potentially leading to Cross-Site Scripting (XSS) vulnerabilities. Ensure to escape episode_location before embedding it into the HTML.

%>
${text}
</td>
Expand Down Expand Up @@ -523,7 +523,7 @@
% endif
${epResult["name"]}
</td>
<td class="col-name location">${epLoc}</td>
<td class="col-name location">${episode_location}</td>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The display of episode_location directly in the HTML could lead to Cross-Site Scripting (XSS) vulnerabilities if the variable contains untrusted data. Ensure episode_location is properly sanitized or escaped before being rendered.

<td class="col-ep size">
% if epResult["file_size"]:
${pretty_file_size(epResult["file_size"])}
Expand Down
2 changes: 1 addition & 1 deletion sickchill/gui/slick/views/editShow.mako
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
</div>
<div class="col-lg-9 col-md-8 col-sm-7 col-xs-12 component-desc">
<input type="hidden" name="show" id="showID" value="${show.indexerid}" />
<input type="text" name="location" id="location" value="${show._location}"
<input type="text" name="location" id="location" value="${show.get_location}"
class="form-control input-sm input350"
autocapitalize="off" title="Location" />
</div>
Expand Down
42 changes: 21 additions & 21 deletions sickchill/gui/slick/views/layouts/main.mako
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,19 @@
<nav class="navbar navbar-default navbar-fixed-top hidden-print">
<div class="container-fluid">
<%
numCombined = numErrors + numWarnings + settings.NEWS_UNREAD
if numCombined:
if numErrors:
total_warning_error_count = error_count + warning_count + settings.NEWS_UNREAD
if total_warning_error_count:
if error_count:
toolsBadgeClass = ' btn-danger'
elif numWarnings:
elif warning_count:
toolsBadgeClass = ' btn-warning'
else:
toolsBadgeClass = ''
%>
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#collapsible-navbar">
% if numCombined:
<span class="floating-badge${ toolsBadgeClass }">${ str(numCombined) }</span>
% if total_warning_error_count:
<span class="floating-badge${ toolsBadgeClass }">${ str(total_warning_error_count) }</span>
% endif
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
Expand All @@ -142,7 +142,7 @@
<a class="navbar-brand" href="${static_url('home/', include_version=False)}" title="SickChill"><img alt="SickChill" src="${static_url('images/sickchill.png')}"
class="img-responsive pull-left" /></a>
</div>
% if scLogin:
% if current_user:
<div class="collapse navbar-collapse" id="collapsible-navbar">
<ul class="nav navbar-nav navbar-right">
<%block name="navbar" />
Expand Down Expand Up @@ -243,8 +243,8 @@
else:
newsBadge = ''

if numCombined:
toolsBadge = ' <span class="badge'+toolsBadgeClass+'">'+str(numCombined)+'</span>'
if total_warning_error_count:
toolsBadge = ' <span class="badge'+toolsBadgeClass+'">'+str(total_warning_error_count)+'</span>'
else:
toolsBadge = ''
%>
Expand All @@ -260,26 +260,26 @@
<li><a href="${static_url('changes/', include_version=False)}"><i class="fa fa-fw fa-globe"></i>&nbsp;${_('Changelog')}</a></li>
<li><a href="${anon_url('https://github.com/SickChill/SickChill/wiki/Donations')}" rel="noreferrer" target="_blank"><i class="fa fa-fw fa-life-ring"></i>&nbsp;${_('Support SickChill')}</a></li>
<li role="separator" class="divider"></li>
%if numErrors:
<li><a href="${static_url('errorlogs/', include_version=False)}"><i class="fa fa-fw fa-exclamation-circle"></i>&nbsp;${_('View Errors')} <span class="badge btn-danger">${numErrors}</span></a></li>
%if error_count:
<li><a href="${static_url('errorlogs/', include_version=False)}"><i class="fa fa-fw fa-exclamation-circle"></i>&nbsp;${_('View Errors')} <span class="badge btn-danger">${error_count}</span></a></li>
%endif
%if numWarnings:
%if warning_count:
<li>
<a href="${static_url('errorlogs/?level={}'.format(logger.WARNING), include_version=False)}">
<i class="fa fa-fw fa-exclamation-triangle"></i>&nbsp;${_('View Warnings')} <span class="badge btn-warning">${numWarnings}</span>
<i class="fa fa-fw fa-exclamation-triangle"></i>&nbsp;${_('View Warnings')} <span class="badge btn-warning">${warning_count}</span>
</a>
</li>
%endif
<li><a href="${static_url('errorlogs/viewlog/', include_version=False)}"><i class="fa fa-fw fa-file-text-o"></i>&nbsp;${_('View Log')}</a></li>
<li role="separator" class="divider"></li>
% if hasattr(settings, "DISABLE_UPDATER") and not settings.DISABLE_UPDATER:
<li><a href="${static_url('home/updateCheck?pid={}'.format(scPID), include_version=False)}"><i class="fa fa-fw fa-wrench"></i>&nbsp;${_('Check For Updates')}</a></li>
<li><a href="${static_url('home/updateCheck?pid={}'.format(process_id), include_version=False)}"><i class="fa fa-fw fa-wrench"></i>&nbsp;${_('Check For Updates')}</a></li>
% endif
<li><a href="${static_url('home/restart/?pid={}'.format(scPID), include_version=False)}" class="confirm restart"><i
<li><a href="${static_url('home/restart/?pid={}'.format(process_id), include_version=False)}" class="confirm restart"><i
class="fa fa-fw fa-repeat"></i>&nbsp;${_('Restart')}</a></li>
<li><a href="${static_url('home/shutdown/?pid={}'.format(scPID), include_version=False)}" class="confirm shutdown"><i
<li><a href="${static_url('home/shutdown/?pid={}'.format(process_id), include_version=False)}" class="confirm shutdown"><i
class="fa fa-fw fa-power-off"></i>&nbsp;${_('Shutdown')}</a></li>
% if scLogin:
% if current_user:
<li><a href="${static_url('logout', include_version=False)}" class="confirm logout"><i class="fa fa-fw fa-sign-out"></i>&nbsp;${_('Logout')}</a></li>
% endif
<li role="separator" class="divider"></li>
Expand Down Expand Up @@ -320,7 +320,7 @@
</div>
% endif
<div class="clearfix"></div>
% if scLogin:
% if current_user:
<div id="site-messages"></div>
% endif
</div>
Expand Down Expand Up @@ -349,7 +349,7 @@
</div>
</div>

% if scLogin:
% if current_user:
<div class="row">
<div class="footer clearfix col-lg-10 col-lg-offset-1 col-md-10 col-md-offset-1 col-sm-12 col-xs-12">
<%
Expand Down Expand Up @@ -382,8 +382,8 @@
% if resource:
<span class="footer-item">${_('Memory used')}: <span class="footerhighlight">${pretty_file_size(resource.getrusage(resource.RUSAGE_SELF).ru_maxrss*1024)}</span></span> |
% endif
<span class="footer-item">${_('Load time')}: <span class="footerhighlight">${"{:.4f}".format(time() - sbStartTime)}s</span></span> |
<span class="footer-item">Mako: <span class="footerhighlight">${"{:.4f}".format(time() - makoStartTime)}s</span></span> |
<span class="footer-item">${_('Load time')}: <span class="footerhighlight">${"{:.4f}".format(time() - page_load_start_time)}s</span></span> |
<span class="footer-item">Mako: <span class="footerhighlight">${"{:.4f}".format(time() - mako_load_start_time)}s</span></span> |
<span class="footer-item">${_('Version')}: <span class="footerhighlight">${get_current_version()}</span></span> |
<span class="footer-item">${_('Now')}: <span class="footerhighlight">${datetime.datetime.now().strftime(settings.DATE_PRESET+" "+settings.TIME_PRESET)}</span></span>
</div>
Expand Down
2 changes: 1 addition & 1 deletion sickchill/gui/slick/views/manage.mako
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
<td class="text-center">${statusStrings[curShow.default_ep_status]}</td>
<td class="text-center">${_(curShow.status)}</td>

<td class="text-center">${curShow._location.rsplit('\\', 1)[0]}</td>
<td class="text-center">${curShow.get_location.rsplit('\\', 1)[0]}</td>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use of get_location method without error handling or checking if the method exists.

<td class="text-center">
<% disabled = settings.showQueueScheduler.action.is_being_updated(curShow) or settings.showQueueScheduler.action.is_in_update_queue(curShow) %>
<label for="update-${curShow.indexerid}" class="sr-only">${_('Update')} ${curShow.name}</label>
Expand Down
38 changes: 19 additions & 19 deletions sickchill/gui/slick/views/manage_backlogOverview.mako
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
<div class="row">
<div class="col-lg-8 col-md-7 col-sm-6 col-xs-12 pull-right">
<div class="pull-right">
% if totalWanted > 0:
<span class="listing-key wanted">${_('Wanted')}: <b>${totalWanted}</b></span>
% if total_wanted > 0:
<span class="listing-key wanted">${_('Wanted')}: <b>${total_wanted}</b></span>
% endif

% if totalQualSnatched > 0:
<span class="listing-key snatched">${_('Snatched (Allowed)')}: <b>${totalQualSnatched}</b></span>
% if total_qual_snatched > 0:
<span class="listing-key snatched">${_('Snatched (Allowed)')}: <b>${total_qual_snatched}</b></span>
% endif

% if totalQual > 0:
<span class="listing-key qual">${_('Allowed')}: <b>${totalQual}</b></span>
% if total_qual > 0:
<span class="listing-key qual">${_('Allowed')}: <b>${total_qual}</b></span>
% endif
</div>
</div>
Expand All @@ -35,31 +35,31 @@
<div class="col-md-12">
<label for="pickShow">${_('Jump to Show')}:</label>
<select id="pickShow" class="form-control form-control-inline input-sm">
% for curShow in backLogShows:
% for curShow in backlog_shows:
<option value="${curShow.indexerid}">${curShow.name}</option>
% endfor
</select>
</div>
</div>

% for curShow in backLogShows:
% if not showQualSnatched(curShow) and not showCounts[curShow.indexerid][Overview.WANTED] + showCounts[curShow.indexerid][Overview.QUAL]:
% for curShow in backlog_shows:
% if not show_qual_snatched(curShow) and not show_counts[curShow.indexerid][Overview.WANTED] + show_counts[curShow.indexerid][Overview.QUAL]:
<% continue %>
% endif

<div class="row">
<div class="col-md-12">
<div class="pull-right" style="margin-top: 30px;">
% if showCounts[curShow.indexerid][Overview.WANTED] > 0:
<span class="listing-key wanted">${_('Wanted')}: <b>${showCounts[curShow.indexerid][Overview.WANTED]}</b></span>
% if show_counts[curShow.indexerid][Overview.WANTED] > 0:
<span class="listing-key wanted">${_('Wanted')}: <b>${show_counts[curShow.indexerid][Overview.WANTED]}</b></span>
% endif

% if showQualSnatched(curShow) and showCounts[curShow.indexerid][Overview.SNATCHED] > 0:
<span class="listing-key snatched">${_('Snatched (Allowed)')}: <b>${showCounts[curShow.indexerid][Overview.SNATCHED]}</b></span>
% if show_qual_snatched(curShow) and show_counts[curShow.indexerid][Overview.SNATCHED] > 0:
<span class="listing-key snatched">${_('Snatched (Allowed)')}: <b>${show_counts[curShow.indexerid][Overview.SNATCHED]}</b></span>
% endif

% if showCounts[curShow.indexerid][Overview.QUAL] > 0:
<span class="listing-key qual">${_('Allowed')}: <b>${showCounts[curShow.indexerid][Overview.QUAL]}</b></span>
% if show_counts[curShow.indexerid][Overview.QUAL] > 0:
<span class="listing-key qual">${_('Allowed')}: <b>${show_counts[curShow.indexerid][Overview.QUAL]}</b></span>
% endif

<a class="btn btn-inline forceBacklog" href="${scRoot}/manage/backlogShow?indexer_id=${curShow.indexerid}"><i class="icon-play-circle icon-white"></i> ${_('Force Backlog')}</a>
Expand All @@ -79,16 +79,16 @@
</tr>
<tr class="seasoncols"><th>${_('Episode')}</th><th>${_('Name')}</th><th class="nowrap">${_('Airdate')}</th></tr>

% for curResult in showSQLResults[curShow.indexerid]:
% for curResult in show_sql_results[curShow.indexerid]:
<%
whichStr = episode_num(curResult['season'], curResult['episode']) or episode_num(curResult['season'], curResult['episode'], numbering='absolute')
if whichStr not in showCats[curShow.indexerid] or showCats[curShow.indexerid][whichStr] not in (Overview.QUAL, Overview.WANTED, Overview.SNATCHED):
if whichStr not in show_categories[curShow.indexerid] or show_categories[curShow.indexerid][whichStr] not in (Overview.QUAL, Overview.WANTED, Overview.SNATCHED):
continue

if not showQualSnatched(curShow) and showCats[curShow.indexerid][whichStr] == Overview.SNATCHED:
if not show_qual_snatched(curShow) and show_categories[curShow.indexerid][whichStr] == Overview.SNATCHED:
continue
%>
<tr class="seasonstyle ${Overview.overviewStrings[showCats[curShow.indexerid][whichStr]]}">
<tr class="seasonstyle ${Overview.overviewStrings[show_categories[curShow.indexerid][whichStr]]}">
<td class="tableleft text-center">${whichStr}</td>
<td class="tableright text-center nowrap">
${curResult["name"]}
Expand Down
Loading
Loading