2 # -*- coding: utf-8 -*-
5 ###################################################################################
6 from urllib
.parse
import urlparse
9 ###################################################################################
11 def __init__(self
, Parent
):
14 def manipulate(self
, path
):
18 if o
.scheme
and o
.netloc
and o
.path
:
19 #Do we have something to manipulate
22 stats
["original"] = {}
23 stats
["original"]["up"] = 0
24 stats
["original"]["down"] = 0
25 stats
["modified"] = {}
26 stats
["modified"]["up"] = 0
27 stats
["modified"]["down"] = 0
29 attributes
= o
.query
.split("&")
30 for attribute
in attributes
:
31 temp
= attribute
.split("=")
34 queryItems
[key
] = value
39 stats
["original"]["down"] = int(queryItems
["downloaded"])
40 stats
["modified"]["down"] = int(queryItems
["downloaded"])
45 stats
["original"]["up"] = int(queryItems
["uploaded"])
46 stats
["modified"]["up"] = int(queryItems
["uploaded"])
49 for key
, value
in queryItems
.items():
52 if key
== "uploaded" and self
.Parent
.Configs
.manipulateUploads
["enabled"]:
53 if self
.Parent
.Configs
.manipulateUploads
["type"] == 1:
54 value
= int(round(int(value
)*self
.Parent
.Configs
.manipulateUploads
["factor"]))
56 value
= int(round(int(queryItems
["downloaded"])*self
.Parent
.Configs
.manipulateUploads
["factor"]))
58 stats
["modified"]["up"] = value
59 #If mofifying downloads
60 if key
== "downloaded" and self
.Parent
.Configs
.manipulateDownloads
["enabled"]:
61 if self
.Parent
.Configs
.manipulateDownloads
["type"] == 0:
62 value
= int(round(int(value
)*self
.Parent
.Configs
.manipulateDownloads
["factor"]))
64 value
= int(round(int(queryItems
["uploaded"])*self
.Parent
.Configs
.manipulateDownloads
["factor"]))
65 #Set modified download
66 stats
["modified"]["down"] = value
68 path
+= "?"+str(key
)+"="+str(value
)
70 path
+= "&"+str(key
)+"="+str(value
)
71 if showStats
== False:
75 return {"scheme":o
.scheme
, "netloc":o
.netloc
, "path":path
, "stats": stats
}