X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=mixi.el;h=789ba27b8d75be993f3ed4c35109b72f4b36ced5;hb=6eb8092c58724e9bc319322b3fab924ad7aa10ed;hp=7c291770ecbe3e2aefc2a3df3e7bbbf2d68a2188;hpb=28ab4c7b77739c3c4c8304ff37f48d450e0d30c5;p=elisp%2Fmixi.git diff --git a/mixi.el b/mixi.el index 7c29177..789ba27 100644 --- a/mixi.el +++ b/mixi.el @@ -1211,21 +1211,7 @@ Increase this value when unexpected error frequently occurs." (defconst mixi-diary-list-regexp " \\([0-9]+\\)·î\\([0-9]+\\)Æü
\\([0-9]+\\):\\([0-9]+\\)
\\(
\\|\\) - \\(.*\\) - - - - - - -
- -\\(.*\\) - -?
- -
-") + \\(.*\\)") (defun mixi-get-diaries (&rest friend-or-range) "Get diaries of FRIEND." @@ -1255,7 +1241,7 @@ Increase this value when unexpected error frequently occurs." (string-to-number (nth 2 item)) (string-to-number (nth 1 item)) month year) - (nth 6 item) (nth 7 item)))) + (nth 6 item)))) items)))) (defmacro mixi-new-diary-list-page () @@ -2025,8 +2011,7 @@ Increase this value when unexpected error frequently occurs." (defconst mixi-bbs-list '(mixi-topic mixi-event)) (defmacro mixi-bbs-p (object) - `(when (memq (mixi-object-class ,object) mixi-bbs-list) - t)) + `(memq (mixi-object-class ,object) mixi-bbs-list)) (defun mixi-bbs-community (object) "Return the community of OBJECT." @@ -2333,8 +2318,7 @@ Increase this value when unexpected error frequently occurs." (defconst mixi-message-box-list '(inbox outbox savebox thrash)) ; thrash? (defmacro mixi-message-box-p (box) - `(when (memq ,box mixi-message-box-list) - t)) + `(memq ,box mixi-message-box-list)) (defun mixi-message-box-name (box) "Return the name of BOX." @@ -2758,8 +2742,7 @@ Increase this value when unexpected error frequently occurs." sports entertainment IT)) (defmacro mixi-news-category-p (category) - `(when (memq ,category mixi-news-category-list) - t)) + `(memq ,category mixi-news-category-list)) (defun mixi-news-category-id (category) "Return the id of CATEGORY." @@ -2769,9 +2752,24 @@ Increase this value when unexpected error frequently occurs." (1+ (- (length mixi-news-category-list) (length (memq category mixi-news-category-list)))))) -(defmacro mixi-news-list-page (category) - `(concat "http://news.mixi.jp/list_news_category.pl?page=%d&sort=1" - (concat "&id=" (mixi-news-category-id category) "&type=bn"))) +(defconst mixi-news-sort-list '(newest pickup)) + +(defmacro mixi-news-sort-p (sort) + `(memq ,sort mixi-news-sort-list)) + +(defun mixi-news-sort-id (sort) + "Return the id of SORT." + (unless (mixi-news-sort-p sort) + (signal 'wrong-type-argument (list 'mixi-news-sort-p sort))) + (number-to-string + (- (length mixi-news-sort-list) + (length (memq sort mixi-news-sort-list))))) + +(defmacro mixi-news-list-page (category sort) + `(concat "http://news.mixi.jp/list_news_category.pl?page=%d" + "&sort=" (mixi-news-sort-id ,sort) + "&id=" (mixi-news-category-id ,category) + "&type=bn")) (defconst mixi-news-list-regexp " @@ -2783,28 +2781,30 @@ Increase this value when unexpected error frequently occurs." \\(.+\\) \\([0-9]+\\)·î\\([0-9]+\\)Æü \\([0-9]+\\):\\([0-9]+\\)") -(defun mixi-get-news (category &optional range) - "Get news of CATEGORY." +(defun mixi-get-news (category sort &optional range) + "Get news of CATEGORY and SORT." (unless (mixi-news-category-p category) (signal 'wrong-type-argument (list 'mixi-news-category-p category))) - (let ((items (mixi-get-matched-items (mixi-news-list-page category) - mixi-news-list-regexp - range)) - (year (nth 5 (decode-time (current-time)))) - (month (nth 4 (decode-time (current-time))))) - (mapcar (lambda (item) - (let ((month-of-item (string-to-number (nth 6 item)))) - (when (> month-of-item month) - (decf year)) - (setq month month-of-item) - (mixi-make-news (nth 2 item) (nth 1 item) (nth 5 item) - (encode-time - 0 (string-to-number (nth 9 item)) - (string-to-number (nth 8 item)) - (string-to-number (nth 7 item)) - month year) - (nth 3 item)))) - items))) + (unless (mixi-news-sort-p sort) + (signal 'wrong-type-argument (list 'mixi-news-sort-p sort))) + (let ((items (mixi-get-matched-items (mixi-news-list-page category sort) + mixi-news-list-regexp + range)) + (year (nth 5 (decode-time (current-time)))) + (month (nth 4 (decode-time (current-time))))) + (mapcar (lambda (item) + (let ((month-of-item (string-to-number (nth 6 item)))) + (when (> month-of-item month) + (decf year)) + (setq month month-of-item) + (mixi-make-news (nth 2 item) (nth 1 item) (nth 5 item) + (encode-time + 0 (string-to-number (nth 9 item)) + (string-to-number (nth 8 item)) + (string-to-number (nth 7 item)) + month year) + (nth 3 item)))) + items))) (provide 'mixi)