Esempio n. 1
0
static gboolean
ttrss_feed_subscription_prepare_update_request (subscriptionPtr subscription, 
                                                 struct updateRequest *request)
{
	debug0 (DEBUG_UPDATE, "ttrss_feed_subscription_prepare_update_request()");
	nodePtr root = node_source_root_from_node (subscription->node);
	ttrssSourcePtr source = (ttrssSourcePtr) root->data;
	const gchar *feed_id;
	gchar *source_name;

	debug0 (DEBUG_UPDATE, "preparing tt-rss feed subscription for update");
	
	g_assert(source); 
	if (source->loginState == TTRSS_SOURCE_STATE_NONE) { 
		subscription_update (root->subscription, 0);
		return FALSE;
	}
	
	feed_id = metadata_list_get (subscription->metadata, "ttrss-feed-id");
	if (!feed_id) {
		g_warning ("tt-rss feed without id! (%s)", subscription->node->title);
		return FALSE;
	}
	request->postdata = g_strdup_printf (TTRSS_JSON_HEADLINES, source->session_id, feed_id, 15 /* items to fetch */ );
	source_name = g_strdup_printf (TTRSS_URL, metadata_list_get (root->subscription->metadata, "ttrss-url"));
	update_request_set_source (request, source_name);
	g_free (source_name);

	return TRUE;
}
Esempio n. 2
0
static gboolean
reedah_feed_subscription_prepare_update_request (subscriptionPtr subscription, 
                                                 struct updateRequest *request)
{
	debug0 (DEBUG_UPDATE, "preparing Reedah feed subscription for update\n");
	ReedahSourcePtr source = (ReedahSourcePtr) node_source_root_from_node (subscription->node)->data; 
	
	g_assert(source); 
	if (source->root->source->loginState == NODE_SOURCE_STATE_NONE) { 
		subscription_update (node_source_root_from_node (subscription->node)->subscription, 0) ;
		return FALSE;
	}

	if (!metadata_list_get (subscription->metadata, "reedah-feed-id")) {
		g_warning ("Skipping Reedah feed '%s' (%s) without id!", subscription->source, subscription->node->id);
		return FALSE;
	}

	debug0 (DEBUG_UPDATE, "Setting cookies for a Reedah subscription");
	gchar* source_escaped = g_uri_escape_string(metadata_list_get (subscription->metadata, "reedah-feed-id"), NULL, TRUE);
	// FIXME: move to .h
	// FIXME: do not use 30
	gchar* newUrl = g_strdup_printf ("http://www.reedah.com/reader/api/0/stream/contents/%s?client=liferea&n=30", source_escaped);
	update_request_set_source (request, newUrl);
	g_free (newUrl);
	g_free (source_escaped);

	update_request_set_auth_value (request, source->root->source->authToken);
	return TRUE;
}
Esempio n. 3
0
/* 
 * Check if folder of a node changed in TinyTinyRSS and move
 * node to the correct folder.
 */
static void
ttrss_source_update_folder (ttrssSourcePtr source, nodePtr node)
{
	nodePtr		parent;
	gint		category;
	const gchar	*feedId;

	feedId = (const gchar *)metadata_list_get (node->subscription->metadata, "ttrss-feed-id");
	if (!feedId)
		return;

	category = GPOINTER_TO_INT (g_hash_table_lookup (source->categories, GINT_TO_POINTER (atoi (feedId))));
	parent = g_hash_table_lookup (source->categoryToNode, GINT_TO_POINTER (category));
	if (!parent)
		return;

	if (parent != node->parent) {
		debug2 (DEBUG_UPDATE, "TinyTinyRSS Moving node \"%s\" to folder \"%s\"", node->title, parent->title);
		node_reparent (node, parent);
	}

	/* if feed has no category and parent is not source root, reparent to source root */
	if (parent == NULL && node->parent != source->root) {
		debug1 (DEBUG_UPDATE, "TinyTinyRSS Moving node \"%s\" back to root", node->title);
		node_reparent (node, source->root);
	}
}
Esempio n. 4
0
static void
ns_itunes_parse_channel_tag (feedParserCtxtPtr ctxt, xmlNodePtr cur)
{
	gchar *tmp;
	const gchar *old;

	if (!xmlStrcmp (cur->name, BAD_CAST"summary") || !xmlStrcmp (cur->name, BAD_CAST"subtitle")) {
		tmp = xhtml_extract (cur, 0, NULL);
		old = metadata_list_get (ctxt->subscription->metadata, "description");
		if (!old || strlen (old) < strlen (tmp))
			metadata_list_set (&ctxt->subscription->metadata, "description", tmp);
		g_free (tmp);
	}
}
Esempio n. 5
0
static void
atom10_parse_entry_updated (xmlNodePtr cur, feedParserCtxtPtr ctxt, struct atom10ParserState *state)
{
	gchar *datestr;
	
	datestr = (gchar *)xmlNodeListGetString (cur->doc, cur->xmlChildrenNode, 1);
	/* if pubDate is already set, don't overwrite it */
	if (datestr && !metadata_list_get(ctxt->item->metadata, "pubDate")) {
		ctxt->item->time = date_parse_ISO8601 (datestr);
		ctxt->item->metadata = metadata_list_append (ctxt->item->metadata, "contentUpdateDate", datestr);
	}

	g_free (datestr);
}
Esempio n. 6
0
static gboolean
ttrss_feed_subscription_prepare_update_request (subscriptionPtr subscription, 
                                                 struct updateRequest *request)
{
	nodePtr		root = node_source_root_from_node (subscription->node);
	ttrssSourcePtr	source = (ttrssSourcePtr) root->data;
	const gchar	*feed_id;
	gchar		*source_name;
	gint		fetchCount;

	debug0 (DEBUG_UPDATE, "TinyTinyRSS preparing feed subscription for update");

	// FIXME: if (!source->selfUpdating) trigger remote update first!
	
	g_assert(source); 
	if (source->loginState == TTRSS_SOURCE_STATE_NONE) { 
		subscription_update (root->subscription, 0);
		return FALSE;
	}
	
	feed_id = metadata_list_get (subscription->metadata, "ttrss-feed-id");
	if (!feed_id) {
		g_warning ("Fatal: TinyTinyRSS feed without id! (%s)", subscription->node->title);
		return FALSE;
	}

	/* We can always max out as TinyTinyRSS does limit results itself */	
	fetchCount = feed_get_max_item_count (subscription->node);

	request->postdata = g_strdup_printf (TTRSS_JSON_HEADLINES, source->session_id, feed_id, fetchCount);
	source_name = g_strdup_printf (TTRSS_URL, source->url);
	update_request_set_source (request, source_name);
	g_free (source_name);

	return TRUE;
}
Esempio n. 7
0
const gchar *
subscription_get_homepage (subscriptionPtr subscription)
{
	return metadata_list_get (subscription->metadata, "homepage");
}