Click here to Skip to main content
Email Password   helpLost your password?

Why Another FTP Downloader?

There are millions of FTP programs. Why write another one?
The answer is simple: I searched for a tool for my special needs, and I couldn't find one.

I'm sharing a Dreambox with a friend. The dreambox is a digital DVB satellite receiver that runs Linux with a built in harddisk.
The dreambox has a Web interface that can be used to program timer recordings via Internet from anywhere in the world.
It also has an FTP server via which you can download the films from the harddisk once they are recorded.
The Dreambox can be completely remote-controlled via Internet. (Obviously you need DynDns and an open FTP and HTTP port in your router)
So if you live in Brazil and have a friend in Germany who has a dreambox, you can remotely record the German television program and later download it.
You can also use a dreambox to share a Pay-TV subscription with a friend.

Normally if you want to record a film which starts at 20:00 and ends at 22:00, you will program a timer from 21:55 till 22:30 to be sure that you don't miss anything if the transmission starts delayed. But a DVB stream creates between 20 and 50 Megabytes per minute (depending on the TV channel's bitrate). So it would be a great advantage if you can download only the interesting part. To download only the film and exclude the news and advertising I needed a preview function. My friend complained that I was occupying all his DSL upstream to load the films. So additionally a bandwidth control and a download scheduler were required.
All this is realized in this project.

Features

Previews

The Dreambox stores the films in the DVB satellite / cable stream format with the file extension *.TS (Transport Stream) as a split file:

You can easily adapt the generation of split-filenames to your needs: (in the file Defaults.cs)

public static string BuildSplitFileName(string s_File, int s32_Index)
{
   if (s32_Index == 0)
       return s_File;

   return s_File + "." + s32_Index.ToString("D3");
}

To use the Preview function, you simply enter a value into the "Preview" textbox. If you enter "100" here, a preview is downloaded every 100 MB. Later, you find in your download directory:

If you need more previews to decide where the film starts or ends, simply modify the Start, End and Preview values and hit the 'Start' button again.
So in the second cycle, you can enter a finer scale to find the start of the film:
Start: 100 MB, End: 300 MB, Preview: 25 MB.
If a preview already exists in your download folder, it will not be downloaded a second time.

Each preview chunk has a length of 500 KB. This assures that it contains at least one I-Frame which is required to decode the data.
After downloading, the previews open them in a tool like Project-X and see what they contain:

Partial Download

After the above procedure, you know that you have to download for example, from 125 MB until 2350 MB and enter this as Start and End values.
Then you can process the downloaded TS file with Project-X, then cut and multiplex it with a tool like Cuttermaran and finally burn it on DVD.

Settings.xml

The XML file in the same folder as the EXE is auto-generated.

The only field to be manually edited is <FileExtensions>. Here you can specify a comma separated list of file extensions which will be displayed in the Drop-Down list of remote files.

If you want to see only AVI and MPG files set:

<FileExtensions>Avi,Mpg</FileExtensions>

To see all files on the server set:

<FileExtensions>*.*</FileExtensions>

You must exit the program before modifying the XML file!

Resuming Downloads

If you abort a running download and start it again later by clicking "Start" it will automatically resume correctly. If you have set the checkbox "Autostart FtpDownloader with Windows," any interrupted download will resume automatically even after shutting down your PC meanwhile.

Problems may only occur if you manually manipulate existing downloads without understanding how resume works:

FtpDownloader calculates the position where to resume a broken download on the server from the value in the field "Start (MB)" plus the filesize that is already downloaded.

IMPORTANT:
To resume a broken download you must NEVER delete an entry from the listview and then enter it again with the same local filename but a different value in the field "Start (MB)"! Nor must you ever manipulate the XML file manually. This would result in a corrupt file.

It is also impossible to download two different files from the server into the same local file. You cannot merge different files together!

If you have three different recordings and want to put them together as one movie, download them as three separate files and then use Video Cutting software like Cuttermaran to put them together.

To avoid these problems never specify an already existing file in the field "Local Filename" when adding new downloads to the list.

Source Code

You will find a very clean and well structured C# source code with plenty of comments, written by a very experienced programmer.

The code is reusable, so you can easily reuse it in your own projects:

P.S.:
On my homepage, you find PTBSync and more information about the Dreambox and tools for cutting DVB films.

History

You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
GeneralMy vote of 1 [modified]
DrWatsonCoding
4:42 14 Jan '10  
(1) lacks simple upload ability
(2) author advertises his code on other projects, claiming that his has more features despite point (1) above.
(3) author uses an archaic object naming scheme:
(a) many objects start with lowercase 'k', which is not descriptive for english speakers
(b) Many public classes and public objects have names starting with lowercase letters (similar to Hungarian notation, but not quite)
(Most modern formatting guidelines would suggest that these objects should start with capital letters because of their prominence as public object/class names)
(c) most structs contain names like s64_fieldname, which is very annoying. fieldnames should be consistent with those in the MS documentation.

modified on Thursday, January 14, 2010 9:59 AM

GeneralMy vote of 1
mikejobu23
13:15 20 Aug '09  
t
GeneralWhy without Upload?
Rookin
10:41 14 Apr '09  
no Upload fucntion
Nice ^0(

Every implementation I found have that bug with 5 minutes limit
Red faced(
GeneralRe: Why without Upload?
Rookin
10:50 14 Apr '09  
Dear author!
This is unbearable.

Yoa are THE ONLY one who fixed the bug in Wininet.dll when application hangs after 5 minuts of upload/download.

If you spent your time on the "fixed FTP class" why did not you finish the job? What about simple upload?

it's a pity.
GeneralRe: Why without Upload?
Elmue
6:26 21 Apr '09  
Hello

Yes there are many discussions in internet about that topic.
But I did not fix the bug.
This can only be done by Microsoft. (but I doubt they will ever do it)
I only found a workaround.

As I wrote above the application is to download movies from a Dreambox.
I have no need to upload movies because the Dreambox itself records from TV.
So I didn't implement upload.

Elmü
GeneralFile delete on remote server
GIULIANO2121
7:34 12 Oct '08  
Hello!

thanks for your beautiful code! I have a question please.
I need to download files from a remore server (every 45 seconds..),
and then delete those files on the remote server.

Is it possibile? How?

Thank you very much in advance,

Giuliano
GeneralRe: File delete on remote server
Elmue
18:09 12 Oct '08  
Hello

Deleting files is not implemented because the Dreambox allows to delete files comfortably via its web interface.

But you can easily implement it on your own.
From Wininet.dll you have to import the command FtpDeleteFileW:

See MSDN: FtpDeleteFile


Elmü
GeneralVersion 3.4 released
Elmue
15:26 4 Sep '08  
Hello

I made 4 improvements and released them as version 3.4.

Download

Elmü

modified on Thursday, October 16, 2008 7:40 PM

GeneralSFTP Support
captor8
13:07 3 Sep '08  
Does it have SFTP support?
GeneralRe: SFTP Support
Elmue
15:24 4 Sep '08  
No.
GeneralNeat app
Stumproot
6:36 19 Aug '08  
Good job


Last Updated 29 Sep 2008 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2010