Here is the .lua script.
Code: Select all
function Initialize()
tItem = {}
tHASH = {}
tSTATUS = {}
tNAME = {}
tSIZE = {}
tPERCENTPROGRESS = {}
tDOWNLOADED = {}
tUPLOADED = {}
tRATIO = {}
tUPLOADSPEED = {}
tDOWNLOADSPEED = {}
tETA = {}
tLABEL = {}
tPEERSCONNECTED = {}
tPEERSINSWARM = {}
tSEEDSCONNECTED = {}
tSEEDSINSWARM = {}
tAVAILABILITY = {}
tTORRENTQUEUEORDER = {}
tREMAINING = {}
tField21 = {}
tField22 = {}
tTEXTSTATUS = {}
tField24 = {}
tField25 = {}
tField26 = {}
tField27 = {}
tSAVEFOLDER = {}
sNormalColor = SKIN:GetVariable("ListFontColor")
sGreyColor = SKIN:GetVariable("GreyColor")
RunningState = SKIN:GetMeasure("CalcTranslatePIDToRunningState")
msMain = SKIN:GetMeasure("MeasureWebUI")
CurrDir = SKIN:GetVariable("CURRENTPATH")
end -- function Initialize
function Update()
IsRunning = RunningState:GetValue()
if IsRunning == 1 then --uTorrent running
Pos = 0
sAllText = msMain:GetStringValue()
sAllText = string.match(sAllText, ".-\034torrents\034%:(.-)$")
sTemp, iItemCount = string.gsub(sAllText, ".-%[\"(.-)\"%]", "")
iItemCount = (iItemCount < 6) and iItemCount or 5
for i = 1, iItemCount do
tItem[i] = "[\""..string.match(sAllText, ".-%[\"(.-)\"%]", Pos).."\"]"
Pos = Pos + string.len(tItem[i])+1
tHASH[i], tSTATUS[i], tNAME[i], tSIZE[i], tPERCENTPROGRESS[i], tDOWNLOADED[i], tUPLOADED[i], tRATIO[i], tUPLOADSPEED[i], tDOWNLOADSPEED[i], tETA[i], tLABEL[i], tPEERSCONNECTED[i], tPEERSINSWARM[i], tSEEDSCONNECTED[i], tSEEDSINSWARM[i], tAVAILABILITY[i], tTORRENTQUEUEORDER[i], tREMAINING[i], tField21[i], tField22[i], tTEXTSTATUS[i], tField24[i], tField25[i], tField26[i], tField27[i], tSAVEFOLDER[i] = string.match(tItem[i], '%[\"(.-)\",(.-),\"(.-)\",(.-),(.-),(.-),(.-),(.-),(.-),(.-),(.-),\"(.-)\",(.-),(.-),(.-),(.-),(.-),(.-),(.-),\"(.-)\",\"(.-)\",\"(.-)\",\"(.-)\",(.-),(.-),\"(.-)\",\"(.-)\".-%]')
tTEXTSTATUS[i] = string.gsub(tTEXTSTATUS[i], "Downloading", "Download")
tSAVEFOLDER[i] = string.gsub(tSAVEFOLDER[i], "\092\092", "\092")
SKIN:Bang("!ShowMeterGroup Torrent"..i)
SKIN:Bang("!SetOption Meter"..i.."Name Text \""..tNAME[i].."\"")
SKIN:Bang("!SetOption Meter"..i.."Name ToolTipText \""..tNAME[i].."#CRLF#"..tSAVEFOLDER[i].."\092#CRLF#Peers: "..tPEERSCONNECTED[i].."("..tPEERSINSWARM[i]..")#CRLF#Downloaded: "..round(tonumber(tDOWNLOADED[i]/1048576),0).." Mb".."#CRLF#Remaining: "..round(tonumber(tREMAINING[i]/1048576),0).." Mb#CRLF#Ratio: "..round(tonumber(tRATIO[i]/1000),3).."\"")
SKIN:Bang("!SetOption Meter"..i.."Size Text \""..round(tonumber(tSIZE[i]/1048576),0).." Mb\"")
SKIN:Bang("!SetVariable Bar"..i.."Calc \""..math.floor(tonumber(tPERCENTPROGRESS[i]/10)).."\"")
SKIN:Bang("!SetOption Meter"..i.."\% Text \""..math.floor(tonumber(tPERCENTPROGRESS[i]/10)).." \%\"")
if round(tonumber(tDOWNLOADSPEED[i]/1024),0) <= 0 then
SKIN:Bang("!SetOption Meter"..i.."DLSpeed FontColor \""..sGreyColor.."\"")
else
SKIN:Bang("!SetOption Meter"..i.."DLSpeed FontColor \""..sNormalColor.."\"")
end
SKIN:Bang("!SetOption Meter"..i.."DLSpeed Text \""..round(tonumber(tDOWNLOADSPEED[i]/1024),0).." k/Bs\"")
SKIN:Bang("!SetOption Meter"..i.."Seeds Text \""..tSEEDSCONNECTED[i].."("..tSEEDSINSWARM[i]..")\"")
SKIN:Bang("!SetOption Meter"..i.."Status Text \""..tTEXTSTATUS[i].."\"")
end
SKIN:Bang("!EnableMeasureGroup AllMeasures")
if iItemCount == 0 then
SKIN:Bang("!HideMeterGroup Body")
else
SKIN:Bang("!ShowMeterGroup Body")
end
SKIN:Bang("!SetVariable BackgroundHeight "..tostring(iItemCount * 31))
if iItemCount < 5 then
for i = iItemCount + 1, 5 do
SKIN:Bang("!HideMeterGroup Torrent"..i)
end
end
else -- uTorrent not running
SKIN:Bang("!DisableMeasureGroup AllMeasures")
SKIN:Bang("!HideMeterGroup Body")
for i = 1, 5 do
SKIN:Bang("!HideMeterGroup Torrent"..i)
end
end -- Test for uTorrent running
return IsRunning
end -- function Update
function round(num, idp)
local mult = 10^(idp or 0)
return math.floor(num * mult + 0.5) / mult
end -- function round
Code: Select all
[Rainmeter]
Author=Jeffrey Morley
Update=1000
DynamicWindowSize=1
[Metadata]
Name=LuaTorrent
Config=LuaTorrent
Description=uTorrent skin, using Lua scripting to automate display
Instructions=Requires uTorrent 3.1.26593 or better. | See Help(x) images in folder for help with setting up uTorrent | Change settings in this file to match
Version=Dec 9, 2011
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0
[Variables]
;uTorrent info you MUST set
UserName=Sakin
Password=4455
uTorrentPort=8081
ProcessName="utorrent"
PathToUTorrent="C:\Program Files (x86)\uTorrent\uTorrent.exe"
;End of uTorrent Info
;Colors you can change
ListFontColor=255,255,255,255
HeaderColor=239,219,137,255
UTorrentColor=239,219,137
PanelColor=0,0,0,180
ProgressBarColor=235,170,0,255
SeparatorLineColor=150,150,150,255
GreyColor=210,210,210,255
;End of Colors
;Dont change these
uTorrentURL=http://#UserName#:#Password#@127.0.0.1:#uTorrentPort#/gui/?list=1
Item=(?(?=.*\[\").*\[\"(.*)\",(.*),\"(.*)\",(.*),(.*),(.*),(.*),(.*),(.*),(.*),(.*),\"(.*)\",(.*),(.*),(.*),(.*),(.*),(.*),(.*)\])
BackgroundHeight=230
Bar1Calc=0
Bar2Calc=0
Bar3Calc=0
Bar4Calc=0
Bar5Calc=0
;End of [Variables]
;[CREATE INTERFACE]==================================================
[ListStyle]
FontColor=#ListFontColor#
FontFace=Arial
FontSize=10
StringStyle=BOLD
StringAlign=LEFT
AntiAlias=1
[MeterTopBackground]
Meter=IMAGE
SolidColor=#PanelColor#
W=645
H=25
X=0
Y=0
[MeterLabelBackground]
Group=Body
Meter=IMAGE
SolidColor=#PanelColor#
W=645
H=30
X=0
Y=25
Hidden=1
[MeterBodyBackground]
Group=Body
Meter=IMAGE
SolidColor=#PanelColor#
W=645
H=#BackgroundHeight#
X=0
Y=55
Hidden=1
DynamicVariables=1
[MeterLogo]
Meter=String
MeterStyle=ListStyle
FontColor=255,255,255,255
FontSize=14
W=18
H=18
X=5
Y=-2
Text=µ
[MeterTopLabel]
Meter=String
MeterStyle=ListStyle
FontColor=255,255,255,255
SolidColor=0,0,0,1
X=18
Y=4
Text=Torrent
[MeterRefresh]
Meter=Image
ImageName=#CURRENTPATH#refresh.png
W=18
H=18
PreserveAspectRatio=1
X=595
Y=4
Greyscale=1
ImageTint=255,255,255,255
ToolTipText="Refresh Skin"
LeftMouseUpAction=!Refresh
[MeterUTorrent]
Meter=Image
ImageName=#CURRENTPATH#Power.png
W=18
H=18
PreserveAspectRatio=1
X=620
Y=4
Greyscale=1
ImageTint=150,150,150,255
[MeterHeaders]
Group=Body
Meter=String
MeterStyle=ListStyle
FontColor=#HeaderColor#
W=545
H=19
X=0
Y=25
Text=" Name | Size | DL Speed | Seeds | Status"
Hidden=1
;[CHECK UTORRENT PROCESS]===========================================
[MeasureProcessPID]
Measure=Plugin
Plugin=Perfmon.dll
PerfMonObject="Process"
PerfMonCounter="ID Process"
PerfMonInstance=#ProcessName#
PerfMonDifference=0
UpdateDivider=2
[CalcTranslatePIDToRunningState]
Measure=Calc
Formula=MeasureProcessPID > 0 ? 1 : 0
IfAboveValue=0
IfAboveAction=!Execute [!EnableMeasure MeasureWebUI][!SetOption MeterUTorrent ImageTint 224,56,59,255][!SetOption MeterUTorrent ToolTipText "Close uTorrent application"][!SetOption MeterUTorrent LeftMouseUpAction """!Execute ["#CURRENTPATH#KillUTorrent.exe"]["#ADDONSPATH#PlayTone\PlayTone.exe" "500" "200"]"""]
IfEqualValue=0
IfEqualAction=!Execute [!DisableMeasure MeasureWebUI][!SetOption MeterUTorrent ImageTint #HeaderColor#][!SetOption MeterUTorrent ToolTipText "Run uTorrent application"][!SetOption MeterUTorrent LeftMouseUpAction """!Execute ["#PathToUTorrent#"]["#ADDONSPATH#PlayTone\PlayTone.exe" "500" "200"]"""]
;[GET UTORRENT INFO FROM WEB UI]=====================================
[MeasureWebUI]
Group=AllMeasures
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=#uTorrentURL#
RegExp="(?siU)^(.*)$"
ForceReload=1
UpdateRate=2
Disabled=1
FinishAction=!Execute [!EnableMeasure MeasureLua]
;[LUA MEASURE]========================================================
[MeasureLua]
Measure=SCRIPT
ScriptFile=#CURRENTPATH#LuaTorrent3.1.lua
UpdateDivider=2
Disabled=1
;[METERS]===================================================================================
[Meter1Name]
Group=Torrent1
Meter=String
MeterStyle=ListStyle
W=185
H=15
ClipString=1
X=5
Y=55
[Meter1Size]
Group=Torrent1
Meter=String
MeterStyle=ListStyle
X=301
Y=55
[Meter1DLSpeed]
Group=Torrent1
Meter=String
MeterStyle=ListStyle
X=372
Y=55
[Meter1Seeds]
Group=Torrent1
Meter=String
MeterStyle=ListStyle
X=463
Y=55
[Meter1Status]
Group=Torrent1
Meter=String
MeterStyle=ListStyle
X=534
Y=55
[Meter1Line]
Group=Torrent1
Meter=Image
SolidColor=#SeparatorLineColor#
W=600
H=1
X=7
Y=74
Hidden=1
[Measure1BarCalc]
Group=Torrent1
Measure=Calc
Formula=#Bar1Calc#
MinValue=0
MaxValue=100
DynamicVariables=1
[Meter1Bar]
Group=Torrent1
Meter=Bar
MeasureName=Measure1BarCalc
BarColor=235,170,0,255
BarOrientation=Horizontal
W=600
H=3
X=7
Y=73
[Meter1%]
Group=Torrent1
Meter=String
MeterStyle=ListStyle
FontSize=7
StringAlign=RIGHT
X=641
Y=-4r
;===============================================================================================================
[Meter2Name]
Group=Torrent2
Meter=String
MeterStyle=ListStyle
W=185
H=15
ClipString=1
X=5
Y=15r
[Meter2Size]
Group=Torrent2
Meter=String
MeterStyle=ListStyle
X=301
Y=0r
[Meter2DLSpeed]
Group=Torrent2
Meter=String
MeterStyle=ListStyle
X=372
Y=0r
[Meter2Seeds]
Group=Torrent2
Meter=String
MeterStyle=ListStyle
X=463
Y=0r
[Meter2Status]
Group=Torrent2
Meter=String
MeterStyle=ListStyle
X=534
Y=0r
[Meter2Line]
Group=Torrent2
Meter=Image
SolidColor=#SeparatorLineColor#
W=600
H=1
X=7
Y=20r
Hidden=1
[Measure2BarCalc]
Group=Torrent2
Measure=Calc
Formula=#Bar2Calc#
MinValue=0
MaxValue=100
DynamicVariables=1
[Meter2Bar]
Group=Torrent2
Meter=Bar
MeasureName=Measure2BarCalc
BarColor=#ProgressBarColor#
BarOrientation=Horizontal
W=600
H=3
X=7
Y=-1r
[Meter2%]
Group=Torrent2
Meter=String
MeterStyle=ListStyle
FontSize=7
StringAlign=RIGHT
X=641
Y=-4r
;===============================================================================================================
[Meter3Name]
Group=Torrent3
Meter=String
MeterStyle=ListStyle
W=185
H=15
ClipString=1
X=5
Y=15r
[Meter3Size]
Group=Torrent3
Meter=String
MeterStyle=ListStyle
X=301
Y=0r
[Meter3DLSpeed]
Group=Torrent3
Meter=String
MeterStyle=ListStyle
X=372
Y=0r
[Meter3Seeds]
Group=Torrent3
Meter=String
MeterStyle=ListStyle
X=463
Y=0r
[Meter3Status]
Group=Torrent3
Meter=String
MeterStyle=ListStyle
X=534
Y=0r
[Meter3Line]
Group=Torrent3
Meter=Image
SolidColor=#SeparatorLineColor#
W=600
H=1
X=7
Y=20r
Hidden=1
[Measure3BarCalc]
Group=Torrent3
Measure=Calc
Formula=#Bar3Calc#
MinValue=0
MaxValue=100
DynamicVariables=1
[Meter3Bar]
Group=Torrent3
Meter=Bar
MeasureName=Measure3BarCalc
BarColor=#ProgressBarColor#
BarOrientation=Horizontal
W=600
H=3
X=7
Y=-1r
[Meter3%]
Group=Torrent3
Meter=String
MeterStyle=ListStyle
FontSize=7
StringAlign=RIGHT
X=641
Y=-4r
;===============================================================================================================
[Meter4Name]
Group=Torrent4
Meter=String
MeterStyle=ListStyle
W=185
H=15
ClipString=1
X=5
Y=15r
[Meter4Size]
Group=Torrent4
Meter=String
MeterStyle=ListStyle
X=301
Y=0r
[Meter4DLSpeed]
Group=Torrent4
Meter=String
MeterStyle=ListStyle
X=372
Y=0r
[Meter4Seeds]
Group=Torrent4
Meter=String
MeterStyle=ListStyle
X=463
Y=0r
[Meter4Status]
Group=Torrent4
Meter=String
MeterStyle=ListStyle
X=534
Y=0r
[Meter4Line]
Group=Torrent4
Meter=Image
SolidColor=#SeparatorLineColor#
W=600
H=1
X=7
Y=20r
Hidden=1
[Measure4BarCalc]
Group=Torrent4
Measure=Calc
Formula=#Bar4Calc#
MinValue=0
MaxValue=100
DynamicVariables=1
[Meter4Bar]
Group=Torrent4
Meter=Bar
MeasureName=Measure4BarCalc
BarColor=#ProgressBarColor#
BarOrientation=Horizontal
W=600
H=3
X=7
Y=-1r
[Meter4%]
Group=Torrent4
Meter=String
MeterStyle=ListStyle
FontSize=7
StringAlign=RIGHT
X=641
Y=-4r
;===============================================================================================================
[Meter5Name]
Group=Torrent5
Meter=String
MeterStyle=ListStyle
W=185
H=15
ClipString=1
X=5
Y=15r
[Meter5Size]
Group=Torrent5
Meter=String
MeterStyle=ListStyle
X=301
Y=0r
[Meter5DLSpeed]
Group=Torrent5
Meter=String
MeterStyle=ListStyle
X=372
Y=0r
[Meter5Seeds]
Group=Torrent5
Meter=String
MeterStyle=ListStyle
X=463
Y=0r
[Meter5Status]
Group=Torrent5
Meter=String
MeterStyle=ListStyle
X=534
Y=0r
[Meter5Line]
Group=Torrent5
Meter=Image
SolidColor=#SeparatorLineColor#
W=600
H=1
X=7
Y=20r
Hidden=1
[Measure5BarCalc]
Group=Torrent5
Measure=Calc
Formula=#Bar5Calc#
MinValue=0
MaxValue=100
DynamicVariables=1
[Meter5Bar]
Group=Torrent5
Meter=Bar
MeasureName=Measure5BarCalc
BarColor=#ProgressBarColor#
BarOrientation=Horizontal
W=600
H=3
X=7
Y=-1r
[Meter5%]
Group=Torrent5
Meter=String
MeterStyle=ListStyle
FontSize=7
StringAlign=RIGHT
X=641
Y=-4r
Can someone please help?