Permalink
Browse files

tonnes of fixes/updates in this...new post-processing (like sickbeard…

…), custom format for folers/files now, comic detail image fix, status changes (archived status added), have counts reflected on Archived status, file-scanner redone to be more inclusive, 1/2 issue fix
  • Loading branch information...
evilhero committed Oct 30, 2012
1 parent 3711cf3 commit 8a5443814409da47b3e2c399747d7c150da61cbd
@@ -50,7 +50,7 @@ <h3><i>(Comic information is currently being loaded)</i></h3>
<td id="mainimg">
<fieldset>
<div id="artistImg">
- <img src="${comic['ComicImage']}" class="editArt" alt="" />
+ <img src="${comic['ComicImage']}" alt="" height="400" width="263" />
</div>
</fieldset>
</td>
@@ -101,7 +101,7 @@ <h3><i>(Comic information is currently being loaded)</i></h3>
<td id="mainimg">
<fieldset>
<div id="artistImg">
- <img src="${comic['ComicImage']}" class="editArt" alt="" />
+ <img src="${comic['ComicImage']}" alt="" height="400" width="263" />
</div>
</fieldset>
</td>
@@ -141,7 +141,7 @@ <h3><i>(Comic information is currently being loaded)</i></h3>
<td id="mainimg">
<fieldset>
<div class="row" id="artistImg">
- <img src="${comic['ComicImage']}" class="editArt" alt="" />
+ <img src="${comic['ComicImage']}" alt="" height="400" width="263" />
</div>
</fieldset>
</td>
@@ -163,7 +163,7 @@ <h3><i>(Comic information is currently being loaded)</i></h3>
<fieldset>
<div>
<label>Directory Location</label>
- <input type="text" name="com_location" value="${comic['ComicLocation']}" size="75"><br/>
+ <input type="text" name="com_location" value="${comic['ComicLocation']}" size="60"><br/>
<div class="row"><small>the directory where all the comics are located for this particular comic</small></div>
</div>
<div>
@@ -185,6 +185,7 @@ <h3><i>(Comic information is currently being loaded)</i></h3>
<option value="Wanted">Wanted</option>
<option value="Skipped">Skipped</option>
<option value="Downloaded">Downloaded</option>
+ <option value="Archived">Archived</option>
</select>
selected issues
<input type="hidden" value="Go">
@@ -240,8 +240,19 @@ <h1 class="clearfix"><img src="interfaces/default/images/icon_gear.png" alt="set
<fieldset>
<legend>Renaming options</legend>
<div>
- <label>Edit the ComicRN.py script and follow the instructions in file</label>
+ <label>*Folder Format is used only when adding new comics*</label>
</div>
+ <div class="row">
+ <label>Folder Format</label>
+ <input type="text" name="folder_format" value="${config['folder_format']}" size="43">
+ <small>Use: $Publisher, $Series, $Year<br />
+ E.g.: $Publisher/$Series ($Year) = DC Comics/Action Comics (2011)</small>
+ </div>
+ <div class="row">
+ <label> File Format</label>
+ <input type="text" name="file_format" value="${config['file_format']}" size="43">
+ <small>Use: $Series, $Year, $Issue<br />
+ E.g.: $Series $Issue ($Year) = Animal Man 0 (2012) </small>
</fieldset>
<fieldset>
@@ -263,6 +274,23 @@ <h1 class="clearfix"><img src="interfaces/default/images/icon_gear.png" alt="set
%endfor
</select>
</div>
+ <div class="row checkbox">
+ <input id="zero_level" type="checkbox" onclick="initConfigCheckbox($(this));" name="zero_level" value="1" ${config['zero_level']} /><label>Zero level Suppression</label>
+ </div>
+ <div class="row">
+ <label>Format</label>
+ <select name="zero_level_n">
+ %for zeros in ['none', '0x', '00x']:
+ <%
+ if config['zero_level_n'] == zeros:
+ outputselect = 'selected'
+ else:
+ outputselect = ''
+ %>
+ <option value=${zeros} ${outputselect}>${zeros}</option>
+ %endfor
+ </select>
+ </div>
</fieldset>
@@ -347,11 +375,13 @@ <h1 class="clearfix"><img src="interfaces/default/images/icon_gear.png" alt="set
$( "#tabs" ).tabs();
});
initActions();
+ initConfigCheckbox("#launch_browser");
initConfigCheckbox("#usenzbsu");
initConfigCheckbox("#usedognzb");
initConfigCheckbox("#useexperimental");
initConfigCheckbox("#useraw");
initConfigCheckbox("#replace_spaces");
+ initConfigCheckbox("#zero_level");
}
$(document).ready(function() {
initThisPage();
View
@@ -0,0 +1,164 @@
+# This file is part of Mylar.
+#
+# Mylar is free software: you can redistribute it and/or modify
+# 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.
+#
+# Mylar is distributed in the hope that it will be useful,
+# 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
+# along with Mylar. If not, see <http://www.gnu.org/licenses/>.
+
+
+import os
+import shutil
+
+import time
+
+import mylar
+
+from mylar import logger, db, helpers, updater
+
+def PostProcess(nzb_name, nzb_folder):
+ log2screen = ""
+ log2screen = log2screen + "Nzb Name:" + nzb_name + "\n"
+ log2screen = log2screen + "Nzb Folder:" + nzb_folder + "\n"
+ #lookup nzb_name in nzblog table to get issueid
+ myDB = db.DBConnection()
+ nzbiss = myDB.action("SELECT * from nzblog WHERE nzbname=?", [nzb_name]).fetchone()
+ if nzbiss is None:
+ log2screen = log2screen + "Epic failure - could not locate file to rename." + "\n"
+ logger.error(u"Unable to locate downloaded file to rename. PostProcessing aborted.")
+ return
+ else:
+ issueid = nzbiss['IssueID']
+ #log2screen = log2screen + "IssueID: " + issueid + "\n"
+ #use issueid to get publisher, series, year, issue number
+ issuenzb = myDB.action("SELECT * from issues WHERE issueid=?", [issueid]).fetchone()
+ comicid = issuenzb['ComicID']
+ #log2screen = log2screen + "ComicID: " + comicid + "\n"
+ issuenum = issuenzb['Issue_Number']
+ issueno = str(issuenum).split('.')[0]
+ log2screen = log2screen + "Issue Number: " + str(issueno) + "\n"
+ # issue zero-suppression here
+ if mylar.ZERO_LEVEL is None:
+ zeroadd = ""
+ else:
+ if mylar.ZERO_LEVEL_N == "none": zeroadd = ""
+ elif mylar.ZERO_LEVEL_N == "0x": zeroadd = "0"
+ elif mylar.ZERO_LEVEL_N == "00x": zeroadd = "00"
+
+
+ if str(len(issueno)) > 1:
+ if int(issueno) < 10:
+ log2screen = log2screen + "issue detected less than 10" + "\n"
+ prettycomiss = str(zeroadd) + str(int(issueno))
+ log2screen = log2screen + "Zero level supplement set to " + str(mylar.ZERO_LEVEL_N) + ". Issue will be set as : " + str(prettycomiss) + "\n"
+ elif int(issueno) >= 10 and int(issueno) < 100:
+ log2screen = log2screen + "issue detected greater than 10, but less than 100" + "\n"
+ if mylar.ZERO_LEVEL_N == "none":
+ zeroadd = ""
+ else:
+ zeroadd = "0"
+ prettycomiss = str(zeroadd) + str(int(issueno))
+ log2screen = log2screen + "Zero level supplement set to " + str(mylar.ZERO_LEVEL_N) + ".Issue will be set as : " + str(prettycomiss) + "\n"
+ else:
+ log2screen = log2screen + "issue detected greater than 100" + "\n"
+ prettycomiss = str(issueno)
+ log2screen = log2screen + "Zero level supplement set to " + str(mylar.ZERO_LEVEL_N) + ". Issue will be set as : " + str(prettycomiss) + "\n"
+ else:
+ prettycomiss = str(issueno)
+ log2screen = log2screen + "issue length error - cannot determine length. Defaulting to None: " + str(prettycomiss) + "\n"
+
+ issueyear = issuenzb['IssueDate'][:4]
+ log2screen = log2screen + "Issue Year: " + str(issueyear) + "\n"
+ comicnzb= myDB.action("SELECT * from comics WHERE comicid=?", [comicid]).fetchone()
+ publisher = comicnzb['ComicPublisher']
+ log2screen = log2screen + "Publisher: " + publisher + "\n"
+ series = comicnzb['ComicName']
+ log2screen = log2screen + "Series: " + series + "\n"
+ seriesyear = comicnzb['ComicYear']
+ log2screen = log2screen + "Year: " + seriesyear + "\n"
+ comlocation = comicnzb['ComicLocation']
+ log2screen = log2screen + "Comic Location: " + comlocation + "\n"
+#---move to importer.py
+ #get output path format
+# if ':' in series:
+# series = series.replace(':','')
+ #do work to generate folder path
+# values = {'$Series': series,
+# '$Publisher': publisher,
+# '$Year': seriesyear
+# }
+# comlocation = mylar.DESTINATION_DIR + "/" + helpers.replace_all(mylar.FOLDER_FORMAT, values)
+ #last perform space replace
+# if mylar.REPLACE_SPACES:
+ #mylar.REPLACE_CHAR ...determines what to replace spaces with underscore or dot
+# comlocation = comlocation.replace(' ', mylar.REPLACE_CHAR)
+# log2screen = log2screen + "Final Location: " + comlocation + "\n"
+#---
+ #rename file and move to new path
+ #nfilename = series + " " + issueno + " (" + seriesyear + ")"
+ file_values = {'$Series': series,
+ '$Issue': prettycomiss,
+ '$Year': issueyear
+ }
+
+ extensions = ('.cbr', '.cbz')
+
+ for root, dirnames, filenames in os.walk(nzb_folder):
+ for filename in filenames:
+ if filename.lower().endswith(extensions):
+ ofilename = filename
+ path, ext = os.path.splitext(ofilename)
+ log2screen = log2screen + "Original Filename: " + ofilename + "\n"
+ log2screen = log2screen + "Original Extension: " + ext + "\n"
+ if mylar.FILE_FORMAT == '':
+ log2screen = log2screen + "Rename Files isn't enabled...keeping original filename." + "\n"
+ #check if extension is in nzb_name - will screw up otherwise
+ if ofilename.lower().endswith(extensions):
+ nfilename = ofilename[:-4]
+ else:
+ nfilename = ofilename
+ else:
+ nfilename = helpers.replace_all(mylar.FILE_FORMAT, file_values)
+ if mylar.REPLACE_SPACES:
+ #mylar.REPLACE_CHAR ...determines what to replace spaces with underscore or dot
+ nfilename = nfilename.replace(' ', mylar.REPLACE_CHAR)
+ #TODO - sort issue numbering 12.00 should be 12
+ log2screen = log2screen + "New Filename: " + nfilename + "\n"
+
+ src = nzb_folder + "/" + ofilename
+ dst = comlocation + "/" + nfilename + ext
+ log2screen = log2screen + "Source:" + src + "\n"
+ log2screen = log2screen + "Destination:" + dst + "\n"
+ os.rename(nzb_folder + "/" + ofilename, nzb_folder + "/" + nfilename + ext)
+ src = nzb_folder + "/" + nfilename + ext
+ try:
+ shutil.move(src, dst)
+ except (OSError, IOError):
+ log2screen = log2screen + "Failed to move directory - check directories and manually re-run." + "\n"
+ log2screen = log2screen + "Post-Processing ABORTED." + "\n"
+ return log2screen
+ #tidyup old path
+ try:
+ shutil.rmtree(nzb_folder)
+ except (OSError, IOError):
+ log2screen = log2screen + "Failed to remove temporary directory - check directory and manually re-run." + "\n"
+ log2screen = log2screen + "Post-Processing ABORTED." + "\n"
+ return log2screen
+
+ log2screen = log2screen + "Removed temporary directory : " + str(nzb_folder) + "\n"
+ #delete entry from nzblog table
+ myDB.action('DELETE from nzblog WHERE issueid=?', [issueid])
+ #force rescan of files
+ updater.forceRescan(comicid)
+ logger.info(u"Post-Processing completed for: " + series + " issue: " + str(issuenum) )
+ log2screen = log2screen + "Post Processing SUCCESSFULL!" + "\n"
+ #print log2screen
+ return log2screen
+
View
@@ -101,6 +101,8 @@
FILE_FORMAT = None
REPLACE_SPACES = False
REPLACE_CHAR = None
+ZERO_LEVEL = False
+ZERO_LEVEL_N = None
AUTOWANT_UPCOMING = True
AUTOWANT_ALL = False
@@ -186,7 +188,7 @@ def initialize():
global __INITIALIZED__, FULL_PATH, PROG_DIR, VERBOSE, DAEMON, DATA_DIR, CONFIG_FILE, CFG, CONFIG_VERSION, LOG_DIR, CACHE_DIR, \
HTTP_PORT, HTTP_HOST, HTTP_USERNAME, HTTP_PASSWORD, HTTP_ROOT, LAUNCH_BROWSER, GIT_PATH, \
CURRENT_VERSION, LATEST_VERSION, CHECK_GITHUB, CHECK_GITHUB_ON_STARTUP, CHECK_GITHUB_INTERVAL, MUSIC_DIR, DESTINATION_DIR, \
- DOWNLOAD_DIR, USENET_RETENTION, SEARCH_INTERVAL, INTERFACE, AUTOWANT_ALL, AUTOWANT_UPCOMING, \
+ DOWNLOAD_DIR, USENET_RETENTION, SEARCH_INTERVAL, INTERFACE, AUTOWANT_ALL, AUTOWANT_UPCOMING, ZERO_LEVEL, ZERO_LEVEL_N, \
LIBRARYSCAN_INTERVAL, DOWNLOAD_SCAN_INTERVAL, SAB_HOST, SAB_USERNAME, SAB_PASSWORD, SAB_APIKEY, SAB_CATEGORY, SAB_PRIORITY, BLACKHOLE, BLACKHOLE_DIR, \
NZBSU, NZBSU_APIKEY, DOGNZB, DOGNZB_APIKEY, \
RAW, RAW_PROVIDER, RAW_USERNAME, RAW_PASSWORD, RAW_GROUPS, EXPERIMENTAL, \
@@ -243,6 +245,8 @@ def initialize():
BLACKHOLE_DIR = check_setting_str(CFG, 'General', 'blackhole_dir', '')
REPLACE_SPACES = bool(check_setting_int(CFG, 'General', 'replace_spaces', 0))
REPLACE_CHAR = check_setting_str(CFG, 'General', 'replace_char', '')
+ ZERO_LEVEL = bool(check_setting_int(CFG, 'General', 'zero_level', 0))
+ ZERO_LEVEL_N = check_setting_str(CFG, 'General', 'zero_level_n', '')
SAB_HOST = check_setting_str(CFG, 'SABnzbd', 'sab_host', '')
SAB_USERNAME = check_setting_str(CFG, 'SABnzbd', 'sab_username', '')
@@ -451,7 +455,8 @@ def config_write():
new_config['General']['blackhole_dir'] = BLACKHOLE_DIR
new_config['General']['replace_spaces'] = int(REPLACE_SPACES)
new_config['General']['replace_char'] = REPLACE_CHAR
-
+ new_config['General']['zero_level'] = int(ZERO_LEVEL)
+ new_config['General']['zero_level_n'] = ZERO_LEVEL_N
new_config['SABnzbd'] = {}
new_config['SABnzbd']['sab_host'] = SAB_HOST
@@ -515,10 +520,11 @@ def dbcheck():
c.execute('CREATE TABLE IF NOT EXISTS comics (ComicID TEXT UNIQUE, ComicName TEXT, ComicSortName TEXT, ComicYear TEXT, DateAdded TEXT, Status TEXT, IncludeExtras INTEGER, Have INTEGER, Total INTEGER, ComicImage TEXT, ComicPublisher TEXT, ComicLocation TEXT, ComicPublished TEXT, LatestIssue TEXT, LatestDate TEXT, Description TEXT, QUALalt_vers TEXT, QUALtype TEXT, QUALscanner TEXT, QUALquality TEXT, LastUpdated TEXT)')
c.execute('CREATE TABLE IF NOT EXISTS issues (IssueID TEXT, ComicName TEXT, IssueName TEXT, Issue_Number TEXT, DateAdded TEXT, Status TEXT, Type TEXT, ComicID, ArtworkURL Text, ReleaseDate TEXT, Location TEXT, IssueDate TEXT, Int_IssueNumber INT)')
- c.execute('CREATE TABLE IF NOT EXISTS sablog (nzo_id TEXT, ComicName TEXT, ComicYEAR TEXT, ComicIssue TEXT, name TEXT, nzo_complete TEXT)')
c.execute('CREATE TABLE IF NOT EXISTS snatched (IssueID TEXT, ComicName TEXT, Issue_Number TEXT, Size INTEGER, DateAdded TEXT, Status TEXT, FolderName TEXT, ComicID TEXT)')
c.execute('CREATE TABLE IF NOT EXISTS upcoming (ComicName TEXT, IssueNumber TEXT, ComicID TEXT, IssueID TEXT, IssueDate TEXT, Status TEXT)')
+ c.execute('CREATE TABLE IF NOT EXISTS nzblog (IssueID TEXT, NZBName TEXT)')
# c.execute('CREATE TABLE IF NOT EXISTS weekly (SHIPDATE, PUBLISHER text, ISSUE text, COMIC VARCHAR(150), EXTRA text, STATUS text)')
+# c.execute('CREATE TABLE IF NOT EXISTS sablog (nzo_id TEXT, ComicName TEXT, ComicYEAR TEXT, ComicIssue TEXT, name TEXT, nzo_complete TEXT)')
#new
c.execute('DROP TABLE IF EXISTS exceptions')
View
@@ -66,7 +66,10 @@ def GetComicInfo(comicid,dom):
#comicvine isn't as up-to-date with issue counts..
#so this can get really buggered, really fast.
tracks = dom.getElementsByTagName('issue')
- cntit = dom.getElementsByTagName('count_of_issues')[0].firstChild.wholeText
+ try:
+ cntit = dom.getElementsByTagName('count_of_issues')[0].firstChild.wholeText
+ except:
+ cntit = len(tracks)
trackcnt = len(tracks)
# if the two don't match, use trackcnt as count_of_issues might be not upto-date for some reason
if int(trackcnt) != int(cntit):
View
@@ -42,7 +42,7 @@ def listFiles(dir,watchcomic):
if watchcomic.lower() in subname.lower():
if 'annual' in subname.lower():
#print ("it's an annual - unsure how to proceed")
- break
+ continue
comicpath = os.path.join(basedir, item)
#print ( watchcomic + " - watchlist match on : " + comicpath)
comicsize = os.path.getsize(comicpath)
Oops, something went wrong.

1 comment on commit 8a54438

@partymike

This comment has been minimized.

Show comment Hide comment
@partymike

partymike Oct 30, 2012

hiya, since this last update i receive an error when trying to run mylar "IndentationError: expected an indented block"......Help!

hiya, since this last update i receive an error when trying to run mylar "IndentationError: expected an indented block"......Help!

Please sign in to comment.