-
-
Save mycccc/3c3024f486e4230ecf5c5879f3b7470e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function doGet(request) { | |
var mid = request.parameter.mid; | |
if (mid && !isNaN(mid)){ | |
var referer = "http://space.bilibili.com/" + mid +"/"; | |
var headers = | |
{ | |
"User-Agent" : "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.59 Safari/537.36", | |
"Referer": referer, | |
"X-Requested-With": "XMLHttpRequest", | |
}; | |
var options = | |
{ | |
"headers" : headers | |
}; | |
var formData = { | |
"mid":mid, | |
"_":"1487150142286" | |
}; | |
var options2 = { | |
'method' : 'post', | |
'payload' : formData, | |
'headers': headers, | |
}; | |
var post_url = "http://space.bilibili.com/ajax/member/GetInfo" | |
var post_response = UrlFetchApp.fetch(post_url, options2); | |
var title = JSON.parse(post_response.getContentText())['data']['name']; | |
Logger.log(title); | |
var url = "http://space.bilibili.com/ajax/member/getSubmitVideos?mid=" + mid + "&pagesize=30&tid=0&keyword=&page=1&_=1477138903325" | |
var response = UrlFetchApp.fetch(url, options); | |
var data = JSON.parse(response.getContentText())['data']['vlist']; | |
// var title = data[0]['author']; | |
// Logger.log(title); | |
var feed = '<?xml version="1.0" encoding="UTF-8"?>' | |
+'<feed xmlns="http://www.w3.org/2005/Atom">' | |
+'<title>' | |
+ title | |
+ '的bilibili空间' | |
+'</title>' | |
+'<link href="' | |
+ referer | |
+'" rel="alternate"/>' | |
+'<id>' | |
+ referer | |
+'</id>' | |
+'<updated>'+(new Date()).toISOString()+'</updated>'; | |
data.forEach(function(e, i) { | |
var video_url = 'http://www.bilibili.com/video/av' + e.aid; | |
var video_content = '<a href="' + video_url + '">' + video_url + '<a>'; | |
var img = "<img src=" + e.pic + " />" | |
// var video_html = '<embed height="415" width="544" quality="high" allowfullscreen="true" type="application/x-shockwave-flash" src="//static.hdslb.com/miniloader.swf" flashvars="aid='+ e.aid +'" pluginspage="//www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash"></embed>' | |
var video_html = '<embed height="415" width="544" quality="high" allowfullscreen="true" type="application/x-shockwave-flash" src="https://static-s.bilibili.com/miniloader.swf?aid='+ e.aid +'"></embed>' | |
feed += '<entry>' | |
+'<title>'+e.title+'</title>' | |
+'<link href="' + video_url + '" rel="alternate"/>' | |
+'<updated>'+e.created+'</updated>' | |
+'<summary>'+e.description+'</summary>' | |
+'<content type="html"><![CDATA[' | |
+e.description + video_content + img | |
+ video_html | |
+']]></content>' | |
+'<author><name>'+e.author+'</name></author>' | |
+'</entry>' | |
}); | |
feed += '</feed>' | |
Logger.log(feed); | |
return ContentService.createTextOutput(feed) | |
.setMimeType(ContentService.MimeType.RSS); | |
} | |
return HtmlService.createHtmlOutput("<h2>invalid uid</h2>") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment