Skip to content
This repository has been archived by the owner on Sep 27, 2022. It is now read-only.

torrent.DateAdded Property #15

Open
chefbennyj1 opened this issue Jul 28, 2019 · 6 comments
Open

torrent.DateAdded Property #15

chefbennyj1 opened this issue Jul 28, 2019 · 6 comments

Comments

@chefbennyj1
Copy link

Hi there. I've been using this great library for quite a while.

I was about to add some extra functionality into my web service application when I realized that the 'torrent.DateAdded' property is only returning a DateTime of 'Date = {1/1/0001 12:00:00 AM}'

The beginning of time! :)

@latop2604
Copy link
Owner

Can you provide sample program that demonstrate the issue?

@chefbennyj1
Copy link
Author

chefbennyj1 commented Aug 5, 2019

Yes,

On the Server side of my application I create an object to send through to my client when accessing ActiveTorrents Items.

(I realize I could probabaly just send alonog the clients data, but I do some byte conversions, and create some booleans to make things simple for the web side of the application. Please excuse the Exraction bit, I'm using SharpCompress to extract zips, and rar files into Emby's auto organize folders).

I hold information for JSON Serialization to the front end web application in an object which looks like this like this:

public class ActiveTorrent
{
    public string title { get; set; }

    public string percentage { get; set; }

    public string state { get; set; }

    public string id { get; set; }

    public string ETA { get; set; }

    public bool extraction { get; set; }

    public string type { get; set; }

    public string ExtractionPercentage { get; set; }

    public string downloadSpeed { get; set; }

    public bool isNew { get; set; }
}

I then run this function to return the ActiveTorrent Object when the javascript in the web application makes a request to the backend code.

public static async Task<List<ActiveTorrent>> GetActiveTorrents()
{
    try
    {
        var client = GetClient();
        //Program.ConsoleReadout("Create Active Torrent List...");

        var torrentList = await client.GetListAsync();

        var activeTorrents = new List<ActiveTorrent>();

        foreach (var torrent in torrentList.Result.Torrents)
        {

            var T = new ActiveTorrent
            {
                title = torrent.Name,
                percentage = torrent.Progress.ToString(CultureInfo.InvariantCulture),
                state = torrent.Status.ToString(),
                id = torrent.Hash,
                ETA = torrent.Eta.ToString(CultureInfo.InvariantCulture),
                extraction = FolderMonitor.IsExtracting(torrent.Name).Extracting,
                ExtractionPercentage = Math.Round(FolderMonitor.IsExtracting(torrent.Name).Percentage, MidpointRounding.ToEven).ToString(),
                downloadSpeed = ByteSizeConverter.SizeSuffix(torrent.DownloadSpeed),
                isNew = torrent.AddedDate > DateTime.Now.AddDays(-3) ? true : false //Right Here :)

            };

            activeTorrents.Add(T);
        }
        return activeTorrents;
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex.Message);
    }
    return null;
}

It returns a boolean for isNew which makes a quick DateTime calculation to see if the torrent.AddedDate is less then three days ago.

The 'torrent.DateAdded' will always return Janurary 1 0001. :)

UI

Please let me know if I can explain anything further. Great Library by the way!

Thank you

@latop2604
Copy link
Owner

I tested with version 3.5.5 and the property AddedDate is correctly deserialized with time component.

Can you provide the json corresponding to /gui/?token=<yourtoken>&list=1&cid=0 ?

Also which environment do you have ? (version/language/...)

@chefbennyj1
Copy link
Author

chefbennyj1 commented Aug 5, 2019

oh, that might be an issue. You see I use uTorrent 2.2.1 for a specific reason. That version is white-listed for me to use. I'm not sure about going into much more detail on that here. ;)

The JSON readout is as follows:

`{"build":25249,"label": [
["Agents of Shield",11]
,["Archer",9]
,["Doom Patrol",4]
,["Krypton",3]
,["Legion",6]
,["The Walking Dead",3]
]
,"torrents": [

["3DE04A5C7A4A32282252D723BA5B1D14D6AD4636",201,"##########################",4126091910,1000,4126091910,5402394624,1309,0,0,-1,"",0,0,0,0,65536,-1,0],…`

Would you need more than that? This is a clip of the response, but I think the web browser is truncating the whole response.

(only slightly incriminating...) LOL!

using C# libraries in visual studio 2017. I kept it a .netFramework Application. I didn't move to core yet for this project.

@latop2604
Copy link
Owner

The date field seem not part of the json. So they are nothing I can do for you.

@chefbennyj1
Copy link
Author

Okay! I will handle the date added as part of my own API. I appreciate you looking at it.

Thank you :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants