()
| 153 | @route("/json/add_package", method="POST") |
| 154 | @login_required('ADD') |
| 155 | def add_package(): |
| 156 | name = request.forms.get("add_name", "New Package").strip() |
| 157 | queue = int(request.forms['add_dest']) |
| 158 | links = decode(request.forms['add_links']) |
| 159 | links = links.split("\n") |
| 160 | pw = request.forms.get("add_password", "").strip("\n\r") |
| 161 | |
| 162 | try: |
| 163 | f = request.files['add_file'] |
| 164 | |
| 165 | if not name or name == "New Package": |
| 166 | name = f.name |
| 167 | |
| 168 | fpath = save_join(PYLOAD.getConfigValue("general", "download_folder"), "tmp_" + f.filename) |
| 169 | destination = open(fpath, 'wb') |
| 170 | copyfileobj(f.file, destination) |
| 171 | destination.close() |
| 172 | links.insert(0, fpath) |
| 173 | except: |
| 174 | pass |
| 175 | |
| 176 | name = name.decode("utf8", "ignore") |
| 177 | |
| 178 | links = map(lambda x: x.strip(), links) |
| 179 | links = filter(lambda x: x != "", links) |
| 180 | |
| 181 | pack = PYLOAD.addPackage(name, links, queue) |
| 182 | if pw: |
| 183 | pw = pw.decode("utf8", "ignore") |
| 184 | data = {"password": pw} |
| 185 | PYLOAD.setPackageData(pack, data) |
| 186 | |
| 187 | |
| 188 | @route("/json/move_package/<dest:int>/<id:int>") |
nothing calls this directly
no test coverage detected