MCPcopy Index your code
hub / github.com/pyload/pyload / add_package

Function add_package

module/web/json_app.py:155–185  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

153@route("/json/add_package", method="POST")
154@login_required('ADD')
155def 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>")

Callers

nothing calls this directly

Calls 11

decodeFunction · 0.90
save_joinFunction · 0.90
filterFunction · 0.85
splitMethod · 0.80
decodeMethod · 0.80
getMethod · 0.45
getConfigValueMethod · 0.45
closeMethod · 0.45
insertMethod · 0.45
addPackageMethod · 0.45
setPackageDataMethod · 0.45

Tested by

no test coverage detected