2014-03-10 01:18:05 -04:00
|
|
|
# Author: Nic Wolfe <nic@wolfeden.ca>
|
|
|
|
# URL: http://code.google.com/p/sickbeard/
|
|
|
|
#
|
2014-05-23 08:37:22 -04:00
|
|
|
# This file is part of SickRage.
|
2014-03-10 01:18:05 -04:00
|
|
|
#
|
2014-05-23 08:37:22 -04:00
|
|
|
# SickRage is free software: you can redistribute it and/or modify
|
2014-03-10 01:18:05 -04:00
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
2014-05-23 08:37:22 -04:00
|
|
|
# SickRage is distributed in the hope that it will be useful,
|
2014-03-10 01:18:05 -04:00
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
2014-05-23 08:37:22 -04:00
|
|
|
# along with SickRage. If not, see <http://www.gnu.org/licenses/>.
|
2014-03-10 01:18:05 -04:00
|
|
|
|
|
|
|
import db
|
|
|
|
import datetime
|
|
|
|
|
2014-03-25 01:57:24 -04:00
|
|
|
from sickbeard.common import SNATCHED, SUBTITLED, FAILED, Quality
|
2014-03-10 01:18:05 -04:00
|
|
|
|
|
|
|
|
|
|
|
dateFormat = "%Y%m%d%H%M%S"
|
|
|
|
|
|
|
|
|
2014-07-22 00:53:32 -04:00
|
|
|
def _logHistoryItem(action, showid, season, episode, quality, resource, provider, version=-1):
|
2014-03-10 01:18:05 -04:00
|
|
|
logDate = datetime.datetime.today().strftime(dateFormat)
|
|
|
|
|
|
|
|
if not isinstance(resource, unicode):
|
2014-07-14 22:00:53 -04:00
|
|
|
resource = unicode(resource, 'utf-8', 'replace')
|
2014-03-10 01:18:05 -04:00
|
|
|
|
2014-06-21 18:46:59 -04:00
|
|
|
myDB = db.DBConnection()
|
|
|
|
myDB.action(
|
2014-07-22 00:53:32 -04:00
|
|
|
"INSERT INTO history (action, date, showid, season, episode, quality, resource, provider, version) VALUES (?,?,?,?,?,?,?,?,?)",
|
|
|
|
[action, logDate, showid, season, episode, quality, resource, provider, version])
|
2014-03-10 01:18:05 -04:00
|
|
|
|
|
|
|
|
|
|
|
def logSnatch(searchResult):
|
|
|
|
for curEpObj in searchResult.episodes:
|
|
|
|
|
|
|
|
showid = int(curEpObj.show.indexerid)
|
|
|
|
season = int(curEpObj.season)
|
|
|
|
episode = int(curEpObj.episode)
|
|
|
|
quality = searchResult.quality
|
2014-07-22 00:53:32 -04:00
|
|
|
version = searchResult.version
|
2014-03-10 01:18:05 -04:00
|
|
|
|
|
|
|
providerClass = searchResult.provider
|
2014-03-20 14:03:22 -04:00
|
|
|
if providerClass != None:
|
2014-03-10 01:18:05 -04:00
|
|
|
provider = providerClass.name
|
|
|
|
else:
|
|
|
|
provider = "unknown"
|
|
|
|
|
|
|
|
action = Quality.compositeStatus(SNATCHED, searchResult.quality)
|
|
|
|
|
|
|
|
resource = searchResult.name
|
|
|
|
|
2014-07-22 00:53:32 -04:00
|
|
|
_logHistoryItem(action, showid, season, episode, quality, resource, provider, version)
|
2014-03-10 01:18:05 -04:00
|
|
|
|
|
|
|
|
2014-07-22 00:53:32 -04:00
|
|
|
def logDownload(episode, filename, new_ep_quality, release_group=None, version=-1):
|
2014-03-10 01:18:05 -04:00
|
|
|
showid = int(episode.show.indexerid)
|
|
|
|
season = int(episode.season)
|
|
|
|
epNum = int(episode.episode)
|
|
|
|
|
|
|
|
quality = new_ep_quality
|
2014-03-25 01:57:24 -04:00
|
|
|
|
2014-03-10 01:18:05 -04:00
|
|
|
# store the release group as the provider if possible
|
|
|
|
if release_group:
|
|
|
|
provider = release_group
|
|
|
|
else:
|
|
|
|
provider = -1
|
|
|
|
|
|
|
|
action = episode.status
|
|
|
|
|
2014-07-22 00:53:32 -04:00
|
|
|
_logHistoryItem(action, showid, season, epNum, quality, filename, provider, version)
|
2014-03-10 01:18:05 -04:00
|
|
|
|
2014-03-25 01:57:24 -04:00
|
|
|
|
2014-03-10 01:18:05 -04:00
|
|
|
def logSubtitle(showid, season, episode, status, subtitleResult):
|
|
|
|
resource = subtitleResult.path
|
|
|
|
provider = subtitleResult.service
|
2014-03-25 01:57:24 -04:00
|
|
|
status, quality = Quality.splitCompositeStatus(status)
|
2014-03-10 01:18:05 -04:00
|
|
|
action = Quality.compositeStatus(SUBTITLED, quality)
|
2014-03-25 01:57:24 -04:00
|
|
|
|
2014-03-10 01:18:05 -04:00
|
|
|
_logHistoryItem(action, showid, season, episode, quality, resource, provider)
|
|
|
|
|
|
|
|
|
2014-05-13 07:16:32 -04:00
|
|
|
def logFailed(epObj, release, provider=None):
|
|
|
|
showid = int(epObj.show.indexerid)
|
|
|
|
season = int(epObj.season)
|
|
|
|
epNum = int(epObj.episode)
|
|
|
|
status, quality = Quality.splitCompositeStatus(epObj.status)
|
2014-03-10 01:18:05 -04:00
|
|
|
action = Quality.compositeStatus(FAILED, quality)
|
|
|
|
|
|
|
|
_logHistoryItem(action, showid, season, epNum, quality, release, provider)
|