commit f2b37044783f684ba51ed4673f5ca1e5fedd3398
parent 2b376f0baa54a0aeca5e0bfc1b1b671647b84f15
Author: Dominik Schmidt <das1993@hotmail.com>
Date: Sun, 28 Feb 2016 17:35:20 +0100
Adapt to new upstream-changes.
The strange data-layout has changed, and they now deliver invalid HTML
since they somewhere opens a body-tag and never close it m(.
Diffstat:
3 files changed, 18 insertions(+), 21 deletions(-)
diff --git a/DRSS b/DRSS
@@ -1 +1 @@
-Subproject commit 6fce2f381a30845eac233f6a93ba8cf5bdbcfd10
+Subproject commit e32d0ebff216f9defb13a552793ee4a2aa5c534f
diff --git a/Makefile b/Makefile
@@ -14,7 +14,7 @@ standardpaths/libstandardpaths.a: standardpaths/source/standardpaths.o
$(DMD) $(IOPTS) -c $< -of$@
.PHONY:
DRSS/drss.a:
- cd DRSS/; make DMD="$(DMD)" drss.a
+ cd DRSS/; make DMD="$(DMD)" OPTS="$(OPTS) -version=FORGIVING" drss.a
clean:
rm -f *.o standardpaths/source/standardpaths.o
cd DRSS/; make clean
diff --git a/fbstream.d b/fbstream.d
@@ -141,24 +141,10 @@ class FBStream : DRSS!(Post){
headers[1][1]=arr[0].getCData().idup;
headers[0][1]=url;
- XmlNode[] nodes=root.parseXPath(`//code`);
- assert(nodes.length>0);
- generatePosts(nodes);
- }
-
- /**
- * Generates the posts
- * Params: nodes = The `<code></code>` nodes, where the data can be found.
- */
-
- private void generatePosts(XmlNode[] nodes){
- foreach(ref XmlNode node; nodes){
- XmlNode subTree=readDocument((cast(XmlComment)(node.getChildren()[0]))._comment);
- XmlNode[] matches=subTree.parseXPath(`//div[@data-time]`);
- if(matches.length==0){continue;}
- foreach(ref XmlNode match; retro(matches)){
- appendPost(match);
- }
+ XmlNode[] nodes=root.parseXPath(`//div[@class="userContentWrapper _5pcr"]`);
+ assert(nodes.length>0, "No data nodes found!");
+ foreach(node; nodes){
+ appendPost(node);
}
}
@@ -175,7 +161,7 @@ class FBStream : DRSS!(Post){
if(translatediv.length>0){
usercontent[0].removeChild(translatediv[0]);
}
- SysTime t=SysTime(unixTimeToStdTime(to!ulong(match.getAttribute("data-time"))));
+ SysTime t=getPostTimestamp(match);
XmlNode[] href=match.parseXPath(`//a[@class="_5pcq"]`);
string hrefs;
if(href.length!=0){
@@ -185,6 +171,17 @@ class FBStream : DRSS!(Post){
}
/**
+ * Gets the timestamp of a post
+ *
+ */
+ private SysTime getPostTimestamp(XmlNode post){
+ XmlNode[] matches=post.parseXPath(`//abbr[@data-utime]`);
+ assert(matches.length>0, "No date-utime node found in post");
+ string time=matches[0].getAttribute("data-utime");
+ return SysTime(unixTimeToStdTime(to!ulong(time)));
+ }
+
+ /**
* Fetches the raw-data, either from File or from URL
*/
public override bool fetch(){