<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: worldcat code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Thu, 21 Aug 2008 05:53:34 GMT</pubDate>
    <description>DZone Snippets: worldcat code</description>
    <item>
      <title>library mashup</title>
      <link>http://snippets.dzone.com/posts/show/2737</link>
      <description>// description of your code here&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;;; combine APIs and other web available bibliographic data.&lt;br /&gt;;; Use amazon, LibraryThing, and OCLC Worldcat.&lt;br /&gt;;; Get ISBN numbers for a book by searching author and title.&lt;br /&gt;;; Get the list of available ISBNs from different sources.&lt;br /&gt;;; Get "tags" available for a book from LibraryThing for&lt;br /&gt;;; a given book.&lt;br /&gt;;; etc.&lt;br /&gt;;;&lt;br /&gt;;; N.B. A person from LibraryThing.com posted a comment&lt;br /&gt;;; regarding this program, indicating that the tag cloud data&lt;br /&gt;;; is copyrighted. &lt;br /&gt;;;&lt;br /&gt;;; Here's the quoted message:&lt;br /&gt;;;&lt;br /&gt;;; Tim's message: "And it's fine here, as a test, and probably in other &lt;br /&gt;;; contexts where it could be considered "fair use" under copyright. &lt;br /&gt;;; But--unlike the thingISBN service and some other LibraryThing &lt;br /&gt;;; APIs--LibraryThing's tag clouds are not free for public use, &lt;br /&gt;;; outside of the RSS feeds and widgets we provide. &lt;br /&gt;;; We're not sure how and under what license to &lt;br /&gt;;; release them when we do."&lt;br /&gt;;;&lt;br /&gt;;; So, I wrote this for fun.  If I were you I wouldn't run it, just read&lt;br /&gt;;; the code.  :-)&lt;br /&gt;;;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;(define (search-worldcat title author)&lt;br /&gt;  (setq title (replace " " title "+"))&lt;br /&gt;  (setq author (replace " " author "+"))&lt;br /&gt;  (get-url (append "http://worldcatlibraries.org/search?q=ti:" title "+au:" author "&amp;qt=advanced")))&lt;br /&gt;&lt;br /&gt;(setq oclc-url-1-pattern {&lt;div class="name"&gt;&lt;a href=})&lt;br /&gt;&lt;br /&gt;(define (oclc-url-1 str)&lt;br /&gt;  (setq loc (find oclc-url-1-pattern str))&lt;br /&gt;  (setq loc (+ loc (length oclc-url-1-pattern)))&lt;br /&gt;  (setq loc (+ 1 loc))&lt;br /&gt;  (setq loc-end (find "&gt;" (loc -1 str)))&lt;br /&gt;  (setq loc-end (- loc-end 1))&lt;br /&gt;  (setq loc-url (loc loc-end str))&lt;br /&gt;  (println (append "http://worldcatlibraries.org" loc-url))&lt;br /&gt;  (get-url (append "http://worldcatlibraries.org" loc-url)))&lt;br /&gt;&lt;br /&gt;(setq oclc-isbn-pattern "&lt;strong&gt;ISBN: &lt;/strong&gt;")&lt;br /&gt;&lt;br /&gt;(define (find-isbn str)&lt;br /&gt;  (setq loc (find oclc-isbn-pattern str))&lt;br /&gt;  (setq loc (+ loc (length oclc-isbn-pattern)))&lt;br /&gt;  (setq loc-end (find "&lt;/li&gt;" (loc -1 str)))&lt;br /&gt;  (loc loc-end str))&lt;br /&gt;&lt;br /&gt;(define (thing-isbn isbn)&lt;br /&gt;  (xml-type-tags nil nil nil nil)&lt;br /&gt;  (setq isbn-data &lt;br /&gt;      (xml-parse (get-url  &lt;br /&gt;          (append "http://www.librarything.com/api/thingISBN/" isbn)))))&lt;br /&gt;&lt;br /&gt;(define (get-isbn-list isbn-data)&lt;br /&gt;  (setq indexer (ref "isbn" isbn-data))&lt;br /&gt;  (nth-set 2 indexer 2)&lt;br /&gt;  (setq num-isbns (length  (isbn-data 0)))&lt;br /&gt;  (setq isbn-list '())&lt;br /&gt;  (for (idx (first (1 indexer))  (- num-isbns 1))&lt;br /&gt;        (push (isbn-data (first (0 indexer)) idx (first (2 indexer))) isbn-list -1))&lt;br /&gt;   isbn-list)&lt;br /&gt;&lt;br /&gt;(define (add-explorer-path)&lt;br /&gt;   (env "PATH" (append (env "PATH" ) ";c:\\program files\\internet explorer")))&lt;br /&gt;&lt;br /&gt;(define (show-amazon-isbn isbn)&lt;br /&gt;   (process (append "iexplore " "http://www.amazon.com/exec/obidos/ASIN/"&lt;br /&gt;           isbn )))&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;(define (get-librarything-isbn isbn)&lt;br /&gt;    (get-url (append "http://librarything.com/isbn/" isbn)))&lt;br /&gt;&lt;br /&gt;(define (get-librarything-tagsection str)&lt;br /&gt;    (setq loc (find "Tags used" str ))&lt;br /&gt;    (setq mystr (loc -1 str))&lt;br /&gt;    (setq loc-end (find "&lt;/div&gt;" mystr))&lt;br /&gt;     (0 loc-end mystr))&lt;br /&gt;&lt;br /&gt;(define (get-librarything-taglist mystr)&lt;br /&gt;    (setq tags-list '())&lt;br /&gt;    (while (setq tag-loc (find "/tag/" mystr))&lt;br /&gt;        (setq tag-loc-end (find "target=" (tag-loc -1 mystr)))&lt;br /&gt;        (push ((+ tag-loc 5) (- tag-loc-end 7) mystr) tags-list -1)&lt;br /&gt;        (setq mystr ((+ tag-loc tag-loc-end ) -1 mystr)))&lt;br /&gt;    tags-list)&lt;br /&gt;&lt;br /&gt;(define (show-librarything-tag tag)&lt;br /&gt;   (process (append "iexplore " "http://www.librarything.com/tag/"&lt;br /&gt;           tag )))&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 30 Sep 2006 03:52:13 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2737</guid>
      <author>frontera000 (bob bae)</author>
    </item>
  </channel>
</rss>
