Exemplo n.º 1
0
 def createNzbName(self, data, media):
     tag = self.cpTag(media)
     split_string = scanPassword(data.get('name'))
     if split_string[1] != None:
         return '%s%s{{%s}}' % (toSafeString(toUnicode(split_string[0])[:123 - len(tag) - len(split_string[1])]), tag, split_string[1])
     else:
         return '%s%s' % (toSafeString(toUnicode(data.get('name'))[:127 - len(tag)]), tag)
Exemplo n.º 2
0
 def createNzbName(self, data, media):
     tag = self.cpTag(media)
     split_string = scanPassword(data.get('name'))
     if split_string[1] != None:
         return '%s%s{{%s}}' % (toSafeString(
             toUnicode(
                 split_string[0])[:123 - len(tag) - len(split_string[1])]),
                                tag, split_string[1])
     else:
         return '%s%s' % (toSafeString(
             toUnicode(data.get('name'))[:127 - len(tag)]), tag)
Exemplo n.º 3
0
    def download(self, data = {}, movie = {}):

        if self.isDisabled() or not self.isCorrectType(data.get('type')):
            return

        directory = self.conf('directory')

        if not directory or not os.path.isdir(directory):
            log.error('No directory set for blackhole %s download.' % data.get('type'))
        else:
            fullPath = os.path.join(directory, '%s%s.%s' % (toSafeString(data.get('name')), self.cpTag(movie) , data.get('type')))

            try:
                if not os.path.isfile(fullPath):
                    log.info('Downloading %s to %s.' % (data.get('type'), fullPath))

                    try:
                        file = data.get('download')(url = data.get('url'), nzb_id = data.get('id'))

                        with open(fullPath, 'wb') as f:
                            f.write(file)
                    except:
                        log.debug('Failed download file: %s' % data.get('name'))
                        return False

                    return True
                else:
                    log.info('File %s already exists.' % fullPath)
                    return True
            except:
                log.error('Failed to download to blackhole %s' % traceback.format_exc())
                pass

        return False
Exemplo n.º 4
0
    def download(self, data={}):

        if self.isDisabled() or not self.isCorrectType(data.get('type')):
            return

        directory = self.conf('directory')

        if not directory or not os.path.isdir(directory):
            log.error('No directory set for blackhole %s download.' %
                      data.get('type'))
        else:
            fullPath = os.path.join(
                directory,
                toSafeString(data.get('name')) + '.' + data)

            if not os.path.isfile(fullPath):
                log.info('Downloading %s to %s.' %
                         (data.get('type'), fullPath))
                file = urllib.urlopen(data.get('url')).read()
                with open(fullPath, 'wb') as f:
                    f.write(file)

                return True
            else:
                log.error('File %s already exists.' % fullPath)

        return False
Exemplo n.º 5
0
def possibleTitles(raw_title):

    titles = [toSafeString(raw_title).lower(), raw_title.lower(), simplifyString(raw_title)]

    # replace some chars
    new_title = raw_title.replace("&", "and")
    titles.append(simplifyString(new_title))

    return removeDuplicate(titles)
Exemplo n.º 6
0
def possibleTitles(raw_title):

    titles = []

    titles.append(toSafeString(raw_title).lower())
    titles.append(raw_title.lower())
    titles.append(simplifyString(raw_title))

    return list(set(titles))
Exemplo n.º 7
0
def possibleTitles(raw_title):

    titles = []

    titles.append(toSafeString(raw_title).lower())
    titles.append(raw_title.lower())
    titles.append(simplifyString(raw_title))

    return list(set(titles))
Exemplo n.º 8
0
    def getColumns(self, entries):
        result = {}

        for x, col in enumerate(entries[0].find_all('th')):
            key = toSafeString(col.text).strip().lower()

            if not key:
                continue

            result[key] = x

        return result
Exemplo n.º 9
0
    def createNzbName(self, data, media):
        release_name = data.get('name')
        tag = self.cpTag(media)

        # Check if password is filename
        name_password = scanForPassword(data.get('name'))
        if name_password:
            release_name, password = name_password
            tag += '{{%s}}' % password

        max_length = 127 - len(tag) # Some filesystems don't support 128+ long filenames
        return '%s%s' % (toSafeString(toUnicode(release_name)[:max_length]), tag)
Exemplo n.º 10
0
def possibleTitles(raw_title):

    titles = [
        toSafeString(raw_title).lower(),
        raw_title.lower(),
        simplifyString(raw_title)
    ]

    # replace some chars
    new_title = raw_title.replace('&', 'and')
    titles.append(simplifyString(new_title))

    return list(set(titles))
Exemplo n.º 11
0
    def getColumns(self, entries):
        result = {}

        for x, col in enumerate(entries[0].find_all('th')):
            name = col.text or col.find('img')['title']
            key = toSafeString(name).strip().lower()

            if not key:
                continue

            result[key] = x

        return result
Exemplo n.º 12
0
    def getColumns(self, entries):
        result = {}

        for x, col in enumerate(entries[0].find_all('th')):
            name = col.text or col.find('img')['title']
            key = toSafeString(name).strip().lower()

            if not key:
                continue

            result[key] = x

        return result
Exemplo n.º 13
0
    def download(self, data={}):

        if self.isDisabled() or not self.isCorrectType(data.get("type")):
            return

        directory = self.conf("directory")

        if not directory or not os.path.isdir(directory):
            log.error("No directory set for blackhole %s download." % data.get("type"))
        else:
            fullPath = os.path.join(directory, toSafeString(data.get("name")) + "." + data)

            if not os.path.isfile(fullPath):
                log.info("Downloading %s to %s." % (data.get("type"), fullPath))
                file = urllib.urlopen(data.get("url")).read()
                with open(fullPath, "wb") as f:
                    f.write(file)

                return True
            else:
                log.error("File %s already exists." % fullPath)

        return False
Exemplo n.º 14
0
 def createNzbName(self, data, movie):
     tag = self.cpTag(movie)
     return '%s%s' % (toSafeString(
         toUnicode(data.get('name'))[:127 - len(tag)]), tag)
Exemplo n.º 15
0
 def createNzbName(self, data, movie):
     tag = self.cpTag(movie)
     return "%s%s" % (toSafeString(data.get("name")[: 127 - len(tag)]), tag)
Exemplo n.º 16
0
 def createNzbName(self, data, movie):
     return '%s%s' % (toSafeString(data.get('name')), self.cpTag(movie))
Exemplo n.º 17
0
 def createNzbName(self, data, media, password = None):
     tag = self.cpTag(media)
     if not password:
         return '%s%s' % (toSafeString(toUnicode(data.get('name'))[:127 - len(tag)]), tag)
     return '%s%s{{%s}}' % (toSafeString(toUnicode(data.get('name'))[:127 - len(tag)]), tag, password)
Exemplo n.º 18
0
 def createNzbName(self, data, movie):
     tag = self.cpTag(movie)
     return '%s%s' % (toSafeString(data.get('name')[:127 - len(tag)]), tag)
Exemplo n.º 19
0
 def createNzbName(self, data, media):
     tag = self.cpTag(media)
     return '%s%s' % (toSafeString(toUnicode(data.get('name'))[:127 - len(tag)]), tag)
Exemplo n.º 20
0
 def createFileName(self, data, filename, movie):
     name = os.path.join('%s%s' % (toSafeString(data.get('name')), self.cpTag(movie)))
     if data.get('type') == 'nzb' and "DOCTYPE nzb" not in filename:
         return '%s.%s' % (name, 'rar')
     return '%s.%s' % (name, data.get('type'))