def getfilelist(request): # ks = public_dic_bt.keys() # for k in ks: # print "public_dic_bt :",public_dic_bt.get(k) user = getusername(request) if not user: rs = "100102246" data = {'returncode':rs,'message':get_message(rs)} return HttpResponse(json.dumps(data),content_type="application/json") rs = "100102238" ftype = request.POST.get("status",'') keyword = request.POST.get("keyword",'') dfs = BtFileinfo_down.objects.filter(user=user) #print 'DDDFFF :',dfs if dfs and ftype: dfs = dfs.filter(status = ftype) if keyword: dfs = dfs.filter(name__icontains=keyword) try: dfs,pageTotal = paginator(request,dfs) objs = format_obj(dfs) rs = "100100000" except Exception,e: print 'get bt down center file err :',e return formatResponse()
def getfilelist(request): # ks = public_dic_bt.keys() # for k in ks: # print "public_dic_bt :",public_dic_bt.get(k) user = getusername(request) if not user: rs = "100102246" data = {'returncode': rs, 'message': get_message(rs)} return HttpResponse(json.dumps(data), content_type="application/json") rs = "100102238" ftype = request.POST.get("status", '') keyword = request.POST.get("keyword", '') dfs = BtFileinfo_down.objects.filter(user=user) #print 'DDDFFF :',dfs if dfs and ftype: dfs = dfs.filter(status=ftype) if keyword: dfs = dfs.filter(name__icontains=keyword) try: dfs, pageTotal = paginator(request, dfs) objs = format_obj(dfs) rs = "100100000" except Exception, e: print 'get bt down center file err :', e return formatResponse()
def getObjs(request): objs = [] bfids = request.POST.get("bfids","") if bfids: bfids = bfids.split(",") else: rs = "100102240" data = {"returncode":rs,"message":get_message(rs)} return HttpResponse(json.dumps(data),content_type="application/json") objs = BtFileinfo_down.objects.filter(id__in=bfids) if not objs: rs = "100102237" data = {"returncode":rs,"message":get_message(rs)} return HttpResponse(json.dumps(data),content_type="application/json") return objs
def getObjs(request): objs = [] bfids = request.POST.get("bfids", "") if bfids: bfids = bfids.split(",") else: rs = "100102240" data = {"returncode": rs, "message": get_message(rs)} return HttpResponse(json.dumps(data), content_type="application/json") objs = BtFileinfo_down.objects.filter(id__in=bfids) if not objs: rs = "100102237" data = {"returncode": rs, "message": get_message(rs)} return HttpResponse(json.dumps(data), content_type="application/json") return objs
def addBt(request): rs = "100102224" username = getusername(request) if not username: rs = "100102239" data = {"returncode":rs,"message":get_message(rs)} return HttpResponse(json.dumps(data),content_type="application/json") bt_path = "%s/btdownload/bt/" %(username) bt_down_path = "%s/btdownload/" %(username) os.chdir(root_path) try: # if not os.path.exists(bt_path): # #print 'create dir :',bt_path # os.makedirs(bt_path) obj = request.FILES.get("file",None) fileName = obj.name #print "fileName :",fileName b = BtFileinfo_down.objects.filter(name=fileName,user=username) if b: godown = request.POST.get("godown",None) if not godown: rs = "100102233" data = {'returncode':rs,"message":get_message(rs)} return HttpResponse(json.dumps(data)) if godown == "111": # 重新下 deleteBT(b) else:# 继续 data = {"returncode":rs,"message":get_message(rs)} return HttpResponse(json.dumps(data),content_type="application/json") file_path = (u"%s%s%s" %(FILE_SAVE_PATH,bt_path,fileName)).decode("utf8") if not os.path.exists(FILE_SAVE_PATH+bt_path): os.makedirs(FILE_SAVE_PATH+bt_path) f = open(file_path,"wb+") f.write(obj.read()) f.close() bt = BtFileinfo_down() info = lt.torrent_info(file_path) # files = info.files() # if files : # #print "FFFFFFFFFFFFF :",files # f = files[0] # #print '-------------->',f.path.split('/') # bt.dname = f.path.split('/')[-1] bt.name = fileName bt.fname = info.name() bt.user = username bt.torrent = bt_path bt.path = bt_down_path bt.percent = "" #bt.upsize = 0 bt.resources = "/" bt.requestUp = "-" bt.requestDown = "-" bt.speedUp = "-" bt.speedDown = "-" bt.status = 2 #bt.hash = info.info_hash() #print 'info.total_size():',info.total_size() bt.totalSize = info.total_size() bt.downloadedtime = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") bt.save() startBT(bt) rs = "100100000" except Exception,e:#add new bt err... list index out of range print 'add new bt err...',e
bt.speedDown = "-" bt.status = 2 #bt.hash = info.info_hash() #print 'info.total_size():',info.total_size() bt.totalSize = info.total_size() bt.downloadedtime = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") bt.save() startBT(bt) rs = "100100000" except Exception,e:#add new bt err... list index out of range print 'add new bt err...',e data = {"returncode":rs,"message":get_message(rs)} return HttpResponse(json.dumps(data),content_type="application/json") def getObjs(request): objs = [] bfids = request.POST.get("bfids","") if bfids: bfids = bfids.split(",") else: rs = "100102240" data = {"returncode":rs,"message":get_message(rs)} return HttpResponse(json.dumps(data),content_type="application/json")
def addBt(request): rs = "100102224" username = getusername(request) if not username: rs = "100102239" data = {"returncode": rs, "message": get_message(rs)} return HttpResponse(json.dumps(data), content_type="application/json") bt_path = "%s/btdownload/bt/" % (username) bt_down_path = "%s/btdownload/" % (username) os.chdir(root_path) try: # if not os.path.exists(bt_path): # #print 'create dir :',bt_path # os.makedirs(bt_path) obj = request.FILES.get("file", None) fileName = obj.name #print "fileName :",fileName b = BtFileinfo_down.objects.filter(name=fileName, user=username) if b: godown = request.POST.get("godown", None) if not godown: rs = "100102233" data = {'returncode': rs, "message": get_message(rs)} return HttpResponse(json.dumps(data)) if godown == "111": # 重新下 deleteBT(b) else: # 继续 data = {"returncode": rs, "message": get_message(rs)} return HttpResponse(json.dumps(data), content_type="application/json") file_path = (u"%s%s%s" % (FILE_SAVE_PATH, bt_path, fileName)).decode("utf8") if not os.path.exists(FILE_SAVE_PATH + bt_path): os.makedirs(FILE_SAVE_PATH + bt_path) f = open(file_path, "wb+") f.write(obj.read()) f.close() bt = BtFileinfo_down() info = lt.torrent_info(file_path) # files = info.files() # if files : # #print "FFFFFFFFFFFFF :",files # f = files[0] # #print '-------------->',f.path.split('/') # bt.dname = f.path.split('/')[-1] bt.name = fileName bt.fname = info.name() bt.user = username bt.torrent = bt_path bt.path = bt_down_path bt.percent = "" #bt.upsize = 0 bt.resources = "/" bt.requestUp = "-" bt.requestDown = "-" bt.speedUp = "-" bt.speedDown = "-" bt.status = 2 #bt.hash = info.info_hash() #print 'info.total_size():',info.total_size() bt.totalSize = info.total_size() bt.downloadedtime = datetime.datetime.now().strftime( "%Y-%m-%d %H:%M:%S") bt.save() startBT(bt) rs = "100100000" except Exception, e: #add new bt err... list index out of range print 'add new bt err...', e
bt.status = 2 #bt.hash = info.info_hash() #print 'info.total_size():',info.total_size() bt.totalSize = info.total_size() bt.downloadedtime = datetime.datetime.now().strftime( "%Y-%m-%d %H:%M:%S") bt.save() startBT(bt) rs = "100100000" except Exception, e: #add new bt err... list index out of range print 'add new bt err...', e data = {"returncode": rs, "message": get_message(rs)} return HttpResponse(json.dumps(data), content_type="application/json") def getObjs(request): objs = [] bfids = request.POST.get("bfids", "") if bfids: bfids = bfids.split(",") else: rs = "100102240" data = {"returncode": rs, "message": get_message(rs)} return HttpResponse(json.dumps(data), content_type="application/json")