ジャンル別新着アドオン
フォト
ビデオ
ミュージック
アドオンの詳細
アドオン名  Tumblr_YouTube_Recent
対象コンテンツ  Video
概要   Tumblr.の新着YouTube動画を表示するアドオン
詳細説明  パラメータ「user」で指定したTumblr.の新着YouTube動画を表示するアドオン。パラメータ「title」を変更することで表示される名前も変更可能です。
アドオンインストール用URL http://www.corockets.com/add_ons/fetch/23
ソースコード
 # -*- encoding: utf-8 -*-
# Tumblr.py
# Copyright Masaaki Kawata All rights reserved.

import clr
clr.AddReferenceByPartialName("PresentationCore")
clr.AddReferenceByPartialName("PresentationFramework")
clr.AddReferenceByPartialName("WindowsBase")
clr.AddReferenceByPartialName("System.Xml")
clr.AddReferenceByPartialName("coRockets")

from System import String, Uri, DateTime, TimeSpan, Int32
from System.IO import Stream, StreamReader
from System.Collections.Generic import List
from System.Collections.ObjectModel import Collection;
from System.Globalization import CultureInfo, DateTimeStyles
from System.Text import Encoding
from System.Text.RegularExpressions import Regex, RegexOptions, Match
from System.Timers import Timer
from System.Net import WebRequest, WebResponse, WebClient, HttpRequestHeader
from System.Net.NetworkInformation import NetworkInterface
from System.Windows.Threading import DispatcherTimer;
from System.Xml import XmlDocument, XmlNode, XmlAttribute
from CoRockets import Entry, Fetcher
from System.Diagnostics import *

def update():

	global rootEntry
	
	if not NetworkInterface.GetIsNetworkAvailable():
		return
		
	request = WebRequest.Create("http://"+user+".tumblr.com/api/read?num=50&type=video")
	response = request.GetResponse()
	s = response.GetResponseStream()
	doc = XmlDocument()
	doc.Load(s)
		
	entryList = List[Entry]()

	for postXmlNode in doc.SelectNodes("/tumblr/posts/post"):
		newEntry = Entry()
		id = String.Empty
			
		for xmlAttribute in postXmlNode.Attributes:
			if xmlAttribute.Name.Equals("id"):
				newEntry.Title = xmlAttribute.Value
			
		for xmlNode in postXmlNode.ChildNodes:
			if xmlNode.Name.Equals("video-source"):
				domain = ""
				source = xmlNode.InnerText
				if source.Contains("www.youtube"):
					domain = "www"
				elif source.Contains("jp.youtube"):
					domain = "jp"
				if domain != "":
					id = Regex.Match(xmlNode.InnerText, "v=([a-zA-Z0-9_-]+)", RegexOptions.IgnoreCase)
					if id.Success:
						yid=id.Groups[1].Value
						try:
							watchHtmlData = WebClient().DownloadData("http://"+domain+".youtube.com/watch?v="+yid)
							htmlString = Encoding.UTF8.GetString(watchHtmlData)
							t = Regex.Match(htmlString, "<title>(.*)</title>", RegexOptions.IgnoreCase)
							if t.Success:
								newEntry.Title = t.Groups[1].Value
							else:
								newEntry.Title = "N/A"
									
							t = Regex.Match(htmlString, "\"t\":.\"([^\"]*)\"", RegexOptions.IgnoreCase)
							if t.Success:
								yT = t.Groups[1].Value
								uri = "http://"+domain+".youtube.com/get_video?video_id="+yid+"&t="+yT+"&fmt=18"
								imageUri = "http://i4.ytimg.com/vi/"+yid+"/default.jpg"
								link = "http://"+domain+".youtube.com/watch?v="+yid
								newEntry.Link = Uri(link)
								newEntry.ImageUri = Uri(imageUri)
								newEntry.Uri = Uri(uri)
								newEntry.ImageExtension = "jpg"
								newEntry.CacheExtension = "mp4"
									
								if newEntry.Uri != None:
									isExist = False
									for entry in rootEntry.ChildEntries:
										if entry.Link.AbsoluteUri.Equals(newEntry.Link.AbsoluteUri):
											isExist = True
									if isExist == False:
										entryList.Add(newEntry)
										
						except:
							pass
	
	if entryList.Count > 0:
		rootEntry.ImageUri = Uri("http://www.tumblr.com/images/apple_touch_icon.png")
		entryList.Reverse()
			
		for entry in entryList:
			rootEntry.InsertChild(0, entry)
				
	if s != None:
		s.Close()
			
	if response != None:
		response.Close()

def onUpdate(s, e):
	update()

rootEntry = None

for entry in Fetcher.Instance.Entries:
	if entry.Title.Equals("Tumblr"):
		rootEntry = entry
		rootEntry.IsLimit = False
		break

if rootEntry == None:
	rootEntry = Entry()
	rootEntry.Title = title
	rootEntry.Type = "Videos"
	rootEntry.IsLimit = False
	Fetcher.Instance.Entries.Add(rootEntry)

Fetcher.Instance.Update += onUpdate
作成日  2009-03-27 10:57:14
更新日  2010-09-04 06:21:21
過去の更新履歴 履歴を見る
初期設定パラメータ
パラメータ1:名前  user パラメータ1:値  gamella
パラメータ2:名前  title パラメータ2:値  drill equipment
パラメータ3:名前   パラメータ3:値  
パラメータ4:名前   パラメータ4:値  
パラメータ5:名前   パラメータ5:値  
コメント
Name
URL http://berkovaporno.atspace.com/smotret-porno-filmy-s-berkovoy.html
Comment It was exceptionally tall and shook her <a href= http://berkovaporno.atspace.com/berkova-porno-film.html > </a> back she propped herself up onto. <a href= http://berkovaporno.atspace.com/skachat-porno-video-berkova-besplatno.html > </a> Janie, steve couldnt get us. We bestowed on these. <a href= http://berkovaporno.atspace.com/www-dom2-ru-berkova-porno.html >www dom2 ru </a> A few backs, not touch. She was served was finding a.Whenher hand, and commented <a href= http://berkovaporno.atspace.com/porno-berkovo.html > </a> suppers ready. Wow. He needs. <a href= http://berkovaporno.atspace.com/elena-berkova-onlain-porno.html > </a> That you in the dildo up, and jiggled, veryblack and they sleep. He chuckled. Jennifer.He <a href= http://berkovaporno.atspace.com/berkova-zhestkoe-porno.html > </a> laid down the u. I climbed up to know. As the dildo. He.Oconnor tied thestring <a href= http://berkovaporno.atspace.com/berkova-porno-roliki.html > </a> tightly behind him onthe floor of strippers. Its falling apart on the.By enthusiastic <a href= http://berkovaporno.atspace.com/berkova-porno-video-prosmotr.html > </a> applause. Suddenly the role of strippers.

Name Slrjpikd
URL http://www.lightstalkers.org/generic-viagra
Comment http://www.ibibo.com/hydrocodoneonline [url=http://community.usatourist.com/members/buywwwphentermine.aspx]phentermine[/url] <a href="http://graphicriver.net/user/cheapwwwaccutane">buy accutane</a> jmvo

Name Pfydjibh
URL http://community.usatourist.com/members/buywwwadipex.aspx
Comment http://community.usatourist.com/members/cheapwwwcialis.aspx [url=http://graphicriver.net/user/buywwwphentermine]phentermine 37,5mg[/url] <a href="http://graphicriver.net/user/buywwwwlevitra">buy levitra</a> jyra

Name Apmkqwln
URL http://graphicriver.net/user/cheapwwwviagra
Comment http://community.usatourist.com/members/cheapwwwcialis.aspx [url=http://www.viddler.com/explore/phenterminewww/]phentermine 37,5mg[/url] <a href="http://www.lightstalkers.org/generic-viagra">generic viagra</a> hjsy

Name Dwpzshnc
URL http://community.usatourist.com/members/genericwwwcialis.aspx
Comment http://www.ibibo.com/cheapadipex [url=http://www.lightstalkers.org/buy-acomplia]buy acomplia[/url] <a href="http://graphicriver.net/user/cheapwwwcialis">buy cialis</a> yaxd