Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alpha-2.5 #10

Merged
merged 4 commits into from
Nov 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions PaheScrapper/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
<value>8</value>
</setting>
<setting name="HTMLSaveStateThershold" serializeAs="String">
<value>5</value>
<value>500</value>
</setting>
<setting name="WebDriveSaveStateThershold" serializeAs="String">
<value>1</value>
<value>100</value>
</setting>
<setting name="WebDriveRestartOnError" serializeAs="String">
<value>True</value>
Expand All @@ -44,7 +44,7 @@
<value>100</value>
</setting>
<setting name="FailsafeStateThershold" serializeAs="String">
<value>50</value>
<value>10</value>
</setting>
<setting name="OutputScrapeFilename" serializeAs="String">
<value>output.json</value>
Expand Down
2 changes: 1 addition & 1 deletion PaheScrapper/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Program
{
static void Main(string[] args)
{
ConsoleHelper.LogInfo("Pahe Scraper - Alpha 2.4");
ConsoleHelper.LogInfo("Pahe Scraper - Alpha 2.5");

if (args.Length == 3 && args[0] == "-d")
{
Expand Down
6 changes: 3 additions & 3 deletions PaheScrapper/Properties/Configuration.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions PaheScrapper/Properties/Configuration.settings
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
<Value Profile="(Default)">8</Value>
</Setting>
<Setting Name="HTMLSaveStateThershold" Type="System.Int32" Scope="User">
<Value Profile="(Default)">5</Value>
<Value Profile="(Default)">500</Value>
</Setting>
<Setting Name="WebDriveSaveStateThershold" Type="System.Int32" Scope="User">
<Value Profile="(Default)">1</Value>
<Value Profile="(Default)">100</Value>
</Setting>
<Setting Name="WebDriveRestartOnError" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
Expand All @@ -36,7 +36,7 @@
<Value Profile="(Default)">100</Value>
</Setting>
<Setting Name="FailsafeStateThershold" Type="System.Int32" Scope="User">
<Value Profile="(Default)">50</Value>
<Value Profile="(Default)">10</Value>
</Setting>
<Setting Name="OutputScrapeFilename" Type="System.String" Scope="User">
<Value Profile="(Default)">output.json</Value>
Expand Down
21 changes: 17 additions & 4 deletions PaheScrapper/ScrapperManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,35 @@ void BypassSurcuriRoutine()

void PersistHtmlState(bool transition)
{
if ((_currentPage + 1) % Configuration.Default.HTMLSaveStateThershold == 0)
if (!transition)
{
if (!transition)
if ((_currentPage + 1) % Configuration.Default.HTMLSaveStateThershold == 0)
{
_currentPage++;

saveState(_scrapperState);
}
}
else
{
saveState(_scrapperState);
}
}

void PersistWebDriveState(bool transition)
{
if ((_currentPage + 1) % Configuration.Default.WebDriveSaveStateThershold == 0)
if (!transition)
{
if (!transition)
if ((_currentPage + 1) % Configuration.Default.WebDriveSaveStateThershold == 0)
{

_currentPage++;

saveState(_scrapperState);
}
}
else
{
saveState(_scrapperState);
}
}
Expand Down
35 changes: 32 additions & 3 deletions PaheScrapper/ScrapperMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -475,14 +475,43 @@ public static VMMovieLookup DecodeDetailsVM(HtmlDocument document)
startIndex = documentHtml.IndexOf(startPattern, StringComparison.Ordinal);
documentHtml = documentHtml.Substring(startIndex + startPattern.Length, documentHtml.Length - startPattern.Length - startIndex);
endIndex = documentHtml.IndexOf(endPattern, StringComparison.Ordinal) + 1;

/*Array Case*/
bool arrayOfString = false;
if (endIndex == 0)
{
endPattern = "]; function";
endIndex = documentHtml.IndexOf(endPattern, StringComparison.Ordinal) + 1;
arrayOfString = true;
}

documentHtml = documentHtml.Substring(0, endIndex);

if (string.IsNullOrEmpty(documentHtml))
return new VMMovieLookup();

JObject linksObject = JObject.Parse(documentHtml);
IEnumerable<JToken> linksTokens = linksObject.Properties().Select(l => l.Value).ToArray();
string[] linksArray = linksTokens.Select(l => l.Value<string>()).ToArray();
string[] linksArray = null;

if (arrayOfString)
{
/*Array Case*/
if (documentHtml != "[]")
{
JArray linksInArrayStruct = new JArray(documentHtml);
linksArray = linksInArrayStruct.Children().Select(l => l.Value<string>()).ToArray();
}
}
else
{
/*Object Case*/
JObject linksObject = JObject.Parse(documentHtml);
IEnumerable<JToken> linksTokens = linksObject.Properties().Select(l => l.Value).ToArray();
linksArray = linksTokens.Select(l => l.Value<string>()).ToArray();
}

/*Empty Array => Empty Lookup*/
if (linksArray == null)
return new VMMovieLookup();

//Movie Page Links Buttons
documentHtml = decodedHtml;
Expand Down