Gonzih / feeds2imap.clj

Pull RSS/Atom feeds to your IMAP folders with Clojure on JVM.
http://feeds2imap.gonzih.me/
MIT License
31 stars 6 forks source link

opml import broken? #7

Closed vitalyster closed 8 years ago

vitalyster commented 9 years ago
$ ~/bin/lein feeds2imap opml2clj opml.xml
clojure.lang.ArityException: Wrong number of args (0) passed to: opml/convert-and-print-from-file!
 at clojure.lang.AFn.throwArity (AFn.java:429)
    clojure.lang.AFn.invoke (AFn.java:28)
    feeds2imap.core$_main$fn__1636$fn__1637$fn__1638$fn__1639$fn__1640$fn__1641$fn__1642.invoke (core.clj:100)
    feeds2imap.core$_main$fn__1636$fn__1637$fn__1638$fn__1639$fn__1640$fn__1641.invoke (core.clj:93)
    feeds2imap.core$_main$fn__1636$fn__1637$fn__1638$fn__1639$fn__1640.invoke (core.clj:93)
    feeds2imap.core$_main$fn__1636$fn__1637$fn__1638$fn__1639.invoke (core.clj:93)
    feeds2imap.core$_main$fn__1636$fn__1637$fn__1638.invoke (core.clj:93)
    feeds2imap.core$_main$fn__1636$fn__1637.invoke (core.clj:93)
    feeds2imap.core$_main$fn__1636.invoke (core.clj:93)
    feeds2imap.core$_main.doInvoke (core.clj:93)
    clojure.lang.RestFn.applyTo (RestFn.java:137)
    clojure.core$apply.invoke (core.clj:624)
    leiningen.feeds2imap$feeds2imap.doInvoke (feeds2imap.clj:23)
    clojure.lang.RestFn.invoke (RestFn.java:439)
    clojure.lang.Var.invoke (Var.java:388)
    clojure.lang.AFn.applyToHelper (AFn.java:160)
    clojure.lang.Var.applyTo (Var.java:700)
    clojure.core$apply.invoke (core.clj:626)
    leiningen.core.main$partial_task$fn__6094.doInvoke (main.clj:263)
    clojure.lang.RestFn.applyTo (RestFn.java:139)
    clojure.lang.AFunction$1.doInvoke (AFunction.java:29)
    clojure.lang.RestFn.applyTo (RestFn.java:137)
    clojure.core$apply.invoke (core.clj:626)
    leiningen.core.main$apply_task.invoke (main.clj:313)
    leiningen.core.main$resolve_and_apply.invoke (main.clj:319)
    leiningen.core.main$_main$fn__6160.invoke (main.clj:392)
    leiningen.core.main$_main.doInvoke (main.clj:385)
    clojure.lang.RestFn.invoke (RestFn.java:436)
    clojure.lang.Var.invoke (Var.java:388)
    clojure.lang.AFn.applyToHelper (AFn.java:160)
    clojure.lang.Var.applyTo (Var.java:700)
    clojure.core$apply.invoke (core.clj:624)
    clojure.main$main_opt.invoke (main.clj:315)
    clojure.main$main.doInvoke (main.clj:420)
    clojure.lang.RestFn.invoke (RestFn.java:482)
    clojure.lang.Var.invoke (Var.java:401)
    clojure.lang.AFn.applyToHelper (AFn.java:171)
    clojure.lang.Var.applyTo (Var.java:700)
    clojure.main.main (main.java:37)
[vt@my ~]$ ~/bin/lein feeds2imap opml2clj opml.xml urls.clj
Can't handle arguments (opml2clj opml.xml urls.clj)
Gonzih commented 9 years ago

Yep, sorry about that. I released version 0.1.8 of plugin. Please try it out.

vitalyster commented 9 years ago

got {:__global__ (nil nil nil nil nil nil nil nil nil nil)} with opml version 2.0.

Gonzih commented 9 years ago

ompl support was implemented by @astanin, I might have free time to take a look at the implementation and try to figure out what is wrong in the next few days. Anyway it would be helpful if you could provide some example file that I can use for testing.

vitalyster commented 9 years ago

Current opml2clj implementation expects opml file to have the following structure:

<outline title="{This goes to imap folder name}">
  <outline xmlUrl="{this will be added as an rss url to parent element folder}" />
</outline>

I have the flat list of outlines as in this example with title and xmlUrl, and want to turn each outline into a folder. Got it with patch https://github.com/vitalyster/feeds2imap.clj/commit/a0763fb47c6bcfea3aa34f59db177d53aa599e48

Gonzih commented 9 years ago

Cool. So is current version is broken or just supports some different format? I'm not an expert on opml thingy.

astanin commented 9 years ago

Hi,

it appears that according to OPML specs <outline>s can be arbitrary nested; so OPML's body may be a flat list like in @vitalyster's example, or it maybe nested list of subscriptions like what Google Reader, Feedly, The Old Reader and others export. Both variants seem to be valid OPML.

From the OPML specs http://dev.opml.org/spec2.html:

What is a <body>?

A <body> contains one or more <outline> elements.

What is an <outline>?

An <outline> is an XML element containing at least one required attribute, text, and zero or more additional attributes. An <outline> may contain zero or more <outline> sub-elements. No attribute may be repeated within the same <outline> element.

...

Subscription lists

A subscription list is a possibly multiple-level list of subscriptions to feeds. Each sub-element of the body of the OPML document is a node of type rss or an outline element that contains nodes of type rss.

So outline element in OPML may have different roles:

vitalyster commented 9 years ago

@astanin my opml was generated by Yandex.Lenta, and Feedly successfully imported it as one "uncategorized" folder and multiple subfolders for each url. feeds2imap trying to add my rss outlines as multiple urls of a single "global" folder, and this case is broken. When feeds2imap will support subfolders, it will be possible to fix implementation in both cases.

Gonzih commented 9 years ago

@vitalyster I think you can already use subfolders, folders are generated as Rss/foldername. So nothing is stopping you from specifying folder/subfoldername as a foldername in that case. You just need probably take care of transformation. Should we think about universal solution that will detect different types of opml format?