|
From: <jmb...@us...> - 2013-07-08 08:11:21
|
Revision: 4598
http://sourceforge.net/p/mp-plugins/code/4598
Author: jmbillings
Date: 2013-07-08 08:11:17 +0000 (Mon, 08 Jul 2013)
Log Message:
-----------
Fix for pages where no image is present so we skip over them
Modified Paths:
--------------
trunk/plugins/APODPlugin/APODPlugin/APODDownloader.cs
trunk/plugins/APODPlugin/APODPlugin/APODPlugin.cs
trunk/plugins/APODPlugin/APODPlugin/APODPlugin.csproj
trunk/plugins/APODPlugin/APODPlugin/bin/Debug/APODPlugin.dll
trunk/plugins/APODPlugin/APODPlugin/bin/Debug/APODPlugin.pdb
trunk/plugins/APODPlugin/APODPlugin/bin/Debug/PostDeploy.ps1
trunk/plugins/APODPlugin/APODPlugin/obj/Debug/APODPlugin.csproj.FileListAbsolute.txt
trunk/plugins/APODPlugin/APODPlugin/obj/Debug/APODPlugin.dll
trunk/plugins/APODPlugin/APODPlugin/obj/Debug/APODPlugin.pdb
trunk/plugins/APODPlugin/APODPlugin/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
Added Paths:
-----------
trunk/plugins/APODPlugin/APODPlugin/directions.cs
Modified: trunk/plugins/APODPlugin/APODPlugin/APODDownloader.cs
===================================================================
--- trunk/plugins/APODPlugin/APODPlugin/APODDownloader.cs 2013-07-05 20:44:18 UTC (rev 4597)
+++ trunk/plugins/APODPlugin/APODPlugin/APODDownloader.cs 2013-07-08 08:11:17 UTC (rev 4598)
@@ -14,12 +14,15 @@
String APODURL = "http://apod.nasa.gov/apod/astropix.html";
internal event downloadErrorEvent onDownloadError;
internal event downloadCompleteEvent onDownloadComplete;
+ internal event downloadNoImageFound onDownloadNoImageFound;
public delegate void downloadErrorEvent(object sender, downloadErrorEventArgs e);
public delegate void downloadCompleteEvent(object sender, downloadCompleteEventArgs e);
+ public delegate void downloadNoImageFound(object sender, downloadNoImageEventArgs e);
WebClient client;
WebClient imageClient;
List<String> apodURLs;
int currentStep = 0;
+ directions direction;
internal APODDownloader()
{
@@ -28,10 +31,11 @@
apodURLs.Add(APODURL);
}
- internal bool GetImage(int step)
+ internal bool GetImage(int step, directions d)
{
try
{
+ direction = d;
currentStep = step;
client.OpenReadCompleted += new OpenReadCompletedEventHandler(readComplete);
client.OpenReadAsync(new Uri(apodURLs[step]));
@@ -67,6 +71,13 @@
client.OpenReadCompleted -= readComplete;
client.Dispose();
+ //Find the previous page URL as well... i.e. <a href="ap130319.html"><</a>
+ Match prevMatcher = Regex.Match(pagesource, "(?<=<a href=\")(.+?)(?=\"><</a>)");
+ String prevURL = "http://apod.nasa.gov/apod/" + prevMatcher.Value;
+ if (!apodURLs.Contains(prevURL))
+ apodURLs.Add(prevURL);
+
+ //Now look for image
Match sourceMatcher = Regex.Match(pagesource, "(?<=<IMG SRC=\")(.+?)(?=\")", RegexOptions.Singleline);
if (sourceMatcher.Success)
{
@@ -75,14 +86,9 @@
}
else
{
- onDownloadError(this, new downloadErrorEventArgs(new Exception("Couldn't find image source :(")));
+ onDownloadNoImageFound(this, new downloadNoImageEventArgs(direction));
+ //onDownloadError(this, new downloadErrorEventArgs(new Exception("No image found, this one might have been a Video... :)")));
}
-
- //Find the previous page URL as well... i.e. <a href="ap130319.html"><</a>
- Match prevMatcher = Regex.Match(pagesource, "(?<=<a href=\")(.+?)(?=\"><</a>)");
- String prevURL = "http://apod.nasa.gov/apod/" + prevMatcher.Value;
- if (!apodURLs.Contains(prevURL))
- apodURLs.Add(prevURL);
}
catch (Exception ex)
{
@@ -134,4 +140,13 @@
bitmap = b;
}
}
+
+ internal class downloadNoImageEventArgs : EventArgs
+ {
+ internal directions scrollDirection;
+ internal downloadNoImageEventArgs(directions d)
+ {
+ scrollDirection = d;
+ }
+ }
}
Modified: trunk/plugins/APODPlugin/APODPlugin/APODPlugin.cs
===================================================================
--- trunk/plugins/APODPlugin/APODPlugin/APODPlugin.cs 2013-07-05 20:44:18 UTC (rev 4597)
+++ trunk/plugins/APODPlugin/APODPlugin/APODPlugin.cs 2013-07-08 08:11:17 UTC (rev 4598)
@@ -119,7 +119,8 @@
downloader = new APODDownloader();
downloader.onDownloadError += downloader_onDownloadError;
downloader.onDownloadComplete += downloader_onDownloadComplete;
- downloader.GetImage(imageStep);
+ downloader.onDownloadNoImageFound += downloader_onDownloadNoImageFound;
+ downloader.GetImage(imageStep, directions.LEFT);
}
public override void OnAction(MediaPortal.GUI.Library.Action action)
@@ -129,11 +130,28 @@
if (action.wID == MediaPortal.GUI.Library.Action.ActionType.ACTION_MOVE_LEFT)
{
+ doDownload(directions.LEFT);
+ }
+ else if (action.wID == MediaPortal.GUI.Library.Action.ActionType.ACTION_MOVE_RIGHT)
+ {
+ doDownload(directions.RIGHT);
+ }
+ else if (action.wID == MediaPortal.GUI.Library.Action.ActionType.ACTION_SHOW_INFO)
+ {
+ //User pressed i
+
+ }
+ }
+
+ private void doDownload(directions d)
+ {
+ if (d == directions.LEFT)
+ {
//User pressed Left
GUIWaitCursor.Show();
downloading = true;
imageStep = imageStep + 1;
- if (!downloader.GetImage(imageStep))
+ if (!downloader.GetImage(imageStep, directions.LEFT))
{
GUIDialogOK dlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK);
if (dlgOK != null)
@@ -146,7 +164,7 @@
imageStep = imageStep - 1; //set counter back to where we were
}
}
- else if (action.wID == MediaPortal.GUI.Library.Action.ActionType.ACTION_MOVE_RIGHT)
+ else if (d == directions.RIGHT)
{
//User pressed right
if (imageStep == 0)
@@ -164,15 +182,17 @@
GUIWaitCursor.Show();
downloading = true;
imageStep = imageStep - 1;
- downloader.GetImage(imageStep);
+ downloader.GetImage(imageStep, directions.RIGHT);
}
- else if (action.wID == MediaPortal.GUI.Library.Action.ActionType.ACTION_SHOW_INFO)
- {
- //User pressed i
-
- }
}
+ void downloader_onDownloadNoImageFound(object sender, downloadNoImageEventArgs e)
+ {
+ //happens when no image found; skip next back/forwards in series.
+ GUIWaitCursor.Hide();
+ doDownload(e.scrollDirection);
+ }
+
void downloader_onDownloadComplete(object sender, downloadCompleteEventArgs e)
{
Rectangle screenRect = Screen.PrimaryScreen.Bounds;
Modified: trunk/plugins/APODPlugin/APODPlugin/APODPlugin.csproj
===================================================================
--- trunk/plugins/APODPlugin/APODPlugin/APODPlugin.csproj 2013-07-05 20:44:18 UTC (rev 4597)
+++ trunk/plugins/APODPlugin/APODPlugin/APODPlugin.csproj 2013-07-08 08:11:17 UTC (rev 4598)
@@ -57,6 +57,7 @@
<ItemGroup>
<Compile Include="APODDownloader.cs" />
<Compile Include="APODPlugin.cs" />
+ <Compile Include="directions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
Modified: trunk/plugins/APODPlugin/APODPlugin/bin/Debug/APODPlugin.dll
===================================================================
(Binary files differ)
Modified: trunk/plugins/APODPlugin/APODPlugin/bin/Debug/APODPlugin.pdb
===================================================================
(Binary files differ)
Modified: trunk/plugins/APODPlugin/APODPlugin/bin/Debug/PostDeploy.ps1
===================================================================
--- trunk/plugins/APODPlugin/APODPlugin/bin/Debug/PostDeploy.ps1 2013-07-05 20:44:18 UTC (rev 4597)
+++ trunk/plugins/APODPlugin/APODPlugin/bin/Debug/PostDeploy.ps1 2013-07-08 08:11:17 UTC (rev 4598)
@@ -1 +1,59 @@
-print "test"
\ No newline at end of file
+write "Copying Files to Mediaportal folders"
+if ([System.IntPtr]::Size -eq 4)
+{
+ write "32-bit OS detected..."
+ if (Test-Path 'C:\Program Files\team mediaportal\mediaportal\plugins\windows')
+ {
+ Copy-Item -Path '.\lib\net35\APODPlugin.dll' -Destination 'C:\Program Files\team mediaportal\mediaportal\plugins\windows'
+ write "Copied plugin DLL to Mediaportal Plugins folder"
+ }
+ else
+ {
+ write "Mediaportal plugins folder not found. Is Mediaportal installed..?"
+ }
+}
+else
+{
+ write "64-bit OS detected..."
+ if (Test-Path 'C:\Program Files (x86)\team mediaportal\mediaportal\plugins\windows')
+ {
+ Copy-Item -Path '.\lib\net35\APODPlugin.dll' -Destination 'C:\Program Files (x86)\team mediaportal\mediaportal\plugins\windows'
+ write "Copied plugin DLL to Mediaportal Plugins folder"
+ }
+ else
+ {
+ write "Mediaportal plugins folder not found. Is Mediaportal installed..?"
+ }
+}
+
+if (Test-Path 'C:\ProgramData\Team Mediaportal\Mediaportal\Skin\Default')
+{
+ Copy-Item -Path '.\content\APODPlugin.xml' -Destination 'C:\ProgramData\Team Mediaportal\Mediaportal\Skin\Default'
+ write "Copied Plugin XML to Default skin folder"
+}
+else
+{
+ write "Default skin folder not found, skipping file copy"
+}
+
+if (Test-Path 'C:\ProgramData\Team Mediaportal\Mediaportal\Skin\DefaultWide')
+{
+ Copy-Item -Path '.\content\APODPlugin.xml' -Destination 'C:\ProgramData\Team Mediaportal\Mediaportal\Skin\DefaultWide'
+ write "Copied Plugin XML to DefaultWide skin folder"
+}
+else
+{
+ write "DefaultWide skin folder not found, skipping file copy"
+}
+
+if (Test-Path 'C:\ProgramData\Team Mediaportal\Mediaportal\Skin\Titan')
+{
+ Copy-Item -Path '.\content\APODPlugin.xml' -Destination 'C:\ProgramData\Team Mediaportal\Mediaportal\Skin\Titan'
+ write "Copied Plugin XML to Titan skin folder"
+}
+else
+{
+ write "Titan skin folder not found, skipping file copy"
+}
+
+write "Plugin installation ended"
Added: trunk/plugins/APODPlugin/APODPlugin/directions.cs
===================================================================
--- trunk/plugins/APODPlugin/APODPlugin/directions.cs (rev 0)
+++ trunk/plugins/APODPlugin/APODPlugin/directions.cs 2013-07-08 08:11:17 UTC (rev 4598)
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace APODPlugin
+{
+ public enum directions
+ {
+ LEFT,
+ RIGHT
+ }
+}
Modified: trunk/plugins/APODPlugin/APODPlugin/obj/Debug/APODPlugin.csproj.FileListAbsolute.txt
===================================================================
--- trunk/plugins/APODPlugin/APODPlugin/obj/Debug/APODPlugin.csproj.FileListAbsolute.txt 2013-07-05 20:44:18 UTC (rev 4597)
+++ trunk/plugins/APODPlugin/APODPlugin/obj/Debug/APODPlugin.csproj.FileListAbsolute.txt 2013-07-08 08:11:17 UTC (rev 4598)
@@ -38,3 +38,5 @@
C:\Users\james.billings\Documents\Visual Studio 2012\Projects\APODPlugin\APODPlugin\obj\Debug\APODPlugin.dll
C:\Users\james.billings\Documents\Visual Studio 2012\Projects\APODPlugin\APODPlugin\obj\Debug\APODPlugin.pdb
C:\Users\james.billings\Documents\Visual Studio 2012\Projects\APODPlugin\APODPlugin\bin\Debug\PostDeploy.ps1
+C:\Users\jamesb\Documents\Visual Studio 2012\Projects\APODPlugin\APODPlugin\bin\Debug\PostDeploy.ps1
+C:\Users\jamesb\Documents\Visual Studio 2012\Projects\APODPlugin\APODPlugin\obj\Debug\APODPlugin.csprojResolveAssemblyReference.cache
Modified: trunk/plugins/APODPlugin/APODPlugin/obj/Debug/APODPlugin.dll
===================================================================
(Binary files differ)
Modified: trunk/plugins/APODPlugin/APODPlugin/obj/Debug/APODPlugin.pdb
===================================================================
(Binary files differ)
Modified: trunk/plugins/APODPlugin/APODPlugin/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|