Skip to content

Commit

Permalink
Merge pull request #10 from roofman2008/dev
Browse files Browse the repository at this point in the history
Alpha-2.5
  • Loading branch information
roofman2008 authored Nov 26, 2021
2 parents e1b9937 + 7c54d9e commit 2faa309
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 17 deletions.
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

0 comments on commit 2faa309

Please sign in to comment.