1# documentation: http://delicious.com/help/api 2 3package require rest 4 5set delicious(updated) { 6 url https://api.del.icio.us/v1/posts/update 7 auth basic 8 result raw 9 post_transform { 10 regexp {<update time=\"(.*?)\"} $result -> update 11 return [clock scan [string map {T " " Z " UTC"} $update]] 12 } 13} 14 15set delicious(add_post) { 16 url https://api.del.icio.us/v1/posts/add 17 auth basic 18 req_args { url: description: } 19 opt_args { extended: tags: dt: replace: shared: } 20 check_result { {[regexp {<result code=\"done} $result]} {} } 21} 22 23set delicious(delete_post) { 24 url https://api.del.icio.us/v1/posts/delete 25 auth basic 26 req_args { url: } 27 check_result { {[regexp {<result code=\"done} $result]} {} } 28} 29 30set delicious(get_posts) { 31 url https://api.del.icio.us/v1/posts/get 32 auth basic 33 opt_args { url: tag: dt: hashes: meta: } 34} 35 36set delicious(recent_posts) { 37 url https://api.del.icio.us/v1/posts/recent 38 auth basic 39 opt_args { tag: } 40} 41 42set delicious(post_dates) { 43 url https://api.del.icio.us/v1/posts/dates 44 auth basic 45 opt_args { tag: count: } 46} 47 48set delicious(get_all_posts) { 49 url https://api.del.icio.us/v1/posts/all 50 auth basic 51 opt_args { tag: start: results: fromdt: todt: meta: } 52} 53 54set delicious(get_hashes) { 55 url https://api.del.icio.us/v1/posts/all 56 auth basic 57 static_args { hashes {} } 58} 59 60set delicious(get_tags) { 61 url https://api.del.icio.us/v1/tags/get 62 auth basic 63} 64 65set delicious(delete_tag) { 66 url https://api.del.icio.us/v1/tags/delete 67 auth basic 68 req_args { tag: } 69 check_result { {[regexp {<result>done} $result]} {} } 70} 71 72set delicious(rename_tag) { 73 url https://api.del.icio.us/v1/tags/rename 74 auth basic 75 req_args { old: new: } 76 check_result { {[regexp {<result>done} $result]} {} } 77} 78 79set delicious(get_bundles) { 80 url https://api.del.icio.us/v1/bundles/all 81 auth basic 82 opt_args { bundle: } 83} 84 85set delicious(set_bundle) { 86 url https://api.del.icio.us/v1/bundles/set 87 auth basic 88 req_args { bundle: tags: } 89 check_result { {[regexp {<result>ok} $result]} {} } 90} 91 92set delicious(delete_bundle) { 93 url https://api.del.icio.us/v1/bundles/delete 94 auth basic 95 req_args { bundle: } 96 check_result { {[regexp {<result>done} $result]} {} } 97} 98 99set delicious(public_posts) { 100 url http://feeds.delicious.com/v2/json/%user%/%tags:% 101 opt_args { count: } 102} 103 104set delicious(modify_post) { 105 url https://api.del.icio.us/v1/posts/add 106 auth basic 107 req_args { post: } 108 opt_args { description: extended: tags: dt: shared: } 109 check_result { {[regexp {<result code=\"done} $result]} {} } 110 result raw 111 input_transform { 112 set new [dict remove [dict get $query post] hash others meta] 113 foreach {from to} {href url tag tags time dt} { 114 set v [dict get $new $from] 115 set new [dict remove $new $from] 116 dict set new $to $v 117 } 118 dict for {k v} [dict remove $query post] { 119 if {$v == ""} { 120 set new [dict remove $new $k] 121 continue 122 } 123 if {$k == "dt"} { set v [string trimright $v Z] } 124 125 set new [dict replace $new $k $v] 126 } 127 return $new 128 } 129} 130 131rest::create_interface delicious 132