FTP announcer for dc++?
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

FTP announcer for dc++?

Started by GILLIS, 03 June, 2005, 01:30:19

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

GILLIS

i was wondering if this has been done yet, or if its possible.

the script would announce new dir's (folders) that get uploaded to the ftp in main on dc. similar to the ircbot "eggdrop".

please let me know, this would add a great feature to my hub. thanks in advance.
GILLIS?

bastya_elvtars

QuoteOriginally posted by GILLIS
i was wondering if this has been done yet, or if its possible.

the script would announce new dir's (folders) that get uploaded to the ftp in main on dc. similar to the ircbot "eggdrop".

please let me know, this would add a great feature to my hub. thanks in advance.
GILLIS?

Sure it can be done, but it is... hmm... courageous thing to run an FTP server and a DC Hub Server on the same machine. Anyway, you should specify whether these are proper releases and .nfo should be read or just the foldername. Both are easy, I will make it for you.
Everything could have been anything else and it would have just as much meaning.

GILLIS

yes it is, i have been running a hub, small hub ofcourse max 30users and an ftp on my pc for around 3 months now, both seems to be working great!

i find that amazing that you can just wip something like this up. they will be proper releases. just the folder would be great.

GILLIS

oh and would this be a script for ptokax?
 that is what i run the hub on.

bastya_elvtars

QuoteOriginally posted by GILLIS
oh and would this be a script for ptokax?
 that is what i run the hub on.

Sure, but can also be done for BCDC++/DCDM++.
Everything could have been anything else and it would have just as much meaning.

GILLIS

#5
ok, i use DC++ v0.674 and Ptokax 0.3.3.0 17.05
if you could wip this script up it would be greatly appritiated.

GILLIS?

GILLIS

#6
any luck? bastya_elvtars

XPMAN

bastya knows whats he doing :) ........ patient is a virtue :) Alot goes into some of these scripts as i am finding out. I dont think this one is something you can just sit down and write in 10 min. :)

bastya_elvtars

QuoteOriginally posted by XPMAN
bastya knows whats he doing :) ........ patient is a virtue :) Alot goes into some of these scripts as i am finding out. I dont think this one is something you can just sit down and write in 10 min. :)

Question: you have an FTP root folder where all releases get uploaded?

i. e.

D:\FTPUpl\release1
D:\FTPUpl\release2
D:\FTPUpl\release3
D:\FTPUpl\release4

or so you put them into subfolders by date?

D:\FTPUpl\0401\release1
Everything could have been anything else and it would have just as much meaning.

XPMAN

Myself , i have various folders, only 1 that they initially go into though . It would be nice to be able to specify ANY folder for it to look at though. That way if you changed the folder for a reason you could change it in the script as well :)

GILLIS

yes it would be something similar..
mine is :
E:\03-----------------NEWRELEASES, 0-DAY----------------------------\01.06.05-15.06.05\0603

but you get the idea.
lookin forward to this script!

bastya_elvtars

#11
Set the TimeBetweenAnnounces to 0.01 and test. It will pop up a dos window for a short time on every scan, but I will fix this. You have to change the directory it uses manually, it would way too much and inaccurate to write an autodetection routine. I wil also add a remote changing ability.

-- EggCrop by bastya_elvtars
-- some code from RabidWombat and plop
-- does the same as eggdrop for IRC
-- shows new folders from an ftp root dir
-- removes reeases older than x days, this can be set

-- How does it work?
-- It makes a dirlist from the desired directory.

---- ========= CONFIG START


DirToShow="M:/Movie" --  no \ on the end!!!!

PtokaXDir="I:/ptokax1601"

Bot="EggCrop"

TimetoLive=1 -- in days, after which releases are considered non-new

TimeBetweenAnnounces=2 -- in hours

---- ========= CONFIG END

function Main()
	local f=io.open("getdirs.bat","w+")
		-- create a windows BAT executable that makes a dirlist
		f:write("dir \""..DirToShow.."\" /b /a:d /o:n > \""..PtokaXDir.."/scripts/ftpdirs.lst\"")
	f:close()
	SetTimer(TimeBetweenAnnounces*1000*3600)
	StartTimer()
end

function AnnounceNew()
	local list=GetList()
	local msg="\r\n----------------- # Announcing latest FTP uploaded files #----------------- \r\n"
	if table.getn(list)==0 then
		msg=msg.."\r\nNo files. :("
	else
		for k=1,table.getn(list) do
			msg=msg.."\r\n"..list[k]
		end
	end
	SendToAll(Bot,msg)
end

function OnTimer()
	AnnounceNew()
end

function GetList()
	local tbl={}
	os.execute(frmHub:GetPtokaXLocation().."/scripts/getdirs.bat")
	local f=io.open("ftpdirs.lst","r")
	if f then
		for line in f:lines() do
			table.insert(tbl,line)
		end
		f:close()
	end
	return tbl
end

function PruneList(tbl) -- not in use
	local cnt,cnt2=0,0
	local now=JulianDate(SplitTimeString(os.date("%Y. %m. %d. %X")))
	local oldest=TimetoLive*1440 -- converting days to mins
	for a,b in tbl do
		cnt=cnt+1
		local notnow=JulianDate(SplitTimeString(b))
		local diff=now-notnow
		local hours, mins= math.floor(diff) * 24 + math.floor(frac(diff) * 24), math.floor(frac(frac(diff)*24)*60)
		local usrtime=hours*60+mins
		if usrtime > oldest then
			cnt2=cnt2+1
			tbl[a]=nil
		end
		SaveList(tbl)
	end
	if cnt2~=0 then
		SendToOps(Bot,cnt.." releases were parsed, and older then "..TimetoLive.." were deleted ("..cnt2").")
	end
end

-- Split a specific Time string into its components
-- New Format: D. M. Y. HR:MN:SC" - 24hr time
-- return: Y,M,D,HR,MN,SC  HR is in 24hr string.format
function SplitTimeString(TimeString) -- 
	local D,M,Y,HR,MN,SC
	if string.find(TimeString,"/") then
		if not string.find (TimeString,"[AP]M") then
			_,_,D,M,Y,HR,MN,SC=string.find(TimeString,"([^/]+).([^/]+).(%S+) ([^:]+).([^:]+).(%S+)")
		else
			if string.find (TimeString,"PM") then
				_,_,D,M,Y,hr,MN,SC=string.find(TimeString,"([^/]+).([^/]+).(%S+) ([^:]+).([^:]+).(%S+)")
				HR=tostring(tonumber(hr)+12)
			else
				_,_,D,M,Y,HR,MN,SC=string.find(TimeString,"([^/]+).([^/]+).(%S+) ([^:]+).([^:]+).(%S+)")
			end
		end
	elseif string.find (TimeString,"%d%-%d") then
		 _,_,Y,M,D,HR,MN,SC = string.find(TimeString, "([^-]+).([^-]+).(%S+) ([^:]+).([^:]+).(%S+)")
	elseif string.find (TimeString,"%d%d.%d%d.%d%d%d%d%s+") then
		 _,_,D,M,Y,HR,MN,SC = string.find(TimeString, "([^.]+).([^.]+).(%S+). ([^:]+).([^:]+).(%S+)")
	else
		 _,_,Y,M,D,HR,MN,SC = string.find(TimeString, "([^.]+).([^.]+).([^.]+). ([^:]+).([^:]+).(%S+)")
	end
	D = tonumber(D)
	M = tonumber(M)
	Y = tonumber(Y)
	HR = tonumber(HR)
	--assert(HR < 24)
	MN = tonumber(MN)
	--assert(MN < 60)
	SC = tonumber(SC)
	--assert(SC < 60)

	assert(HR < 24);
	assert(MN < 60);
	assert(SC < 60);
	return D,M,Y,HR,MN,SC
end

function JulianDate(DAY, MONTH, YEAR, HOUR, MINUTE, SECOND) -- HOUR is 24hr string.format
	local jy, ja, jm;
	assert(YEAR ~= 0);
	assert(YEAR ~= 1582 or MONTH ~= 10 or DAY < 4 or DAY > 15);
	--The dates 5 through 14 October, 1582, do not exist in the Gregorian system!");
	if(YEAR < 0 ) then
		YEAR = YEAR + 1;
	end
	if( MONTH > 2) then 
		jy = YEAR;
		jm = MONTH + 1;
	else
		jy = YEAR - 1;
		jm = MONTH + 13;
	end
	local intgr = math.floor( math.floor(365.25*jy) + math.floor(30.6001*jm) + DAY + 1720995 );
	--check for switch to Gregorian calendar
	local gregcal = 15 + 31*( 10 + 12*1582 );
	if(DAY + 31*(MONTH + 12*YEAR) >= gregcal ) then
		ja = math.floor(0.01*jy);
		intgr = intgr + 2 - ja + math.floor(0.25*ja);
	end
	--correct for half-day offset
	local dayfrac = HOUR / 24 - 0.5;
	if( dayfrac < 0.0 ) then
		dayfrac = dayfrac + 1.0;
		intgr = intgr - 1;
	end
	--now set the fraction of a day
	local frac = dayfrac + (MINUTE + SECOND/60.0)/60.0/24.0;
	--round to nearest second
	local jd0 = (intgr + frac)*100000;
	local  jd  = math.floor(jd0);
	if( jd0 - jd > 0.5 ) then jd = jd + 1 end
	return jd/100000;
end

function frac(num)
	return num - math.floor(num);
end
Everything could have been anything else and it would have just as much meaning.

GILLIS

#12
seems fine, no errors,
but it doesnt seem to be reading files.. i get :
----------------- # Announcing latest FTP uploaded files #-----------------

No files. :(

i have my the dir in | DirToShow="here" | with no "/" at the end. and i changed TimeBetweenAnnounces to 0.01

i was hoping it would automaticly announce them as they were uploaded, like as a new folder is uploaded to the current dir it would annouce it.

thanks, it seems to be coming along very nicely

bastya_elvtars

#13
QuoteOriginally posted by GILLIS
seems fine, no errors,
but it doesnt seem to be reading files.. i get :
----------------- # Announcing latest FTP uploaded files #-----------------

No files. :(

i have my the dir in | DirToShow="here" | with no "/" at the end. and i changed TimeBetweenAnnounces to 0.01

Absolute path is needed, i. e.: C:/Program Files/FTPSERVER"

QuoteOriginally posted by GILLIS
i was hoping it would automaticly announce them as they were uploaded, like as a new folder is uploaded to the current dir it would annouce it.

That's only possible if it scans the dir al the time. However it can be done.
Everything could have been anything else and it would have just as much meaning.

GILLIS

ok, sounds good. mine is set like this and still isnt reading folders..
---- ========= CONFIG START


DirToShow="E:\03-----------------NEWRELEASES, 0-DAY----------------------------\01.06.05-15.06.05\0604" --  no \ on the end!!!!

PtokaXDir="C:\PtokaX"

Bot="?0Day-Dump?"

TimetoLive=1 -- in days, after which releases are considered non-new

TimeBetweenAnnounces=0.01 -- in hours

---- ========= CONFIG END

Star

bastya_elvtars:
Got the same problem here. I can only get it to work if I use bouble \ in the path.
and change this
/scripts/ftpdirs.lst
to
\\scripts\\ftpdirs.lst

//Star

bastya_elvtars

QuoteOriginally posted by Star
bastya_elvtars:
Got the same problem here. I can only get it to work if I use bouble \ in the path.
and change this
/scripts/ftpdirs.lst
to
\\scripts\\ftpdirs.lst

//Star

It is working perfect here. What OS are you runnig this on? I tested on Xp SP2
Everything could have been anything else and it would have just as much meaning.

GILLIS

#17
yes works great now, thanks very much.

now the dir change could be changed so it might be easier to change it daily, and if its not going to auto read folders when they get uploaded, maybe a toggle on/off switch for the script?

just puttin ideas out, let me know how it works out.
thanks

i am using Xp pro SP2

worked fine after the "//" change in dir and "//scripts//ftpdirs.lst\"

GILLIS?

Star

XP pro SP2, PtokaX 17.09

GILLIS

#19
i have an idea...if you set the script TimeBetweenAnnounces at every 5mins it would work, but after the releases that have been posted in that 5min frame would never get posted again. only that once...then the next five mins it wouldnt post the ones it posted already, just the newer folders, and if theres no new folders it just doesnt post anything. get my drift?
let me know if it would work or if its even possible, if it is possible it would be flawless.

 or have it announce a folder as it gets uploaded to the dir.

thanks again.

GILLIS?

bastya_elvtars

QuoteOriginally posted by GILLIS
i have an idea...if you set the script TimeBetweenAnnounces at every 5mins it would work, but after the releases that have been posted in that 5min frame would never get posted again. only that once...then the next five mins it wouldnt post the ones it posted already, just the newer folders, and if theres no new folders it just doesnt post anything. get my drift?
let me know if it would work or if its even possible, if it is possible it would be flawless.

 or have it announce a folder as it gets uploaded to the dir.

thanks again.

GILLIS?

Nice idea. 1 more: is the folder is the same that files are uploaded to?
Everything could have been anything else and it would have just as much meaning.

GILLIS

no it would be ..
E:\NEWRELEASES, 0-DAY\01.06.05-15.06.05\0604
E:\NEWRELEASES, 0-DAY\01.06.05-15.06.05\0605 and so on..

bastya_elvtars

QuoteOriginally posted by GILLIS
no it would be ..
E:\NEWRELEASES, 0-DAY\01.06.05-15.06.05\0604
E:\NEWRELEASES, 0-DAY\01.06.05-15.06.05\0605 and so on..

OK, i understand releases are in daily folders. BUT, the files are uploaded to release folders directly?
Everything could have been anything else and it would have just as much meaning.

GILLIS

yes the releases are uploaded in to 0604 ..

E:\NEWRELEASES, 0-DAY\01.06.05-15.06.05\0604\RELEASEFOLDER#1\blahblah.mp3

E:\NEWRELEASES, 0-DAY\01.06.05-15.06.05\0604\RELEASEFOLDER#2\blahblah2.mp3

GILLIS

#24
got another idea..after it announces the releases after 5min time frame or what ever it happens to be, it saves it to a .txt for use later, say a user wasnt in the hub when it got announced. there could be a quick command like !rls or something. that would be fantastic.


or have the script mimic what eggdrop does, and just add the feature as the releases are uploaded to the ftp and announced in dc it saves the text in a .txt file for later access.

thanks again

GILLIS?

SMF spam blocked by CleanTalk