Skip to content

Commit

Permalink
- Add Pixeldrain.com indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
KoalaBear84 committed May 22, 2022
1 parent b6178cf commit cef6286
Show file tree
Hide file tree
Showing 7 changed files with 409 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/OpenDirectoryDownloader/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public class Constants
public const string Parameters_GdIndex_RootId = "GDINDEX_ROOTID";
public const string Parameters_GoFileIOAccountToken = "GOFILE_ACCOUNTTOKEN";

public const string PixeldrainDomain = "pixeldrain.com";

public const string DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
public const string Parameters_Password = "PASSWORD";
public const string Parameters_FtpEncryptionMode = "FtpEncryptionMode";
Expand Down
6 changes: 6 additions & 0 deletions src/OpenDirectoryDownloader/DirectoryParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using OpenDirectoryDownloader.Site.GDIndex.Go2Index;
using OpenDirectoryDownloader.Site.GDIndex.GoIndex;
using OpenDirectoryDownloader.Site.GoFileIO;
using OpenDirectoryDownloader.Site.Pixeldrain;
using System;
using System.Collections.Generic;
using System.Diagnostics;
Expand Down Expand Up @@ -72,6 +73,11 @@ public static async Task<WebDirectory> ParseHtml(WebDirectory webDirectory, stri
return await GoFileIOParser.ParseIndex(httpClient, webDirectory);
}

if (webDirectory.Uri.Host == Constants.PixeldrainDomain)
{
return await PixeldrainParser.ParseIndex(httpClient, webDirectory, html);
}

if (httpClient is not null)
{
foreach (IHtmlScriptElement script in htmlDocument.Scripts.Where(s => s.Source is not null))
Expand Down
6 changes: 4 additions & 2 deletions src/OpenDirectoryDownloader/OpenDirectoryIndexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,8 @@ public async void StartIndexingAsync()
if (!OpenDirectoryIndexerSettings.CommandLineOptions.NoUrls &&
Session.Root.Uri.Host != Constants.GoogleDriveDomain &&
Session.Root.Uri.Host != Constants.BlitzfilesTechDomain &&
Session.Root.Uri.Host != Constants.GoFileIoDomain)
Session.Root.Uri.Host != Constants.GoFileIoDomain &&
Session.Root.Uri.Host != Constants.PixeldrainDomain)
{
if (Session.TotalFiles > 0)
{
Expand Down Expand Up @@ -448,7 +449,8 @@ public async void StartIndexingAsync()
if (OpenDirectoryIndexerSettings.CommandLineOptions.Speedtest &&
Session.Root.Uri.Host != Constants.GoogleDriveDomain &&
Session.Root.Uri.Host != Constants.BlitzfilesTechDomain &&
Session.Root.Uri.Host != Constants.GoFileIoDomain)
Session.Root.Uri.Host != Constants.GoFileIoDomain &&
Session.Root.Uri.Host != Constants.PixeldrainDomain)
{
if (Session.TotalFiles > 0)
{
Expand Down
3 changes: 0 additions & 3 deletions src/OpenDirectoryDownloader/Site/GoFileIO/GoFileIOParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@

namespace OpenDirectoryDownloader.Site.GoFileIO;

/// <summary>
/// Similar to GoFile.IO
/// </summary>
public static class GoFileIOParser
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
Expand Down
124 changes: 124 additions & 0 deletions src/OpenDirectoryDownloader/Site/Pixeldrain/PixeldrainFileResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
// <auto-generated />
//
// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
//
// using QuickType;
//
// var pixeldrainFileResult = PixeldrainFileResult.FromJson(jsonString);

namespace OpenDirectoryDownloader.Site.Pixeldrain.FileResult
{
using System;
using System.Collections.Generic;

using System.Globalization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

public partial class PixeldrainFileResult
{
[JsonProperty("type")]
public string Type { get; set; }

[JsonProperty("api_response")]
public ApiResponse ApiResponse { get; set; }

[JsonProperty("captcha_key")]
public string CaptchaKey { get; set; }

[JsonProperty("view_token")]
public string ViewToken { get; set; }

[JsonProperty("embedded")]
public bool Embedded { get; set; }

[JsonProperty("user_ads_enabled")]
public bool UserAdsEnabled { get; set; }
}

public partial class ApiResponse
{
[JsonProperty("id")]
public string Id { get; set; }

[JsonProperty("name")]
public string Name { get; set; }

[JsonProperty("size")]
public long Size { get; set; }

[JsonProperty("views")]
public long Views { get; set; }

[JsonProperty("bandwidth_used")]
public long BandwidthUsed { get; set; }

[JsonProperty("bandwidth_used_paid")]
public long BandwidthUsedPaid { get; set; }

[JsonProperty("downloads")]
public long Downloads { get; set; }

[JsonProperty("date_upload")]
public DateTimeOffset DateUpload { get; set; }

[JsonProperty("date_last_view")]
public DateTimeOffset DateLastView { get; set; }

[JsonProperty("mime_type")]
public string MimeType { get; set; }

[JsonProperty("thumbnail_href")]
public string ThumbnailHref { get; set; }

[JsonProperty("hash_sha256")]
public string HashSha256 { get; set; }

[JsonProperty("availability")]
public string Availability { get; set; }

[JsonProperty("availability_message")]
public string AvailabilityMessage { get; set; }

[JsonProperty("abuse_type")]
public string AbuseType { get; set; }

[JsonProperty("abuse_reporter_name")]
public string AbuseReporterName { get; set; }

[JsonProperty("can_edit")]
public bool CanEdit { get; set; }

[JsonProperty("show_ads")]
public bool ShowAds { get; set; }

[JsonProperty("allow_video_player")]
public bool AllowVideoPlayer { get; set; }

[JsonProperty("download_speed_limit")]
public long DownloadSpeedLimit { get; set; }
}

public partial class PixeldrainFileResult
{
public static PixeldrainFileResult FromJson(string json) => JsonConvert.DeserializeObject<PixeldrainFileResult>(json, Converter.Settings);
}

public static class Serialize
{
public static string ToJson(this PixeldrainFileResult self) => JsonConvert.SerializeObject(self, Converter.Settings);
}

internal static class Converter
{
public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
{
MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
DateParseHandling = DateParseHandling.None,
Converters =
{
new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
},
};
}
}
151 changes: 151 additions & 0 deletions src/OpenDirectoryDownloader/Site/Pixeldrain/PixeldrainListResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
// <auto-generated />
//
// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
//
// using QuickType;
//
// var pixeldrainListResult = PixeldrainListResult.FromJson(jsonString);

namespace OpenDirectoryDownloader.Site.Pixeldrain.ListResult
{
using System;
using System.Collections.Generic;

using System.Globalization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

public partial class PixeldrainListResult
{
[JsonProperty("type")]
public string Type { get; set; }

[JsonProperty("api_response")]
public ApiResponse ApiResponse { get; set; }

[JsonProperty("captcha_key")]
public string CaptchaKey { get; set; }

[JsonProperty("view_token")]
public string ViewToken { get; set; }

[JsonProperty("embedded")]
public bool Embedded { get; set; }

[JsonProperty("user_ads_enabled")]
public bool UserAdsEnabled { get; set; }
}

public partial class ApiResponse
{
[JsonProperty("id")]
public string Id { get; set; }

[JsonProperty("title")]
public string Title { get; set; }

[JsonProperty("date_created")]
public DateTimeOffset DateCreated { get; set; }

[JsonProperty("file_count")]
public long FileCount { get; set; }

[JsonProperty("files")]
public File[] Files { get; set; }

[JsonProperty("can_edit")]
public bool CanEdit { get; set; }
}

public partial class File
{
[JsonProperty("detail_href")]
public string DetailHref { get; set; }

[JsonProperty("description")]
public string Description { get; set; }

[JsonProperty("id")]
public string Id { get; set; }

[JsonProperty("name")]
public string Name { get; set; }

[JsonProperty("size")]
public long Size { get; set; }

[JsonProperty("views")]
public long Views { get; set; }

[JsonProperty("bandwidth_used")]
public long BandwidthUsed { get; set; }

[JsonProperty("bandwidth_used_paid")]
public long BandwidthUsedPaid { get; set; }

[JsonProperty("downloads")]
public long Downloads { get; set; }

[JsonProperty("date_upload")]
public DateTimeOffset DateUpload { get; set; }

[JsonProperty("date_last_view")]
public DateTimeOffset DateLastView { get; set; }

[JsonProperty("mime_type")]
public string MimeType { get; set; }

[JsonProperty("thumbnail_href")]
public string ThumbnailHref { get; set; }

[JsonProperty("hash_sha256")]
public string HashSha256 { get; set; }

[JsonProperty("availability")]
public string Availability { get; set; }

[JsonProperty("availability_message")]
public string AvailabilityMessage { get; set; }

[JsonProperty("abuse_type")]
public string AbuseType { get; set; }

[JsonProperty("abuse_reporter_name")]
public string AbuseReporterName { get; set; }

[JsonProperty("can_edit")]
public bool CanEdit { get; set; }

[JsonProperty("show_ads")]
public bool ShowAds { get; set; }

[JsonProperty("allow_video_player")]
public bool AllowVideoPlayer { get; set; }

[JsonProperty("download_speed_limit")]
public long DownloadSpeedLimit { get; set; }
}

public partial class PixeldrainListResult
{
public static PixeldrainListResult FromJson(string json) => JsonConvert.DeserializeObject<PixeldrainListResult>(json, Converter.Settings);
}

public static class Serialize
{
public static string ToJson(this PixeldrainListResult self) => JsonConvert.SerializeObject(self, Converter.Settings);
}

internal static class Converter
{
public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
{
MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
DateParseHandling = DateParseHandling.None,
Converters =
{
new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
},
};
}
}
Loading

0 comments on commit cef6286

Please sign in to comment.