コード例 #1
0
ファイル: file.py プロジェクト: vuolter/pyload
    def __init__(self, manager, fid, name, size, filestatus, media, added, fileorder,
                 url, pluginname, hash, status, error, package, owner):

        self.manager = manager

        self.fid = int(fid)
        self._name = format.name(name)
        self._size = size
        self.filestatus = filestatus
        self.media = media
        self.added = added
        self.fileorder = fileorder
        self.url = url
        self.pluginname = pluginname
        self.hash = hash
        self.status = status
        self.error = error
        self.owner = owner
        self.packageid = package
        # database information ends here

        self.lock = ReadWriteLock()

        self.plugin = None

        self.wait_until = 0  #: time.time() + time to wait

        # status attributes
        self.abort = False
        self.reconnected = False
        self.statusname = None
コード例 #2
0
    def __init__(self, manager, fid, name, size, filestatus, media, added,
                 fileorder, url, pluginname, hash, status, error, package,
                 owner):

        self.manager = manager

        self.fid = int(fid)
        self._name = format.name(name)
        self._size = size
        self.filestatus = filestatus
        self.media = media
        self.added = added
        self.fileorder = fileorder
        self.url = url
        self.pluginname = pluginname
        self.hash = hash
        self.status = status
        self.error = error
        self.owner = owner
        self.packageid = package
        # database information ends here

        self.lock = ReadWriteLock()

        self.plugin = None

        self.wait_until = 0  #: time.time() + time to wait

        # status attributes
        self.abort = False
        self.reconnected = False
        self.statusname = None
コード例 #3
0
def url_to_name(url, strict=False):
    url = format.url(url)
    url_p = urllib.parse.urlparse(url)
    name = url_p.path.split('/')[-1]
    if not name:
        name = url_p.query.split('=', 1)[::-1][0].split('&', 1)[0]
    if not name:
        name = url_p.netloc.split('.', 1)[0]
    return name.strip() if strict else format.name(name)
コード例 #4
0
    def set_name(self, name):
        """
        Only set unicode or utf8 strings as name.
        """
        name = format.name(name)

        # media type is updated if needed
        if self._name != name:
            self.media = guess_type(name)
            self._name = name
コード例 #5
0
ファイル: file.py プロジェクト: vuolter/pyload
    def set_name(self, name):
        """
        Only set unicode or utf8 strings as name.
        """
        name = format.name(name)

        # media type is updated if needed
        if self._name != name:
            self.media = guess_type(name)
            self._name = name
コード例 #6
0
def addcrypted():

    package = request.forms.get('referer', 'ClickAndLoad Package')
    dlc = request.forms['crypted'].replace(" ", "+")

    dlc_path = os.path.join(DL_ROOT, format.name(package) + ".dlc")
    with io.open(dlc_path, mode='wb') as fp:
        fp.write(dlc)

    try:
        API.add_package(package, [dlc_path], paused=True)
    except Exception:
        return HTTPError()
    else:
        return "success\r\n"
コード例 #7
0
    def parse_header(self):
        """
        Parse data from received header.
        """
        for orgline in self.decode_response(self.header).splitlines():
            line = orgline.strip().lower()
            if line.startswith("accept-ranges") and "bytes" in line:
                self.p.chunk_support = True

            if 'content-disposition' in line:
                m = self._re_filename.search(orgline.strip())
                if m:
                    name = format.name(m.groupdict()['name'])
                    self.p._name = name
                    self.log.debug("Content-Disposition: {0}".format(name))

            if not self.resume and line.startswith('content-length'):
                self.p._size = int(line.split(":")[1])

        self.header_parsed = True
コード例 #8
0
ファイル: curlchunk.py プロジェクト: vuolter/pyload
    def parse_header(self):
        """
        Parse data from received header.
        """
        for orgline in self.decode_response(self.header).splitlines():
            line = orgline.strip().lower()
            if line.startswith("accept-ranges") and "bytes" in line:
                self.p.chunk_support = True

            if "content-disposition" in line:

                m = _re_filename.search(orgline.strip())
                if m:
                    name = format.name(m.groupdict()['name'])
                    self.p._name = name
                    self.log.debug("Content-Disposition: {0}".format(name))

            if not self.resume and line.startswith("content-length"):
                self.p._size = int(line.split(":")[1])

        self.header_parsed = True
コード例 #9
0
def alias(value):
    chunks = _re_alias.split(format.name(value))
    return ''.join(word.capitalize() for word in chunks if word)