From 4e21f3674d7d4c138c231a6bee2d7cc226d9c293 Mon Sep 17 00:00:00 2001 From: bg66 Date: Sun, 22 Oct 2006 07:03:21 +0000 Subject: [PATCH] * mixi.el (mixi-make-friend): New slog `sex'. (mixi-friend-sex): New accessor method. (mixi-friend-set-sex): Ditto. (mixi-friend-name-sex-regexp): Rename from `mixi-friend-name-regexp'. (mixi-my-name-regexp): Abolish. (mixi-friend-realize): Use them. * mixi.el (mixi-make-friend): New slog `address'. (mixi-friend-address): New accessor method. (mixi-friend-set-address): Ditto. (mixi-friend-address-regexp): New constant. (mixi-friend-realize): Use them. * mixi.el (mixi-make-friend): New slog `age'. (mixi-friend-age): New accessor method. (mixi-friend-set-age): Ditto. (mixi-friend-age-regexp): New constant. (mixi-friend-realize): Use them. * mixi.el (mixi-make-friend): New slog `birthday'. (mixi-friend-birthday): New accessor method. (mixi-friend-set-birthday): Ditto. (mixi-friend-birthday-regexp): New constant. (mixi-friend-realize): Use them. * mixi.el (mixi-make-friend): New slog `blood type'. (mixi-friend-blood-type): New accessor method. (mixi-friend-set-blood-type): Ditto. (mixi-friend-blood-type-regexp): New constant. (mixi-friend-realize): Use them. * mixi.el (mixi-make-friend): New slog `birthplace'. (mixi-friend-birthplace): New accessor method. (mixi-friend-set-birthplace): Ditto. (mixi-friend-birthplace-regexp): New constant. (mixi-friend-realize): Use them. * mixi.el (mixi-make-friend): New slog `hobby'. (mixi-friend-hobby): New accessor method. (mixi-friend-set-hobby): Ditto. (mixi-friend-hobby-regexp): New constant. (mixi-friend-realize): Use them. * mixi.el (mixi-make-friend): New slog `job'. (mixi-friend-job): New accessor method. (mixi-friend-set-job): Ditto. (mixi-friend-job-regexp): New constant. (mixi-friend-realize): Use them. * mixi.el (mixi-make-friend): New slog `organization'. (mixi-friend-organization): New accessor method. (mixi-friend-set-organization): Ditto. (mixi-friend-organization-regexp): New constant. (mixi-friend-realize): Use them. * mixi.el (mixi-make-friend): New slog `profile'. (mixi-friend-profile): New accessor method. (mixi-friend-set-profile): Ditto. (mixi-friend-profile-regexp): New constant. (mixi-friend-realize): Use them. --- ChangeLog | 63 +++++++++++++++++++ mixi.el | 207 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 253 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7ee42b6..7975a1b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,66 @@ +2006-10-22 OHASHI Akira + + * mixi.el (mixi-make-friend): New slog `sex'. + (mixi-friend-sex): New accessor method. + (mixi-friend-set-sex): Ditto. + (mixi-friend-name-sex-regexp): Rename from `mixi-friend-name-regexp'. + (mixi-my-name-regexp): Abolish. + (mixi-friend-realize): Use them. + + * mixi.el (mixi-make-friend): New slog `address'. + (mixi-friend-address): New accessor method. + (mixi-friend-set-address): Ditto. + (mixi-friend-address-regexp): New constant. + (mixi-friend-realize): Use them. + + * mixi.el (mixi-make-friend): New slog `age'. + (mixi-friend-age): New accessor method. + (mixi-friend-set-age): Ditto. + (mixi-friend-age-regexp): New constant. + (mixi-friend-realize): Use them. + + * mixi.el (mixi-make-friend): New slog `birthday'. + (mixi-friend-birthday): New accessor method. + (mixi-friend-set-birthday): Ditto. + (mixi-friend-birthday-regexp): New constant. + (mixi-friend-realize): Use them. + + * mixi.el (mixi-make-friend): New slog `blood type'. + (mixi-friend-blood-type): New accessor method. + (mixi-friend-set-blood-type): Ditto. + (mixi-friend-blood-type-regexp): New constant. + (mixi-friend-realize): Use them. + + * mixi.el (mixi-make-friend): New slog `birthplace'. + (mixi-friend-birthplace): New accessor method. + (mixi-friend-set-birthplace): Ditto. + (mixi-friend-birthplace-regexp): New constant. + (mixi-friend-realize): Use them. + + * mixi.el (mixi-make-friend): New slog `hobby'. + (mixi-friend-hobby): New accessor method. + (mixi-friend-set-hobby): Ditto. + (mixi-friend-hobby-regexp): New constant. + (mixi-friend-realize): Use them. + + * mixi.el (mixi-make-friend): New slog `job'. + (mixi-friend-job): New accessor method. + (mixi-friend-set-job): Ditto. + (mixi-friend-job-regexp): New constant. + (mixi-friend-realize): Use them. + + * mixi.el (mixi-make-friend): New slog `organization'. + (mixi-friend-organization): New accessor method. + (mixi-friend-set-organization): Ditto. + (mixi-friend-organization-regexp): New constant. + (mixi-friend-realize): Use them. + + * mixi.el (mixi-make-friend): New slog `profile'. + (mixi-friend-profile): New accessor method. + (mixi-friend-set-profile): Ditto. + (mixi-friend-profile-regexp): New constant. + (mixi-friend-realize): Use them. + 2006-10-21 OHASHI Akira * mixi.el (mixi-friend-max-pages): Abolish; Move to toplevel defvar. diff --git a/mixi.el b/mixi.el index 76d18bd..f147382 100644 --- a/mixi.el +++ b/mixi.el @@ -333,7 +333,8 @@ while `mixi' is waiting for a server's response." (defvar mixi-friend-cache (make-hash-table :test 'equal)) (defun mixi-make-friend (id &optional nick) "Return a friend object." - (mixi-make-cache id (cons 'mixi-friend (vector nil id nick nil)) + (mixi-make-cache id (cons 'mixi-friend (vector nil id nick nil nil nil nil + nil nil nil nil nil nil nil)) mixi-friend-cache)) (defun mixi-make-me () @@ -353,29 +354,71 @@ while `mixi' is waiting for a server's response." (defconst mixi-friend-nick-regexp "\"\\*\"
\n\\(.*\\)¤µ¤ó([0-9]+)") -(defconst mixi-friend-name-regexp - "̾ Á°\n\\([^<]+\\)") -(defconst mixi-my-name-regexp - "̾ Á°\n\n\\([^<]+\\)") +(defconst mixi-friend-name-sex-regexp + "̾\\( \\| \\)Á°\n+\\([^<]+\\) (\\([Ã˽÷]\\)À­)") +(defconst mixi-friend-address-regexp + "¸½½»½ê\n\\(.+\\)\\(\n.+\n\\)?") +(defconst mixi-friend-age-regexp + "ǯ\\( \\| \\)Îð\n\\([0-9]+\\)ºÐ\\(\n.+\n\\)?") +(defconst mixi-friend-birthday-regexp + "ÃÂÀ¸Æü\n\\([0-9]+\\)·î\\([0-9]+\\)Æü\\(\n.+\n\\)?") +(defconst mixi-friend-blood-type-regexp + "·ì±Õ·¿\n\\([ABO]B?\\)·¿\\(\n\n\\)?") +(defconst mixi-friend-birthplace-regexp + "½Ð¿ÈÃÏ\n?\n\\(.+\\)\\(\n.+\n\\)?") +(defconst mixi-friend-hobby-regexp + "¼ñ\\( \\| \\)Ì£\n\\(.+\\)") +(defconst mixi-friend-job-regexp + "¿¦\\( \\| \\)¶È\n\\(.+\\)\\(\n.+\n\\)?") +(defconst mixi-friend-organization-regexp + "½ê\\( \\| \\)°\n]*>\\(.+\\)\\(\n.+\n\\)?") +(defconst mixi-friend-profile-regexp + "¼«¸Ê¾Ò²ð\n\\(.+\\)") (defun mixi-friend-realize (friend) "Realize a FRIEND." ;; FIXME: Check a expiration of cache? (unless (mixi-friend-realize-p friend) - (let (name) + (let (buf) (with-mixi-retrieve (mixi-friend-page friend) - (if (string-match mixi-friend-nick-regexp buffer) - (mixi-friend-set-nick friend (match-string 1 buffer)) - (signal 'error (list 'cannot-find-nick friend))) - (when (string-match mixi-friend-name-regexp buffer) - (setq name (match-string 1 buffer)))) - ;; For getting my name. - (unless name + (setq buf buffer)) + (if (string-match mixi-friend-nick-regexp buf) + (mixi-friend-set-nick friend (match-string 1 buf)) + (signal 'error (list 'cannot-find-nick friend))) + ;; For getting my profile. + (unless (string-match mixi-friend-name-sex-regexp buf) (with-mixi-retrieve "/show_profile.pl" - (if (string-match mixi-my-name-regexp buffer) - (setq name (match-string 1 buffer)) - (signal 'error (list 'cannot-find-name friend))))) - (mixi-friend-set-name friend name)) + (setq buf buffer))) + (if (string-match mixi-friend-name-sex-regexp buf) + (progn + (mixi-friend-set-name friend (match-string 2 buf)) + (mixi-friend-set-sex friend + (if (string= (match-string 3 buf) "ÃË") + 'male 'female))) + (signal 'error (list 'cannot-find-name-or-sex friend))) + (when (string-match mixi-friend-address-regexp buf) + (mixi-friend-set-address friend (match-string 1 buf))) + (when (string-match mixi-friend-age-regexp buf) + (mixi-friend-set-age + friend (string-to-number (match-string 2 buf)))) + (when (string-match mixi-friend-birthday-regexp buf) + (mixi-friend-set-birthday + friend (list (string-to-number (match-string 1 buf)) + (string-to-number (match-string 2 buf))))) + (when (string-match mixi-friend-blood-type-regexp buf) + (mixi-friend-set-blood-type friend (intern (match-string 1 buf)))) + (when (string-match mixi-friend-birthplace-regexp buf) + (mixi-friend-set-birthplace friend (match-string 1 buf))) + (when (string-match mixi-friend-hobby-regexp buf) + (mixi-friend-set-hobby + friend (split-string (match-string 2 buf) ", "))) + (when (string-match mixi-friend-job-regexp buf) + (mixi-friend-set-job friend (match-string 2 buf))) + (when (string-match mixi-friend-organization-regexp buf) + (mixi-friend-set-organization friend (match-string 2 buf))) + (when (string-match mixi-friend-profile-regexp buf) + (mixi-friend-set-profile + friend (mixi-remove-markup (match-string 1 buf))))) (mixi-friend-touch friend))) (defun mixi-friend-realize-p (friend) @@ -405,6 +448,76 @@ while `mixi' is waiting for a server's response." (mixi-friend-realize friend) (aref (cdr friend) 3)) +(defun mixi-friend-sex (friend) + "Return the sex of FRIEND." + (unless (mixi-friend-p friend) + (signal 'wrong-type-argument (list 'mixi-friend-p friend))) + (mixi-friend-realize friend) + (aref (cdr friend) 4)) + +(defun mixi-friend-address (friend) + "Return the address of FRIEND." + (unless (mixi-friend-p friend) + (signal 'wrong-type-argument (list 'mixi-friend-p friend))) + (mixi-friend-realize friend) + (aref (cdr friend) 5)) + +(defun mixi-friend-age (friend) + "Return the age of FRIEND." + (unless (mixi-friend-p friend) + (signal 'wrong-type-argument (list 'mixi-friend-p friend))) + (mixi-friend-realize friend) + (aref (cdr friend) 6)) + +(defun mixi-friend-birthday (friend) + "Return the birthday of FRIEND." + (unless (mixi-friend-p friend) + (signal 'wrong-type-argument (list 'mixi-friend-p friend))) + (mixi-friend-realize friend) + (aref (cdr friend) 7)) + +(defun mixi-friend-blood-type (friend) + "Return the blood type of FRIEND." + (unless (mixi-friend-p friend) + (signal 'wrong-type-argument (list 'mixi-friend-p friend))) + (mixi-friend-realize friend) + (aref (cdr friend) 8)) + +(defun mixi-friend-birthplace (friend) + "Return the birthplace of FRIEND." + (unless (mixi-friend-p friend) + (signal 'wrong-type-argument (list 'mixi-friend-p friend))) + (mixi-friend-realize friend) + (aref (cdr friend) 9)) + +(defun mixi-friend-hobby (friend) + "Return the hobby of FRIEND." + (unless (mixi-friend-p friend) + (signal 'wrong-type-argument (list 'mixi-friend-p friend))) + (mixi-friend-realize friend) + (aref (cdr friend) 10)) + +(defun mixi-friend-job (friend) + "Return the job of FRIEND." + (unless (mixi-friend-p friend) + (signal 'wrong-type-argument (list 'mixi-friend-p friend))) + (mixi-friend-realize friend) + (aref (cdr friend) 11)) + +(defun mixi-friend-organization (friend) + "Return the organization of FRIEND." + (unless (mixi-friend-p friend) + (signal 'wrong-type-argument (list 'mixi-friend-p friend))) + (mixi-friend-realize friend) + (aref (cdr friend) 12)) + +(defun mixi-friend-profile (friend) + "Return the pforile of FRIEND." + (unless (mixi-friend-p friend) + (signal 'wrong-type-argument (list 'mixi-friend-p friend))) + (mixi-friend-realize friend) + (aref (cdr friend) 13)) + (defun mixi-friend-touch (friend) "Set the timestamp of FRIEND." (unless (mixi-friend-p friend) @@ -423,6 +536,66 @@ while `mixi' is waiting for a server's response." (signal 'wrong-type-argument (list 'mixi-friend-p friend))) (aset (cdr friend) 3 name)) +(defun mixi-friend-set-sex (friend sex) + "Set the sex of FRIEND." + (unless (mixi-friend-p friend) + (signal 'wrong-type-argument (list 'mixi-friend-p friend))) + (aset (cdr friend) 4 sex)) + +(defun mixi-friend-set-address (friend address) + "Set the address of FRIEND." + (unless (mixi-friend-p friend) + (signal 'wrong-type-argument (list 'mixi-friend-p friend))) + (aset (cdr friend) 5 address)) + +(defun mixi-friend-set-age (friend age) + "Set the age of FRIEND." + (unless (mixi-friend-p friend) + (signal 'wrong-type-argument (list 'mixi-friend-p friend))) + (aset (cdr friend) 6 age)) + +(defun mixi-friend-set-birthday (friend birthday) + "Set the birthday of FRIEND." + (unless (mixi-friend-p friend) + (signal 'wrong-type-argument (list 'mixi-friend-p friend))) + (aset (cdr friend) 7 birthday)) + +(defun mixi-friend-set-blood-type (friend blood-type) + "Set the blood type of FRIEND." + (unless (mixi-friend-p friend) + (signal 'wrong-type-argument (list 'mixi-friend-p friend))) + (aset (cdr friend) 8 blood-type)) + +(defun mixi-friend-set-birthplace (friend birthplace) + "Set the birthplace of FRIEND." + (unless (mixi-friend-p friend) + (signal 'wrong-type-argument (list 'mixi-friend-p friend))) + (aset (cdr friend) 9 birthplace)) + +(defun mixi-friend-set-hobby (friend hobby) + "Set the hobby of FRIEND." + (unless (mixi-friend-p friend) + (signal 'wrong-type-argument (list 'mixi-friend-p friend))) + (aset (cdr friend) 10 hobby)) + +(defun mixi-friend-set-job (friend job) + "Set the job of FRIEND." + (unless (mixi-friend-p friend) + (signal 'wrong-type-argument (list 'mixi-friend-p friend))) + (aset (cdr friend) 11 job)) + +(defun mixi-friend-set-organization (friend organization) + "Set the organization of FRIEND." + (unless (mixi-friend-p friend) + (signal 'wrong-type-argument (list 'mixi-friend-p friend))) + (aset (cdr friend) 12 organization)) + +(defun mixi-friend-set-profile (friend profile) + "Set the profile of FRIEND." + (unless (mixi-friend-p friend) + (signal 'wrong-type-argument (list 'mixi-friend-p friend))) + (aset (cdr friend) 13 profile)) + (defmacro mixi-friend-list-page (&optional friend) `(concat "/list_friend.pl?page=%d" (when ,friend (concat "&id=" (number-to-string -- 1.7.10.4