;; combine APIs and other web available bibliographic data. ;; Use amazon, LibraryThing, and OCLC Worldcat. ;; Get ISBN numbers for a book by searching author and title. ;; Get the list of available ISBNs from different sources. ;; Get "tags" available for a book from LibraryThing for ;; a given book. ;; etc. ;; ;; N.B. A person from LibraryThing.com posted a comment ;; regarding this program, indicating that the tag cloud data ;; is copyrighted. ;; ;; Here's the quoted message: ;; ;; Tim's message: "And it's fine here, as a test, and probably in other ;; contexts where it could be considered "fair use" under copyright. ;; But--unlike the thingISBN service and some other LibraryThing ;; APIs--LibraryThing's tag clouds are not free for public use, ;; outside of the RSS feeds and widgets we provide. ;; We're not sure how and under what license to ;; release them when we do." ;; ;; So, I wrote this for fun. If I were you I wouldn't run it, just read ;; the code. :-) ;; (define (search-worldcat title author) (setq title (replace " " title "+")) (setq author (replace " " author "+")) (get-url (append "http://worldcatlibraries.org/search?q=ti:" title "+au:" author "&qt=advanced"))) (setq oclc-url-1-pattern {<div class="name"><a href=}) (define (oclc-url-1 str) (setq loc (find oclc-url-1-pattern str)) (setq loc (+ loc (length oclc-url-1-pattern))) (setq loc (+ 1 loc)) (setq loc-end (find ">" (loc -1 str))) (setq loc-end (- loc-end 1)) (setq loc-url (loc loc-end str)) (println (append "http://worldcatlibraries.org" loc-url)) (get-url (append "http://worldcatlibraries.org" loc-url))) (setq oclc-isbn-pattern "<strong>ISBN: </strong>") (define (find-isbn str) (setq loc (find oclc-isbn-pattern str)) (setq loc (+ loc (length oclc-isbn-pattern))) (setq loc-end (find "</li>" (loc -1 str))) (loc loc-end str)) (define (thing-isbn isbn) (xml-type-tags nil nil nil nil) (setq isbn-data (xml-parse (get-url (append "http://www.librarything.com/api/thingISBN/" isbn))))) (define (get-isbn-list isbn-data) (setq indexer (ref "isbn" isbn-data)) (nth-set 2 indexer 2) (setq num-isbns (length (isbn-data 0))) (setq isbn-list '()) (for (idx (first (1 indexer)) (- num-isbns 1)) (push (isbn-data (first (0 indexer)) idx (first (2 indexer))) isbn-list -1)) isbn-list) (define (add-explorer-path) (env "PATH" (append (env "PATH" ) ";c:\\program files\\internet explorer"))) (define (show-amazon-isbn isbn) (process (append "iexplore " "http://www.amazon.com/exec/obidos/ASIN/" isbn ))) (define (get-librarything-isbn isbn) (get-url (append "http://librarything.com/isbn/" isbn))) (define (get-librarything-tagsection str) (setq loc (find "Tags used" str )) (setq mystr (loc -1 str)) (setq loc-end (find "</div>" mystr)) (0 loc-end mystr)) (define (get-librarything-taglist mystr) (setq tags-list '()) (while (setq tag-loc (find "/tag/" mystr)) (setq tag-loc-end (find "target=" (tag-loc -1 mystr))) (push ((+ tag-loc 5) (- tag-loc-end 7) mystr) tags-list -1) (setq mystr ((+ tag-loc tag-loc-end ) -1 mystr))) tags-list) (define (show-librarything-tag tag) (process (append "iexplore " "http://www.librarything.com/tag/" tag )))
You need to create an account or log in to post comments to this site.