Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: https://videobrowser.googlecode.com/svn/trunk@1166 096cc86f-8a4c-0410-9b85-8b5e0eee1c45
- Loading branch information
sam.saffron
committed
Jun 7, 2009
1 parent
0c1368a
commit bf132b5
Showing
55 changed files
with
5,036 additions
and
5,036 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,64 +1,64 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | <?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | <Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | <PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProductVersion>9.0.30729</ProductVersion> | <ProductVersion>9.0.30729</ProductVersion> | ||
<SchemaVersion>2.0</SchemaVersion> | <SchemaVersion>2.0</SchemaVersion> | ||
<ProjectGuid>{97AC0ED9-9207-4A7E-85A5-2EFEB2D35F6F}</ProjectGuid> | <ProjectGuid>{97AC0ED9-9207-4A7E-85A5-2EFEB2D35F6F}</ProjectGuid> | ||
<OutputType>Library</OutputType> | <OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | <AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>NndbMetadataProvider</RootNamespace> | <RootNamespace>NndbMetadataProvider</RootNamespace> | ||
<AssemblyName>NndbMetadataProvider</AssemblyName> | <AssemblyName>NndbMetadataProvider</AssemblyName> | ||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> | <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | <FileAlignment>512</FileAlignment> | ||
</PropertyGroup> | </PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | <DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | <DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | <Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | <OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | <DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | <ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | <WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | </PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | <DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | <Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | <OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | <DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | <ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | <WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | </PropertyGroup> | ||
<ItemGroup> | <ItemGroup> | ||
<Reference Include="System" /> | <Reference Include="System" /> | ||
<Reference Include="System.Core"> | <Reference Include="System.Core"> | ||
<RequiredTargetFramework>3.5</RequiredTargetFramework> | <RequiredTargetFramework>3.5</RequiredTargetFramework> | ||
</Reference> | </Reference> | ||
<Reference Include="System.Data" /> | <Reference Include="System.Data" /> | ||
<Reference Include="System.Web" /> | <Reference Include="System.Web" /> | ||
<Reference Include="System.Xml" /> | <Reference Include="System.Xml" /> | ||
</ItemGroup> | </ItemGroup> | ||
<ItemGroup> | <ItemGroup> | ||
<Compile Include="NndbPeopleProvider.cs" /> | <Compile Include="NndbPeopleProvider.cs" /> | ||
<Compile Include="Plugin.cs" /> | <Compile Include="Plugin.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | <Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | </ItemGroup> | ||
<ItemGroup> | <ItemGroup> | ||
<ProjectReference Include="..\MediaBrowser\MediaBrowser.csproj"> | <ProjectReference Include="..\MediaBrowser\MediaBrowser.csproj"> | ||
<Project>{C6B27E5F-3D83-4D71-85B9-AF83C8392721}</Project> | <Project>{C6B27E5F-3D83-4D71-85B9-AF83C8392721}</Project> | ||
<Name>MediaBrowser</Name> | <Name>MediaBrowser</Name> | ||
</ProjectReference> | </ProjectReference> | ||
</ItemGroup> | </ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | <!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | <Target Name="BeforeBuild"> | ||
</Target> | </Target> | ||
<Target Name="AfterBuild"> | <Target Name="AfterBuild"> | ||
</Target> | </Target> | ||
--> | --> | ||
<PropertyGroup> | <PropertyGroup> | ||
<PostBuildEvent>copy "$(TargetPath)" C:\ProgramData\MediaBrowser\Plugins\$(TargetFileName)</PostBuildEvent> | <PostBuildEvent>copy "$(TargetPath)" C:\ProgramData\MediaBrowser\Plugins\$(TargetFileName)</PostBuildEvent> | ||
</PropertyGroup> | </PropertyGroup> | ||
</Project> | </Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,102 +1,102 @@ | |||
using System; | using System; | ||
using System.Collections.Generic; | using System.Collections.Generic; | ||
using System.Text; | using System.Text; | ||
using System.Web; | using System.Web; | ||
using System.IO; | using System.IO; | ||
using System.Net; | using System.Net; | ||
using System.Text.RegularExpressions; | using System.Text.RegularExpressions; | ||
using System.Diagnostics; | using System.Diagnostics; | ||
using MediaBrowser.Library.Persistance; | using MediaBrowser.Library.Persistance; | ||
using MediaBrowser.Library.Entities; | using MediaBrowser.Library.Entities; | ||
using System.Web; | using System.Web; | ||
using MediaBrowser.Library.Providers.Attributes; | using MediaBrowser.Library.Providers.Attributes; | ||
using MediaBrowser.Library.Providers; | using MediaBrowser.Library.Providers; | ||
using MediaBrowser.Library.Logging; | using MediaBrowser.Library.Logging; | ||
|
|
||
|
|
||
namespace NndbMetadataProvider | namespace NndbMetadataProvider | ||
{ | { | ||
[RequiresInternet] | [RequiresInternet] | ||
[SupportedType(typeof(Person))] | [SupportedType(typeof(Person))] | ||
public class NndbPeopleProvider : BaseMetadataProvider | public class NndbPeopleProvider : BaseMetadataProvider | ||
{ | { | ||
[Persist] | [Persist] | ||
DateTime lastFetched = DateTime.MinValue; | DateTime lastFetched = DateTime.MinValue; | ||
|
|
||
public override void Fetch() { | public override void Fetch() { | ||
|
|
||
lastFetched = DateTime.Now; | lastFetched = DateTime.Now; | ||
string name = Item.Name; | string name = Item.Name; | ||
string url = "http://search.nndb.com/search/nndb.cgi?nndb=1&omenu=unspecified&query=" + HttpUtility.UrlEncode(name); | string url = "http://search.nndb.com/search/nndb.cgi?nndb=1&omenu=unspecified&query=" + HttpUtility.UrlEncode(name); | ||
string doc = Fetch(url); | string doc = Fetch(url); | ||
if (doc == null) return; | if (doc == null) return; | ||
|
|
||
|
|
||
Regex searchEx = new Regex("<a href=\"(?<fetchurl>[^\"]*)\">" + name + "</a>"); | Regex searchEx = new Regex("<a href=\"(?<fetchurl>[^\"]*)\">" + name + "</a>"); | ||
Match m = searchEx.Match(doc); | Match m = searchEx.Match(doc); | ||
if (m.Success) { | if (m.Success) { | ||
Trace.TraceInformation("Got basic info url for:" + name); | Trace.TraceInformation("Got basic info url for:" + name); | ||
url = m.Groups["fetchurl"].Value; | url = m.Groups["fetchurl"].Value; | ||
Trace.WriteLine(url); | Trace.WriteLine(url); | ||
doc = Fetch(url); | doc = Fetch(url); | ||
if (doc != null) { | if (doc != null) { | ||
Regex imageExpr = new Regex("<img src=\"(?<imageurl>[^\"]*)\" [^>]* alt=\"" + name + "\""); | Regex imageExpr = new Regex("<img src=\"(?<imageurl>[^\"]*)\" [^>]* alt=\"" + name + "\""); | ||
Match mi = imageExpr.Match(doc); | Match mi = imageExpr.Match(doc); | ||
if (mi.Success) { | if (mi.Success) { | ||
string imageUrl = url + mi.Groups["imageurl"].Value; | string imageUrl = url + mi.Groups["imageurl"].Value; | ||
Item.PrimaryImagePath = imageUrl; | Item.PrimaryImagePath = imageUrl; | ||
Trace.TraceInformation("Got image for:" + name); | Trace.TraceInformation("Got image for:" + name); | ||
} else | } else | ||
Trace.TraceInformation("No match for imageurl for " + name); | Trace.TraceInformation("No match for imageurl for " + name); | ||
} | } | ||
} else { | } else { | ||
Trace.TraceInformation("No match for fetchurl for " + name); | Trace.TraceInformation("No match for fetchurl for " + name); | ||
} | } | ||
} | } | ||
|
|
||
public override bool NeedsRefresh() | public override bool NeedsRefresh() | ||
{ | { | ||
// only fetch missing images | // only fetch missing images | ||
return Item.PrimaryImagePath == null && (DateTime.Now - lastFetched).Days > 30; | return Item.PrimaryImagePath == null && (DateTime.Now - lastFetched).Days > 30; | ||
} | } | ||
|
|
||
private static object fetchLock = new object(); | private static object fetchLock = new object(); | ||
private string Fetch(string url) | private string Fetch(string url) | ||
{ | { | ||
Logger.ReportInfo("nndb provider requesting image from: " + url); | Logger.ReportInfo("nndb provider requesting image from: " + url); | ||
|
|
||
int attempt = 0; | int attempt = 0; | ||
while (attempt < 2) | while (attempt < 2) | ||
{ | { | ||
attempt++; | attempt++; | ||
try | try | ||
{ | { | ||
lock (fetchLock) // nndb doesn't cope well with being hit too hard | lock (fetchLock) // nndb doesn't cope well with being hit too hard | ||
{ | { | ||
WebRequest req = HttpWebRequest.Create(url); | WebRequest req = HttpWebRequest.Create(url); | ||
req.Timeout = 60000; | req.Timeout = 60000; | ||
WebResponse resp = req.GetResponse(); | WebResponse resp = req.GetResponse(); | ||
try | try | ||
{ | { | ||
using (Stream s = resp.GetResponseStream()) | using (Stream s = resp.GetResponseStream()) | ||
{ | { | ||
StreamReader sr = new StreamReader(s); | StreamReader sr = new StreamReader(s); | ||
return sr.ReadToEnd(); | return sr.ReadToEnd(); | ||
} | } | ||
} | } | ||
finally | finally | ||
{ | { | ||
resp.Close(); | resp.Close(); | ||
} | } | ||
} | } | ||
} | } | ||
catch (Exception ex) | catch (Exception ex) | ||
{ | { | ||
Logger.ReportException("Error requesting: " + url, ex); | Logger.ReportException("Error requesting: " + url, ex); | ||
} | } | ||
|
|
||
} | } | ||
return null; | return null; | ||
} | } | ||
} | } | ||
} | } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,24 +1,24 @@ | |||
using System; | using System; | ||
using System.Collections.Generic; | using System.Collections.Generic; | ||
using System.Linq; | using System.Linq; | ||
using System.Text; | using System.Text; | ||
using MediaBrowser.Library.Plugins; | using MediaBrowser.Library.Plugins; | ||
using MediaBrowser.Library.Logging; | using MediaBrowser.Library.Logging; | ||
using MediaBrowser.Library; | using MediaBrowser.Library; | ||
|
|
||
namespace NndbMetadataProvider { | namespace NndbMetadataProvider { | ||
class Plugin : BasePlugin { | class Plugin : BasePlugin { | ||
|
|
||
public override void Init(Kernel kernel) { | public override void Init(Kernel kernel) { | ||
kernel.MetadataProviderFactories.Add(MetadataProviderFactory.Get<NndbPeopleProvider>()); | kernel.MetadataProviderFactories.Add(MetadataProviderFactory.Get<NndbPeopleProvider>()); | ||
} | } | ||
|
|
||
public override string Name { | public override string Name { | ||
get { return "Nndb image provider"; } | get { return "Nndb image provider"; } | ||
} | } | ||
|
|
||
public override string Description { | public override string Description { | ||
get { return "Downloads actor and director images from nndb.com"; } | get { return "Downloads actor and director images from nndb.com"; } | ||
} | } | ||
} | } | ||
} | } |
Oops, something went wrong.