Skip to content

Commit

Permalink
- Support alternative mediafire.com url
Browse files Browse the repository at this point in the history
  • Loading branch information
KoalaBear84 committed May 22, 2022
1 parent 79e0bbb commit ba9f2f2
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/OpenDirectoryDownloader/Site/Mediafire/MediafireParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public static class MediafireParser
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private static readonly Regex FolderIdRegex = new Regex(@"\/folder\/(?<FolderId>[^/]*)(?:\/?.*)?");
private static readonly Regex FolderIdRegex2 = new Regex(@"\/\?(?<FolderId>[^/]*)(?:\/?.*)?");
private const string Parser = "Mediafire";
private const string StatusSuccess = "Success";
private const string ApiBaseAddress = "https://www.mediafire.com/api/1.4";
Expand Down Expand Up @@ -43,12 +44,19 @@ private static string GetFolderId(WebDirectory webDirectory)
{
Match folderIdRegexMatch = FolderIdRegex.Match(webDirectory.Url);

if (!folderIdRegexMatch.Success)
if (folderIdRegexMatch.Success)
{
throw new Exception("Error getting folder id");
return folderIdRegexMatch.Groups["FolderId"].Value;
}

return folderIdRegexMatch.Groups["FolderId"].Value;
Match folderIdRegex2Match = FolderIdRegex2.Match(webDirectory.Url);

if (folderIdRegex2Match.Success)
{
return folderIdRegex2Match.Groups["FolderId"].Value;
}

throw new Exception("Error getting folder id");
}

private static async Task<WebDirectory> ScanAsync(HttpClient httpClient, WebDirectory webDirectory)
Expand Down

0 comments on commit ba9f2f2

Please sign in to comment.