mirror of
https://github.com/moparisthebest/SickRage
synced 2024-11-11 03:45:01 -05:00
0d9fbc1ad7
This version of SickBeard uses both TVDB and TVRage to search and gather it's series data from allowing you to now have access to and download shows that you couldn't before because of being locked into only what TheTVDB had to offer. Also this edition is based off the code we used in our XEM editon so it does come with scene numbering support as well as all the other features our XEM edition has to offer. Please before using this with your existing database (sickbeard.db) please make a backup copy of it and delete any other database files such as cache.db and failed.db if present, we HIGHLY recommend starting out with no database files at all to make this a fresh start but the choice is at your own risk! Enjoy!
68 lines
2.2 KiB
Python
68 lines
2.2 KiB
Python
"""
|
|
Microsoft Archive parser
|
|
|
|
Author: Victor Stinner
|
|
Creation date: 2007-03-04
|
|
"""
|
|
|
|
MAX_NB_FILE = 100000
|
|
|
|
from lib.hachoir_parser import Parser
|
|
from lib.hachoir_core.field import FieldSet, String, UInt32, SubFile
|
|
from lib.hachoir_core.endian import LITTLE_ENDIAN
|
|
from lib.hachoir_core.text_handler import textHandler, filesizeHandler, hexadecimal
|
|
|
|
class FileIndex(FieldSet):
|
|
static_size = 68*8
|
|
|
|
def createFields(self):
|
|
yield String(self, "filename", 56, truncate="\0", charset="ASCII")
|
|
yield filesizeHandler(UInt32(self, "filesize"))
|
|
yield textHandler(UInt32(self, "crc32"), hexadecimal)
|
|
yield UInt32(self, "offset")
|
|
|
|
def createDescription(self):
|
|
return "File %s (%s) at %s" % (
|
|
self["filename"].value, self["filesize"].display, self["offset"].value)
|
|
|
|
class MarFile(Parser):
|
|
MAGIC = "MARC"
|
|
PARSER_TAGS = {
|
|
"id": "mar",
|
|
"category": "archive",
|
|
"file_ext": ("mar",),
|
|
"min_size": 80*8, # At least one file index
|
|
"magic": ((MAGIC, 0),),
|
|
"description": "Microsoft Archive",
|
|
}
|
|
endian = LITTLE_ENDIAN
|
|
|
|
def validate(self):
|
|
if self.stream.readBytes(0, 4) != self.MAGIC:
|
|
return "Invalid magic"
|
|
if self["version"].value != 3:
|
|
return "Invalid version"
|
|
if not(1 <= self["nb_file"].value <= MAX_NB_FILE):
|
|
return "Invalid number of file"
|
|
return True
|
|
|
|
def createFields(self):
|
|
yield String(self, "magic", 4, "File signature (MARC)", charset="ASCII")
|
|
yield UInt32(self, "version")
|
|
yield UInt32(self, "nb_file")
|
|
files = []
|
|
for index in xrange(self["nb_file"].value):
|
|
item = FileIndex(self, "file[]")
|
|
yield item
|
|
if item["filesize"].value:
|
|
files.append(item)
|
|
files.sort(key=lambda item: item["offset"].value)
|
|
for index in files:
|
|
padding = self.seekByte(index["offset"].value)
|
|
if padding:
|
|
yield padding
|
|
size = index["filesize"].value
|
|
desc = "File %s" % index["filename"].value
|
|
yield SubFile(self, "data[]", size, desc, filename=index["filename"].value)
|
|
|