Bug Tracker
SourceForge
Feedback
Wiki
Stor
It is currently August 18th, 2017, 8:06 pm




 Page 1 of 1 [ 10 posts ] 
Author Message
 Post subject: [Official Thread] MeeMedia plug-in - National Geographic Ima
PostMessage posted...: February 8th, 2011, 2:49 pm 
User avatar
More than 1000 posts
More than 1000 posts
Developer

Joined: June 23rd, 2006, 1:04 am
Posts: 1661
Location: Groningen, the Netherlands
Netherlands
National Geographic Images - MeeMedia plug-in.
* Official release and support thread *

Description: Browse and view nature images from http://www.nationalgeographic.com/
Repository: Main (http://meemedia.svn.sourceforge.net/vie ... a_plugins/)
Author: Ztoner

Changelog:
changelog.txt (SourceForge SVN)

Register entry:
plug-in.dat (SourceForge SVN)

Plug-in code:
National_Geographic.cs (SourceForge SVN)

Settings file:
<none>

Icon base:


Attachments:
National Geographic.png
National Geographic.png [ 55.57 KiB | Viewed 1612 times ]

_________________
DJ Heemstra a.k.a. blubberhoofd
Offline
 Profile  
 
 Post subject: Re: [Official Thread] MeeMedia plug-in - National Geographic
PostMessage posted...: November 21st, 2011, 11:51 pm 
User avatar
More than 6000 posts
More than 6000 posts

Joined: July 3rd, 2006, 1:25 pm
Posts: 6508
Location: UK
"Best of the month" not working.

All the rest is working fine.



_________________
HTPC - xbmc eden/meedios, mce remote, 40gb intel ssd, i5, 4gb ram | Storage - 2 x qnap 8tb 419p+ NAS
Kitchen/Bar - Wall mounted Motorola Xoom tablet | Mobile - Ipad 2 | My setup pics
Offline
 Profile  
 
 Post subject: Re: [Official Thread] MeeMedia plug-in - National Geographic
PostMessage posted...: November 22nd, 2011, 8:14 am 
User avatar
More than 1000 posts
More than 1000 posts

Joined: December 8th, 2006, 11:14 pm
Posts: 1393
Location: Sweden, Stockholm
I'll take a look tonight...

*** Richard ***


Offline
 Profile  
 
 Post subject: Re: [Official Thread] MeeMedia plug-in - National Geographic
PostMessage posted...: November 22nd, 2011, 5:00 pm 
User avatar
More than 1000 posts
More than 1000 posts

Joined: December 8th, 2006, 11:14 pm
Posts: 1393
Location: Sweden, Stockholm
Best Of Month FIXED 8)

using System;
using System.IO;
using MeediOS;
using SharedFunctions;
using MeeMedia.Interfaces;
namespace MeeMedia.Plugin.National_Geographic
{
    public class National_Geographic : IMeeMediaPlugin
    {
        SharedFunctions.Functions SF = new SharedFunctions.Functions();
        public string Listings(string settings)
        {
            return "Newest|http://photography.nationalgeographic.com/photography/photo-of-the-day/archive?&page=;Best Of The Month|Best_Of;By Category|show_per_category";
        }
        public string GetItems(string caption, string url, int page, IMeedioSystem meedioSystem, IMeedioMenu plugin_page_menu, string SearchString, string settings)
        {
            try
            {
                plugin_page_menu.Clear();
                string plugin_icon = SF.GetRegExMatch(settings, @"<plugin_icon>(?<name>[^<]+)", "name");

                if (url == "Best_Of")
                {
                    string content = SF.GetHttpDecode("http://photography.nationalgeographic.com/photography/best-of-photo-of-the-day/", System.Text.Encoding.UTF8);
                    string selection1 = SF.GetRegExMatch(content, @"<div id=""content_mainA"" class="""">(?<name>[\W\w]+)?<div class=""promo_collection thumbnail_grid"">", "name");
                    string selection2 = SF.GetRegExMatch(content, @"<div class=""promo_collection thumbnail_grid"">(?<name>[\W\w]+)?<div id=""content_mainB"" class=""aside"">", "name");
                    foreach (string Unit in SF.GetRegExMatchCollection(selection1, @"<li[\W\w]+?</li>"))
                    {
                        IMeedioItem item = meedioSystem.NewItem();
                        item["caption"] = SF.FixText(SF.GetRegExMatch(Unit, @"title=""(?<name>[^""]+)", "name"));
                        item["image"] = SF.GetRegExMatch(Unit, @"src=""(?<name>[^""]+)", "name");
                        item["description"] = "";
                        item["medialink"] = "repeat::";
                        item["reference"] = "Photos_of_the_month::" + "http://photography.nationalgeographic.com" + SF.GetRegExMatch(Unit, @"<a href=""(?<name>[^""]+)", "name");
                        plugin_page_menu.Add(item);
                    }
                    foreach (string Unit in SF.GetRegExMatchCollection(selection1, @"{[\W\w]+?}"))
                    {
                        IMeedioItem item = meedioSystem.NewItem();
                        item["caption"] = SF.FixText(SF.GetRegExMatch(Unit, @"headline: '(?<name>[^']+)", "name").Replace(@"\u0027", "'").Replace(@"Pictures", ""));
                        item["image"] = SF.GetRegExMatch(Unit, @"url: '(?<name>[^']+)", "name");
                        item["description"] = "";
                        item["medialink"] = "repeat::";
                        item["reference"] = "Photos_of_the_month::" + "http://photography.nationalgeographic.com" + SF.GetRegExMatch(Unit, @"link: '(?<name>[^']+)", "name").Replace(@"\u002D", "-");
                        plugin_page_menu.Add(item);
                    }
                    foreach (string Unit in SF.GetRegExMatchCollection(selection2, @"<li[\W\w]+?</li>"))
                    {
                        IMeedioItem item = meedioSystem.NewItem();
                        item["caption"] = SF.FixText(SF.GetRegExMatch(Unit, @"title=""(?<name>[^""]+)", "name"));
                        item["image"] = SF.GetRegExMatch(Unit, @"src=""(?<name>[^""]+)", "name");
                        item["description"] = "";
                        item["medialink"] = "repeat::";
                        item["reference"] = "Photos_of_the_month::" + "http://photography.nationalgeographic.com" + SF.GetRegExMatch(Unit, @"<a href=""(?<name>[^""]+)", "name");
                        plugin_page_menu.Add(item);
                    }
                }

                else if (url == "show_per_category")
                {
                    string content = "Adventure & Exploration|adventure-exploration;Animals|animals;Black & White|black-white;History|history;Landscapes|landscapes;Nature & Weather|nature-weather;People & Culture|people-culture;Science & Space|science-space;Travel|travel;Underwater|underwater";
                    foreach (string Unit in content.Split(';'))
                    {
                        IMeedioItem item = meedioSystem.NewItem();
                        item["caption"] = Unit.Split('|')[0];
                        item["image"] = plugin_icon;
                        item["description"] = "";
                        item["medialink"] = "repeat::";
                        item["reference"] = "http://photography.nationalgeographic.com/photography/photo-of-the-day/" + Unit.Split('|')[1] + "?&page=";
                        plugin_page_menu.Add(item);
                    }
                }
                else if (url.Contains("Photos_of_the_month::"))
                {
                    string content = SF.GetHttpDecode(url.Replace("Photos_of_the_month::", ""), System.Text.Encoding.UTF8);
                    content = SF.GetRegExMatch(content, @"<div id=""content_mainA"" class="""">(?<name>[\W\w]+)?<!-- .article_body-->", "name");
                    if (content.Contains("jcarousel-skin-gallery"))
                    {
                        foreach (string Unit in SF.GetRegExMatchCollection(content, @"<li>[\W\w]+?</li>"))
                        {
                            IMeedioItem item = meedioSystem.NewItem();
                            item["caption"] = SF.FixText(SF.GetRegExMatch(Unit, @"<h2>(?<name>[^<]+)", "name"));
                            item["image"] = item["image"] = SF.GetRegExMatch(Unit, @"src=""(?<name>[^""]+)", "name");
                            item["description"] = SF.FixText(SF.GetRegExMatch(Unit, @"</p><p>(?<name>[^<]+)", "name"));
                            if (SF.GetRegExMatch(Unit, @"""><a href=""(?<name>[^""]+)", "name") != "")
                            { item["medialink"] = SF.GetRegExMatch(Unit, @"""><a href=""(?<name>[^""]+)", "name"); }
                            else
                            { item["medialink"] = SF.GetRegExMatch(Unit, @"href='(?<name>[^']+)", "name"); }
                            item["mediatype"] = "image";
                            item["reference"] = "";
                            plugin_page_menu.Add(item);
                        }
                    }
                    else
                    {
                        foreach (string Unit in SF.GetRegExMatchCollection(content, @"primary_photo[\W\w]+?</div><!-- .article_text-->"))
                        {
                            IMeedioItem item = meedioSystem.NewItem();
                            item["caption"] = SF.FixText(SF.GetRegExMatch(Unit, @"<h2>(?<name>[^<]+)", "name")) + "\n";
                            foreach (string category in SF.GetRegExMatchCollection(Unit, @"<div id=""caption"">[^']+"))
                            { item["caption"] = item["caption"].ToString() + SF.FixText(SF.GetRegExMatch(category, @"<p><b>(?<name>[^<]+)", "name")) + " " + SF.FixText(SF.GetRegExMatch(category, @"<p class=""publication_time"">(?<name>[^<]+)", "name")); }
                            item["image"] = SF.GetRegExMatch(Unit, @"src=""(?<name>[^""]+)", "name");
                            item["description"] = SF.FixText(SF.GetRegExMatch(Unit, @"<p> (?<name>[^<]+)", "name"));
                            item["medialink"] = SF.GetRegExMatch(Unit, @"src=""(?<name>[^""]+)", "name");
                            item["mediatype"] = "image";
                            item["reference"] = "";
                            plugin_page_menu.Add(item);
                        }
                    }
                }
                else
                {
                    plugin_page_menu.Clear();
                    string content = SF.GetHttp(url + page.ToString());
                    if (content != null)
                    {
                        content = SF.GetRegExMatch(content, @"thumbnail_grid(?<name>[\W\w]+)?content_mainA", "name");
                        if (page > 1)
                        {
                            IMeedioItem item = meedioSystem.NewItem();
                            item["caption"] = "previous (page " + (page - 1).ToString() + ")";
                            item["image"] = "previous-img";
                            item["medialink"] = "previous::" + (page - 1);
                            item["reference"] = url;
                            item["mediatype"] = "image";
                            item["description"] = "Go to the previous page.";
                            plugin_page_menu.Add(item);
                        }
                        foreach (string Unit in SF.GetRegExMatchCollection(content, @"<div>[\W\w]+?a></p>"))
                        {
                            IMeedioItem item = meedioSystem.NewItem();
                            item["caption"] = SF.FixText(SF.GetRegExMatch(Unit, @"<h4>(?<name>[^<]+)", "name")) + "\n";
                            foreach (string category in SF.GetRegExMatchCollection(Unit, @"<p class=[^<]+"))
                            { item["caption"] = item["caption"].ToString() + SF.FixText(SF.GetRegExMatch(category, @"<p class=""publication_time"">(?<name>[^<]+)", "name")); }
                            item["image"] = SF.GetRegExMatch(Unit, @"src=""(?<name>[^""]+)", "name");
                            item["medialink"] = SF.GetRegExMatch(Unit, @"<a href=""(?<name>[^""]+)", "name");
                            item["description"] = SF.FixText(SF.GetRegExMatch(Unit, @"<p>(?<name>[^<]+)", "name"));
                            item["mediatype"] = "image";
                            plugin_page_menu.Add(item);
                        }
                        if (content.Contains(">Next &"))
                        {
                            IMeedioItem item = meedioSystem.NewItem();
                            item["caption"] = "next (page " + (page + 1).ToString() + ")";
                            item["image"] = "next-img";
                            item["medialink"] = "next::" + (page + 1);
                            item["reference"] = url;
                            item["mediatype"] = "image";
                            item["description"] = "Go to the next page.";
                            plugin_page_menu.Add(item);
                        }
                    }
                }
                return "success";
            }
            catch (Exception e)
            {
                return "error: " + e.ToString();
            }
        }
        public string Play(IMeedioMenu menu, IMeedioItem item, string settings)
        {
            try
            {
                string test = item["medialink"].ToString();

                if (test.StartsWith("/"))
                {
                    string content = SF.GetHttpDecode("http://photography.nationalgeographic.com" + item["medialink"].ToString(), System.Text.Encoding.UTF8);
                    content = SF.GetRegExMatch(content, @"<div id=""content_top"">(?<name>[\W\w]+)?article_text", "name");
                    if (SF.GetRegExMatch(content, @"""download_link""><a href=""(?<name>[^""]+)", "name").StartsWith("http"))
                    {
                        menu.Selected["storelink"] = SF.GetRegExMatch(content, @"""download_link""><a href=""(?<name>[^""]+)", "name");
                        return SF.GetRegExMatch(content, @"""download_link""><a href=""(?<name>[^""]+)", "name");
                    }
                    else
                    {
                        menu.Selected["storelink"] = SF.GetRegExMatch(content, @"<img src=""(?<name>[^""]+)", "name");
                        return SF.GetRegExMatch(content, @"<img src=""(?<name>[^""]+)", "name");
                    }
                }

                else
                {
                    menu.Selected["storelink"] = item["medialink"].ToString();
                    return item["medialink"].ToString();
                }

            }
            catch (Exception e)
            {
                return "error: " + e.ToString();
            }
        }
        public string Store(IMeedioMenu menu, IMeedioItem item, string settings)
        {
            return "";
        }
    }
}


*** Richard ***


Last edited by ztoner on November 22nd, 2011, 9:25 pm, edited 1 time in total.

Offline
 Profile  
 
 Post subject: Re: [Official Thread] MeeMedia plug-in - National Geographic
PostMessage posted...: November 22nd, 2011, 9:05 pm 
User avatar
More than 1000 posts
More than 1000 posts
Developer

Joined: June 23rd, 2006, 1:04 am
Posts: 1661
Location: Groningen, the Netherlands
Netherlands
released updated version by ztoner



_________________
DJ Heemstra a.k.a. blubberhoofd
Offline
 Profile  
 
 Post subject: Re: [Official Thread] MeeMedia plug-in - National Geographic
PostMessage posted...: November 22nd, 2011, 9:14 pm 
User avatar
More than 1000 posts
More than 1000 posts

Joined: December 8th, 2006, 11:14 pm
Posts: 1393
Location: Sweden, Stockholm
blubberhoofd wrote:
released updated version by ztoner


hmm something went wrong I think, did you "update" with old the script? OR did I send You the old :lol:

EDIT: nope you must have "updated" with same script 8)


Offline
 Profile  
 
 Post subject: Re: [Official Thread] MeeMedia plug-in - National Geographic
PostMessage posted...: November 22nd, 2011, 11:20 pm 
User avatar
More than 1000 posts
More than 1000 posts
Developer

Joined: June 23rd, 2006, 1:04 am
Posts: 1661
Location: Groningen, the Netherlands
Netherlands
ztoner wrote:
blubberhoofd wrote:
released updated version by ztoner


hmm something went wrong I think, did you "update" with old the script? OR did I send You the old :lol:

EDIT: nope you must have "updated" with same script 8)


nope, apparently the update code isn't fullproof enough and declares success even when it fails to update the .cs file :?

anyway, I've updated the plugins.dat file on the server, replacing the whole of the old national geographic entry.

Update should now be successfull, confirmed?



_________________
DJ Heemstra a.k.a. blubberhoofd
Offline
 Profile  
 
 Post subject: Re: [Official Thread] MeeMedia plug-in - National Geographic
PostMessage posted...: November 23rd, 2011, 12:54 am 
User avatar
More than 1000 posts
More than 1000 posts

Joined: December 8th, 2006, 11:14 pm
Posts: 1393
Location: Sweden, Stockholm
yes worked :!:

I'm working on a re wright of this pluggin adding "Animal", "Travel" and "Adventure" sections It now only works with the "photo of the day" section.
it's an early pluggin of mine, so learned mush since then :P

*** Richard ***


Offline
 Profile  
 
 Post subject: Re: [Official Thread] MeeMedia plug-in - National Geographic
PostMessage posted...: November 23rd, 2011, 1:00 am 
User avatar
More than 1000 posts
More than 1000 posts
Developer

Joined: June 23rd, 2006, 1:04 am
Posts: 1661
Location: Groningen, the Netherlands
Netherlands
looking forward to it :!:



_________________
DJ Heemstra a.k.a. blubberhoofd
Offline
 Profile  
 
 Post subject: Re: [Official Thread] MeeMedia plug-in - National Geographic
PostMessage posted...: November 24th, 2011, 10:51 pm 
User avatar
More than 1000 posts
More than 1000 posts
Developer

Joined: June 23rd, 2006, 1:04 am
Posts: 1661
Location: Groningen, the Netherlands
Netherlands
released revision 7 by ztoner



_________________
DJ Heemstra a.k.a. blubberhoofd
Offline
 Profile  
 
Display posts from previous:  Sort by  
 Page 1 of 1 [ 10 posts ] 


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:

cron