[banshee: 2/61] Initial work on an Internet Archive extension
- From: Gabriel Burt <gburt src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [banshee: 2/61] Initial work on an Internet Archive extension
- Date: Tue, 3 Nov 2009 06:28:01 +0000 (UTC)
commit 5c55b7d065b4335f9c0af4a457e9002d95edc845
Author: Gabriel Burt <gabriel burt gmail com>
Date: Tue Oct 6 23:09:03 2009 -0700
Initial work on an Internet Archive extension
Currently doesn't do anything; there is a source which has appropriate
columns and the start of some header filter widgetry, but it's not
yet loading data from archive.org.
build/build.environment.mk | 3 +
configure.ac | 1 +
.../Banshee.InternetArchive.addin.xml | 22 +++
.../Banshee.InternetArchive/HeaderFilters.cs | 89 +++++++++++
.../Banshee.InternetArchive/Source.cs | 165 ++++++++++++++++++++
.../InternetArchive/Field.cs | 77 +++++++++
.../InternetArchive/FieldValue.cs | 44 +++++
.../InternetArchive/MediaType.cs | 100 ++++++++++++
.../InternetArchive/ResultsFormat.cs | 45 ++++++
.../InternetArchive/Search.cs | 142 +++++++++++++++++
.../InternetArchive/Sort.cs | 95 +++++++++++
src/Extensions/Banshee.InternetArchive/Makefile.am | 19 +++
src/Extensions/Makefile.am | 1 +
13 files changed, 803 insertions(+), 0 deletions(-)
---
diff --git a/build/build.environment.mk b/build/build.environment.mk
index 6bce1c1..6751645 100644
--- a/build/build.environment.mk
+++ b/build/build.environment.mk
@@ -24,6 +24,8 @@ LINK_TAGLIB = $(TAGLIB_SHARP_LIBS)
LINK_IPOD = $(IPODSHARP_LIBS)
LINK_BOO = $(BOO_LIBS)
LINK_WEBKIT = $(WEBKIT_LIBS)
+#LINK_ARCHIVE_SHARP = $(ARCHIVE_SHARP_LIBS)
+#LINK_ARCHIVE_SHARP = -pkg:archive-sharp
LINK_MONOTORRENT_DBUS = $(MONOTORRENT_DBUS_LIBS)
LINK_IGEMACINTEGRATION = $(IGEMACINTEGRATIONSHARP_LIBS)
LINK_MONO_ADDINS_DEPS = $(MONO_ADDINS_LIBS)
@@ -124,6 +126,7 @@ REF_EXTENSION_COVERART = $(LINK_BANSHEE_THICKCLIENT_DEPS)
REF_EXTENSION_DAAP = $(LINK_BANSHEE_THICKCLIENT_DEPS) $(LINK_ICSHARP_ZIP_LIB) $(LINK_MONO_ZEROCONF)
REF_EXTENSION_FILESYSTEMQUEUE = $(LINK_BANSHEE_THICKCLIENT_DEPS)
REF_EXTENSION_INTERNETRADIO = $(LINK_BANSHEE_THICKCLIENT_DEPS)
+REF_EXTENSION_INTERNETARCHIVE = $(LINK_BANSHEE_THICKCLIENT_DEPS)
REF_EXTENSION_MINIMODE = $(LINK_BANSHEE_THICKCLIENT_DEPS)
REF_EXTENSION_MULTIMEDIAKEYS = $(LINK_BANSHEE_SERVICES_DEPS)
REF_EXTENSION_NOTIFICATIONAREA = $(LINK_BANSHEE_THICKCLIENT_DEPS)
diff --git a/configure.ac b/configure.ac
index 7458282..718519c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -272,6 +272,7 @@ src/Extensions/Banshee.Bpm/Makefile
src/Extensions/Banshee.CoverArt/Makefile
src/Extensions/Banshee.Daap/Makefile
src/Extensions/Banshee.FileSystemQueue/Makefile
+src/Extensions/Banshee.InternetArchive/Makefile
src/Extensions/Banshee.InternetRadio/Makefile
src/Extensions/Banshee.Lastfm/Makefile
src/Extensions/Banshee.MiniMode/Makefile
diff --git a/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive.addin.xml b/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive.addin.xml
new file mode 100644
index 0000000..d974d7f
--- /dev/null
+++ b/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive.addin.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Addin
+ id="Banshee.InternetArchive"
+ version="1.0"
+ compatVersion="1.0"
+ copyright="© 2008 Novell Inc. Licensed under the MIT X11 license."
+ name="Banshee.InternetArchive"
+ category=""
+ description="Browse and search the Internet Archive's vast collection."
+ author="Gabriel Burt"
+ url="http://banshee-project.org/"
+ defaultEnabled="true">
+
+ <Dependencies>
+ <Addin id="Banshee.Services" version="1.0"/>
+ <Addin id="Banshee.ThickClient" version="1.0"/>
+ </Dependencies>
+
+ <Extension path="/Banshee/SourceManager/Source">
+ <Source class="Banshee.InternetArchive.Source"/>
+ </Extension>
+</Addin>
diff --git a/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/HeaderFilters.cs b/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/HeaderFilters.cs
new file mode 100644
index 0000000..695ac7c
--- /dev/null
+++ b/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/HeaderFilters.cs
@@ -0,0 +1,89 @@
+//
+// HeaderFilters.cs
+//
+// Authors:
+// Gabriel Burt <gburt novell com>
+//
+// Copyright (C) 2009 Novell, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+using Gtk;
+using Mono.Unix;
+
+using IA=InternetArchive;
+
+namespace Banshee.InternetArchive
+{
+ public class HeaderFilters : HBox
+ {
+ public HeaderFilters ()
+ {
+ Spacing = 6;
+
+ BuildMediaTypeCombo ();
+ BuildSortCombo ();
+ }
+
+ private void BuildMediaTypeCombo ()
+ {
+ var store = new TreeStore (typeof (string), typeof (string));
+ foreach (var mediatype in IA.MediaType.Options.OrderBy (t => t.Name)) {
+ if (mediatype.Id != "software") {
+ var iter = store.AppendValues (mediatype.Id, mediatype.Name);
+
+ if (mediatype.Children != null) {
+ foreach (var child in mediatype.Children.OrderBy (t => t.Name)) {
+ store.AppendValues (iter, child.Id, child.Name);
+ }
+ }
+ }
+ }
+
+ var combo = new ComboBox ();
+ combo.Model = store;
+
+ var cell = new CellRendererText ();
+ combo.PackStart (cell, true);
+ combo.AddAttribute (cell, "text", 1);
+ combo.Active = 0;
+
+ PackStart (new Label (Catalog.GetString ("Show")), false, false, 0);
+ PackStart (combo, false, false, 0);
+ }
+
+ private void BuildSortCombo ()
+ {
+ var combo = ComboBox.NewText ();
+
+ combo.AppendText (Catalog.GetString ("Popular This Week"));
+ combo.AppendText (Catalog.GetString ("Popular"));
+ combo.AppendText (Catalog.GetString ("Rated"));
+
+ PackStart (new Label (Catalog.GetString ("Sort by")), false, false, 0);
+ PackStart (combo, false, false, 0);
+ }
+ }
+}
diff --git a/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/Source.cs b/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/Source.cs
new file mode 100644
index 0000000..027499a
--- /dev/null
+++ b/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/Source.cs
@@ -0,0 +1,165 @@
+//
+// Source.cs
+//
+// Authors:
+// Gabriel Burt <gburt novell com>
+//
+// Copyright (C) 2009 Novell, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+using Mono.Unix;
+
+using Hyena.Collections;
+using Hyena.Data.Sqlite;
+
+using Banshee.Collection;
+using Banshee.Collection.Database;
+using Banshee.Configuration;
+using Banshee.Database;
+using Banshee.Gui;
+using Banshee.Library;
+using Banshee.MediaEngine;
+using Banshee.PlaybackController;
+using Banshee.Playlist;
+using Banshee.Preferences;
+using Banshee.ServiceStack;
+using Banshee.Sources;
+
+namespace Banshee.InternetArchive
+{
+ public class Source : Banshee.Sources.PrimarySource
+ {
+ private static string name = Catalog.GetString ("Internet Archive");
+
+ private Gtk.Widget header_widget;
+
+ public Source () : base (name, name, "internet-archive", 210)
+ {
+ IsLocal = false;
+ // TODO Should probably support normal playlists at some point (but not smart playlists)
+ SupportsPlaylists = false;
+ //Properties.SetStringList ("Icon.Name", "video-x-generic", "video", "source-library");
+
+ Properties.SetString ("TrackView.ColumnControllerXml", String.Format (@"
+ <column-controller>
+ <add-default column=""IndicatorColumn"" visible=""true"" />
+ <add-default column=""TitleColumn"" visible=""true"" />
+ <add-default column=""ArtistColumn"" visible=""true"" />
+ <add-default column=""CommentColumn"" visible=""true"" />
+ <add-default column=""RatingColumn"" />
+ <add-default column=""DurationColumn"" visible=""true"" />
+ <add-default column=""GenreColumn"" />
+ <add-default column=""YearColumn"" />
+ <add-default column=""FileSizeColumn"" visible=""true"" />
+ <add-default column=""PlayCountColumn"" visible=""true"" />
+ <add-default column=""MimeTypeColumn"" visible=""true"" />
+ <add-default column=""LicenseUriColumn"" />
+ <column modify-default=""ArtistColumn"">
+ <title>{0}</title><long-title>{0}</long-title>
+ </column>
+ <column modify-default=""PlayCountColumn"">
+ <title>{1}</title><long-title>{1}</long-title>
+ </column>
+ <column modify-default=""CommentColumn"">
+ <title>{2}</title><long-title>{2}</long-title>
+ </column>
+ </column-controller>",
+ Catalog.GetString ("Creator"), Catalog.GetString ("Downloads"), Catalog.GetString ("Description")
+ ));
+
+ AfterInitialized ();
+
+ DatabaseTrackModel.ForcedSortQuery = "CoreTracks.TrackID ASC";
+ DatabaseTrackModel.CanReorder = false;
+
+ if (header_widget == null) {
+ header_widget = new HeaderFilters ();
+ header_widget.ShowAll ();
+ Properties.Set<Gtk.Widget> ("Nereid.SourceContents.HeaderWidget", header_widget);
+ }
+ }
+
+ public override void Activate ()
+ {
+ base.Activate ();
+ }
+
+ /*public override bool AcceptsInputFromSource (Source source)
+ {
+ return false;
+ }*/
+
+ // DatabaseSource overrides
+
+ public override bool ShowBrowser {
+ get { return false; }
+ }
+
+ public override bool CanShuffle {
+ get { return false; }
+ }
+
+ public override bool CanAddTracks {
+ get { return false; }
+ }
+
+ public override bool CanRemoveTracks {
+ get { return false; }
+ }
+
+ public override bool CanDeleteTracks {
+ get { return false; }
+ }
+
+ protected override bool HasArtistAlbum {
+ get { return false; }
+ }
+
+ public override bool HasEditableTrackProperties {
+ get { return false; }
+ }
+
+ public override bool CanSearch {
+ get { return false; }
+ }
+
+ protected override void Initialize ()
+ {
+ base.Initialize ();
+
+ //InstallPreferences ();
+ }
+
+ /*public void Dispose ()
+ {
+ if (actions != null) {
+ actions.Dispose ();
+ }
+
+ UninstallPreferences ();
+ }*/
+ }
+}
diff --git a/src/Extensions/Banshee.InternetArchive/InternetArchive/Field.cs b/src/Extensions/Banshee.InternetArchive/InternetArchive/Field.cs
new file mode 100644
index 0000000..55064cd
--- /dev/null
+++ b/src/Extensions/Banshee.InternetArchive/InternetArchive/Field.cs
@@ -0,0 +1,77 @@
+//
+// Field.cs
+//
+// Author:
+// Gabriel Burt <gabriel burt gmail com>
+//
+// Copyright (c) 2009 Gabriel Burt
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+
+using Hyena.Query;
+
+namespace InternetArchive
+{
+ public class Field
+ {
+ /*avg_rating
+ call_number
+ collection
+ contributor
+ coverage
+
+ creator
+ date
+ description
+ downloads
+ foldoutcount
+ format
+ headerImage
+ identifier
+ imagecount
+
+ language
+ licenseurl
+ mediatype
+ month
+ num_reviews
+ oai_updatedate
+ publicdate
+ publisher
+ rights
+
+ scanningcentre
+ source
+ subject
+ title
+ type
+ volume
+ week
+ year*/
+
+ public string Name { get; protected set; }
+ public string Id { get; set; }
+
+ public Field ()
+ {
+ }
+ }
+}
diff --git a/src/Extensions/Banshee.InternetArchive/InternetArchive/FieldValue.cs b/src/Extensions/Banshee.InternetArchive/InternetArchive/FieldValue.cs
new file mode 100644
index 0000000..c9d356d
--- /dev/null
+++ b/src/Extensions/Banshee.InternetArchive/InternetArchive/FieldValue.cs
@@ -0,0 +1,44 @@
+//
+// FieldValue.cs
+//
+// Author:
+// Gabriel Burt <gabriel burt gmail com>
+//
+// Copyright (c) 2009 Gabriel Burt
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+
+using Hyena.Query;
+
+namespace InternetArchive
+{
+ public class FieldValue
+ {
+ public string Name { get; private set; }
+ public string Id { get; private set; }
+
+ public FieldValue (string id, string name)
+ {
+ Id = id;
+ Name = name;
+ }
+ }
+}
diff --git a/src/Extensions/Banshee.InternetArchive/InternetArchive/MediaType.cs b/src/Extensions/Banshee.InternetArchive/InternetArchive/MediaType.cs
new file mode 100644
index 0000000..e05cc2e
--- /dev/null
+++ b/src/Extensions/Banshee.InternetArchive/InternetArchive/MediaType.cs
@@ -0,0 +1,100 @@
+//
+// MediaType.cs
+//
+// Author:
+// Gabriel Burt <gabriel burt gmail com>
+//
+// Copyright (c) 2009 Gabriel Burt
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using System.Collections.Generic;
+
+using Mono.Unix;
+
+namespace InternetArchive
+{
+ public class MediaType : FieldValue
+ {
+ private MediaType (string id, string name) : base (id, name) {}
+
+ private MediaType AddChildren (params MediaType [] children)
+ {
+ if (Children == null) {
+ Children = new List<MediaType> ();
+ }
+
+ foreach (var child in children) {
+ Children.Add (child);
+ }
+
+ return this;
+ }
+
+ public IList<MediaType> Children { get; set; }
+
+ public static MediaType [] Options = new MediaType [] {
+ new MediaType ("movies", Catalog.GetString ("Moving Images")).AddChildren (
+ new MediaType ("movies.animationandcartoons", Catalog.GetString ("Animation & Cartoons")),
+ new MediaType ("movies.artsandmusicvideos", Catalog.GetString ("Arts & Music")),
+ new MediaType ("movies.computersandtechvideos", Catalog.GetString ("Computers & Technology")),
+ new MediaType ("movies.culturalandacademicfilms", Catalog.GetString ("Cultural & Academic Films")),
+ new MediaType ("movies.ephemera", Catalog.GetString ("Ephemeral Films")),
+ new MediaType ("movies.home_movies", Catalog.GetString ("Home Movies")),
+ new MediaType ("movies.moviesandfilms", Catalog.GetString ("Movies")),
+ new MediaType ("movies.newsandpublicaffairs", Catalog.GetString ("News & Public Affairs")),
+ new MediaType ("movies.opensource_movies", Catalog.GetString ("Open Source Movies")),
+ new MediaType ("movies.prelinger", Catalog.GetString ("Prelinger Archives")),
+ new MediaType ("movies.spiritualityandreligion", Catalog.GetString ("Spirituality & Religion")),
+ new MediaType ("movies.sports", Catalog.GetString ("Sports Videos")),
+ new MediaType ("movies.gamevideos", Catalog.GetString ("Videogame Videos")),
+ new MediaType ("movies.vlogs", Catalog.GetString ("Vlogs")),
+ new MediaType ("movies.youth_media", Catalog.GetString ("Youth Media"))
+ ),
+ new MediaType ("texts", Catalog.GetString ("Texts")).AddChildren (
+ new MediaType ("texts.americana", Catalog.GetString ("American Libraries")),
+ new MediaType ("texts.toronto", Catalog.GetString ("Canadian Libraries")),
+ new MediaType ("texts.universallibrary", Catalog.GetString ("Universal Library")),
+ new MediaType ("texts.gutenberg", Catalog.GetString ("Project Gutenberg")),
+ new MediaType ("texts.iacl", Catalog.GetString ("Children's Library")),
+ new MediaType ("texts.biodiversity", Catalog.GetString ("Biodiversity Heritage Library")),
+ new MediaType ("texts.additional_collections", Catalog.GetString ("Additional Collections"))
+ ),
+ new MediaType ("audio", Catalog.GetString ("Audio")).AddChildren (
+ new MediaType ("audio.audio_bookspoetry", Catalog.GetString ("Audio Books & Poetry")),
+ new MediaType ("audio.audio_tech", Catalog.GetString ("Computers & Technology")),
+ new MediaType ("audio.GratefulDead", Catalog.GetString ("Grateful Dead")),
+ new MediaType ("audio.etree", Catalog.GetString ("Live Music Archive")),
+ new MediaType ("audio.audio_music", Catalog.GetString ("Music & Arts")),
+ new MediaType ("audio.netlabels", Catalog.GetString ("Netlabels")),
+ new MediaType ("audio.audio_news", Catalog.GetString ("News & Public Affairs")),
+ new MediaType ("audio.audio_foreign", Catalog.GetString ("Non-English Audio")),
+ new MediaType ("audio.opensource_audio", Catalog.GetString ("Open Source Audio")),
+ new MediaType ("audio.audio_podcast", Catalog.GetString ("Podcasts")),
+ new MediaType ("audio.radioprograms", Catalog.GetString ("Radio Programs")),
+ new MediaType ("audio.audio_religion", Catalog.GetString ("Spirituality & Religion"))
+ ),
+ new MediaType ("education", Catalog.GetString ("Education")),
+ new MediaType ("software", Catalog.GetString ("Software")).AddChildren (
+ new MediaType ("software.clasp", Catalog.GetString ("CLASP"))
+ )
+ };
+ }
+}
diff --git a/src/Extensions/Banshee.InternetArchive/InternetArchive/ResultsFormat.cs b/src/Extensions/Banshee.InternetArchive/InternetArchive/ResultsFormat.cs
new file mode 100644
index 0000000..c668d3b
--- /dev/null
+++ b/src/Extensions/Banshee.InternetArchive/InternetArchive/ResultsFormat.cs
@@ -0,0 +1,45 @@
+//
+// ResultsFormat.cs
+//
+// Author:
+// Gabriel Burt <gabriel burt gmail com>
+//
+// Copyright (c) 2009 Gabriel Burt
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+
+namespace InternetArchive
+{
+ public class ResultsFormat
+ {
+ public static ResultsFormat Xml = new ResultsFormat ("xml");
+ public static ResultsFormat Json = new ResultsFormat ("json");
+ public static ResultsFormat Html = new ResultsFormat ("tables");
+ public static ResultsFormat Csv = new ResultsFormat ("csv");
+
+ public string Id { get; private set; }
+
+ public ResultsFormat (string id)
+ {
+ Id = id;
+ }
+ }
+}
diff --git a/src/Extensions/Banshee.InternetArchive/InternetArchive/Search.cs b/src/Extensions/Banshee.InternetArchive/InternetArchive/Search.cs
new file mode 100644
index 0000000..043bac2
--- /dev/null
+++ b/src/Extensions/Banshee.InternetArchive/InternetArchive/Search.cs
@@ -0,0 +1,142 @@
+//
+// Search.cs
+//
+// Author:
+// Gabriel Burt <gabriel burt gmail com>
+//
+// Copyright (c) 2009 Gabriel Burt
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+using System.IO;
+using System.Net;
+using System.Linq;
+using System.Collections.Generic;
+
+namespace InternetArchive
+{
+ public static class Test
+ {
+ public static void Main ()
+ {
+ Hyena.Log.Debugging = true;
+ var resp = new Search ().GetResults ();
+ Console.WriteLine ("response:\n{0}", resp);
+
+ var json = new Hyena.Json.Deserializer (resp);
+ Console.WriteLine ("json:\n");
+ (json.Deserialize () as Hyena.Json.JsonObject).Dump ();
+
+ /*title subject description
+ creator
+ downloads
+ num_reviews
+ licenseurl*/
+ }
+ }
+
+ public class Search
+ {
+ List<Sort> sorts = new List<Sort> ();
+ List<Field> result_fields = new List<Field> ();
+ int NumResults;
+ ResultsFormat format;
+ //bool indent = false;
+
+ public IList<Field> ReturnFields { get { return result_fields; } }
+ public IList<Sort> SortBy { get { return sorts; } }
+
+ static Search () {
+ //UserAgent = "InternetArchiveSharp";
+ TimeoutMs = 20000;
+ }
+
+ public Search ()
+ {
+ format = ResultsFormat.Json;
+ NumResults = 50;
+
+ result_fields.Add (new Field () { Id = "identifier" });
+ result_fields.Add (new Field () { Id = "title" });
+ result_fields.Add (new Field () { Id = "creator" });
+
+ sorts.Add (new Sort () { Id = "avg_rating desc" });
+ }
+
+ private string GetQuery ()
+ {
+ var sb = new System.Text.StringBuilder ();
+
+ sb.AppendFormat ("q={0}", "(collection%3Aaudio+OR+mediatype%3Aaudio)+AND+-mediatype%3Acollection");
+
+ foreach (var field in result_fields) {
+ sb.AppendFormat ("&fl[]={0}", System.Web.HttpUtility.UrlEncode (field.Id));
+ }
+
+ foreach (var sort in sorts) {
+ sb.AppendFormat ("&sort[]={0}", System.Web.HttpUtility.UrlEncode (sort.Id));
+ }
+
+ sb.AppendFormat ("&rows={0}", NumResults);
+ sb.AppendFormat ("&fmt={0}", format.Id);
+ sb.Append ("&xmlsearch=Search");
+
+ return sb.ToString ();
+ }
+
+ public string GetResults ()
+ {
+ HttpWebResponse response = null;
+ string url = null;
+
+ try {
+ url = String.Format ("http://www.archive.org/advancedsearch.php?{0}", GetQuery ());
+ Hyena.Log.Debug ("ArchiveSharp Searching", url);
+
+ var request = (HttpWebRequest) WebRequest.Create (url);
+ request.UserAgent = UserAgent;
+ request.Timeout = TimeoutMs;
+ request.KeepAlive = KeepAlive;
+
+ response = (HttpWebResponse) request.GetResponse ();
+ using (Stream stream = response.GetResponseStream ()) {
+ using (StreamReader reader = new StreamReader (stream)) {
+ return reader.ReadToEnd ();
+ }
+ }
+ } catch (Exception e) {
+ Hyena.Log.Exception (String.Format ("Error searching {0}", url), e);
+ return null;
+ } finally {
+ if (response != null) {
+ if (response.StatusCode != HttpStatusCode.OK) {
+ Hyena.Log.WarningFormat ("Got status {0} searching {1}", response.StatusCode, url);
+ }
+ response.Close ();
+ response = null;
+ }
+ }
+ }
+
+ public static string UserAgent { get; set; }
+ public static bool KeepAlive { get; set; }
+ public static int TimeoutMs { get; set; }
+ }
+}
diff --git a/src/Extensions/Banshee.InternetArchive/InternetArchive/Sort.cs b/src/Extensions/Banshee.InternetArchive/InternetArchive/Sort.cs
new file mode 100644
index 0000000..7a10db8
--- /dev/null
+++ b/src/Extensions/Banshee.InternetArchive/InternetArchive/Sort.cs
@@ -0,0 +1,95 @@
+//
+// Sort.cs
+//
+// Author:
+// Gabriel Burt <gabriel burt gmail com>
+//
+// Copyright (c) 2009 Gabriel Burt
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+using System;
+
+namespace InternetArchive
+{
+ /*
+ "" = relevance
+ addeddate desc
+ addeddate asc
+ avg_rating desc
+ avg_rating asc
+ call_number desc
+
+ call_number asc
+ createdate desc
+ createdate asc
+ creatorSorter desc
+ creatorSorter asc
+ date desc
+ date asc
+ downloads desc
+ downloads asc
+
+ foldoutcount desc
+ foldoutcount asc
+ headerImage desc
+ headerImage asc
+ identifier desc
+ identifier asc
+ imagecount desc
+ imagecount asc
+ indexdate desc
+
+ indexdate asc
+ languageSorter desc
+ languageSorter asc
+ licenseurl desc
+ licenseurl asc
+ month desc
+ month asc
+ nav_order desc
+ nav_order asc
+
+ num_reviews desc
+ num_reviews asc
+ publicdate desc
+ publicdate asc
+ reviewdate desc
+ reviewdate asc
+ stars desc
+ stars asc
+ titleSorter desc
+
+ titleSorter asc
+ updatedate desc
+ updatedate asc
+ week desc
+ week asc
+ year desc
+ year asc */
+
+ public class Sort
+ {
+ public Sort ()
+ {
+ }
+
+ public string Id { get; set; }
+ }
+}
diff --git a/src/Extensions/Banshee.InternetArchive/Makefile.am b/src/Extensions/Banshee.InternetArchive/Makefile.am
new file mode 100644
index 0000000..e7dd75e
--- /dev/null
+++ b/src/Extensions/Banshee.InternetArchive/Makefile.am
@@ -0,0 +1,19 @@
+ASSEMBLY = Banshee.InternetArchive
+TARGET = library
+LINK = $(REF_EXTENSION_INTERNETARCHIVE)
+INSTALL_DIR = $(EXTENSIONS_INSTALL_DIR)
+
+SOURCES = \
+ InternetArchive/Field.cs \
+ InternetArchive/FieldValue.cs \
+ InternetArchive/MediaType.cs \
+ InternetArchive/ResultsFormat.cs \
+ InternetArchive/Search.cs \
+ InternetArchive/Sort.cs \
+ Banshee.InternetArchive/HeaderFilters.cs \
+ Banshee.InternetArchive/Source.cs
+
+RESOURCES = Banshee.InternetArchive.addin.xml
+
+include $(top_srcdir)/build/build.mk
+
diff --git a/src/Extensions/Makefile.am b/src/Extensions/Makefile.am
index caef9f9..f2a6a03 100644
--- a/src/Extensions/Makefile.am
+++ b/src/Extensions/Makefile.am
@@ -6,6 +6,7 @@ SUBDIRS = \
Banshee.CoverArt \
Banshee.Daap \
Banshee.FileSystemQueue \
+ Banshee.InternetArchive \
Banshee.InternetRadio \
Banshee.Lastfm \
Banshee.MiniMode \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]