Skip Menu |

This queue is for tickets about the WWW-Myspace CPAN distribution.

Report information
The Basics
Id: 17476
Status: resolved
Priority: 0/
Queue: WWW-Myspace

People
Owner: GRANTG [...] cpan.org
Requestors: info [...] tomkerswill.co.uk
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: Patch submission for getting username
Hi Grant... OK - I'm very new to Perl so I'm not sure whether this is the correct place to submit a patch. Sorry if it's something that is already in the script but I missed, but I thought it would be good to have a method to extract the person's username. Also apologies if it's rubbishly programmed ;-) WWW::Myspace is working great for me... really useful bit of kit. Cheers! Anyway, for what it's worth: #Begin added by Tom Kerswill =head2 get_user_name ($friend_id) Gives the user_name for a given friend_id. It looks inside the <title> tag of a myspace profile page. =cut sub get_user_name { my $page_source = $self->get_profile (@_); #Pattern matching inside title tag. \s is needed because for some reason myspace surrounds title text with whitespace: if ( $page_source->content =~ /\<title\>[\s]*www.myspace\.com\/([\S]*)[\s]*\<\/title \>/ ) { $self->{user_name} = $1; } return $self->{user_name}; } #End added by Tom Kerswill
Subject: Re: [rt.cpan.org #17476] Patch submission for getting username
Date: Sat, 4 Feb 2006 22:31:08 -0800
To: bug-WWW-Myspace [...] rt.cpan.org
From: Grant Grueninger <grantg [...] spamarrest.com>
That's exactly where to submit features. Thanks. Traditional format for a patch is to run "diff -u old_version new_version" and send the output. A similar method exists ("user_name") that returns the logged in user's name, but this is a good idea. You also probably don't want to set $self->{user_name} because that'd by convention be the logged in user's name (i.e. the same as the method of the same name). I've changed it to this - it'll be in version 0.20 right under "user_name". (Patch from 0.19 to 0.20 below). (btw, make sure you install version 0.19 - fixes a counting issue with Comment.pm and Message.pm, and makes the tests work properly). Oh, and I added you in the AUTHORS section - is the mention below good? Would you like an email address included to help increase your spam (or anything else)? Index: Myspace.pm =================================================================== RCS file: /export/home0/src/projects/WWW-Myspace/lib/WWW/Myspace.pm,v retrieving revision 1.21 diff -u -r1.21 Myspace.pm --- Myspace.pm 5 Feb 2006 03:01:59 -0000 1.21 +++ Myspace.pm 5 Feb 2006 06:24:25 -0000 @@ -38,11 +38,11 @@ =head1 VERSION -Version 0.19 +Version 0.20 =cut -our $VERSION = '0.19'; +our $VERSION = '0.20'; =head1 SYNOPSIS @@ -299,6 +299,30 @@ } +=head2 friend_user_name( friend_id ) + +Returns the profile name of the friend specified by friend_id. +This is the name that shows up at the top of their profile page +above their picture. (Note, DON'T go using this to sign comments +because most users use funky names and it'll just look cheesy. +If you really want to personalize things, write a table mapping +friend IDs to first names - you'll have to enter them yourself). + +=cut + +sub friend_user_name { + + my $page = $self->get_profile( @_ ); + + # Pattern matching inside title tag. \s is needed because for some + # reason myspace surrounds title text with whitespace: + if ( $page->content =~ /\<title\>[\s]*www.myspace\.com\/([\S] *)[\s]*\<\/title\>/ ) { + return $1; + } else { + return ""; + } +} + =head2 friend_count Returns the logged in user's friend count as displayed on the @@ -1625,6 +1649,9 @@ Grant Grueninger, C<< <grantg at cpan.org> >> +Thanks to: +Tom Kerswill for the friend_user_name method. + =head1 KNOWN ISSUES =over 4 On Feb 4, 2006, at 3:05 AM, Guest via RT wrote: Show quoted text
> > Sat Feb 04 06:05:43 2006: Request 17476 was acted upon. > Transaction: Ticket created by guest > Queue: WWW-Myspace > Subject: Patch submission for getting username > Owner: Nobody > Requestors: info@tomkerswill.co.uk > Status: new > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=17476 > > > > Hi Grant... > > OK - I'm very new to Perl so I'm not sure whether this is the > correct place to submit a patch. > Sorry if it's something that is already in the script but I missed, > but I thought it would be > good to have a method to extract the person's username. Also > apologies if it's rubbishly > programmed ;-) > > WWW::Myspace is working great for me... really useful bit of kit. > Cheers! > > Anyway, for what it's worth: > > #Begin added by Tom Kerswill > =head2 get_user_name ($friend_id) > > Gives the user_name for a given friend_id. It looks inside the > <title> tag of a myspace profile > page. > > =cut > > sub get_user_name { > my $page_source = $self->get_profile (@_); > #Pattern matching inside title tag. \s is needed because for > some reason myspace > surrounds title text with whitespace: > if ( $page_source->content =~ /\<title\>[\s]*www.myspace\.com\/ > ([\S]*)[\s]*\<\/title > \>/ ) { > $self->{user_name} = $1; > } > return $self->{user_name}; > } > > #End added by Tom Kerswill > > > >
Hmm, seems your regexp gets the custom URL instead of what I'd call the user name (what appears above their picture). I changed the regexp to grab that name instead (patch from what I last sent is below). Did you mean to grab the custom URL for some reason? Maybe we need a friend_url method? Index: lib/WWW/Myspace.pm ========================================================= ========== RCS file: /export/home0/src/projects/WWW-Myspace/lib/WWW/Myspace.pm,v retrieving revision 1.22 diff -u -r1.22 Myspace.pm --- lib/WWW/Myspace.pm 5 Feb 2006 06:48:00 -0000 1.22 +++ lib/WWW/Myspace.pm 5 Feb 2006 07:02:06 -0000 @@ -316,7 +316,7 @@ - if ( $page->content =~ /\<title\>[\s]*www.myspace\.com\/([\S]*)[\s]*\<\/title\>/ ) { + if ( $page->content =~ /index\.cfm\?fuseaction=user\&circuitaction \=viewProfile_commentForm\&friendID\=[0-9]+\&name\=([^\&]+)\&/ ) { return $1; } else { return "";
Subject: Re: [rt.cpan.org #17476] Patch submission for getting username
Date: Sun, 05 Feb 2006 10:54:41 +0000
To: bug-WWW-Myspace [...] rt.cpan.org
From: Tom Kerswill <info [...] tomkerswill.co.uk>
Ah that looks great - now I know how to submit a patch, that's good! And thanks very much for adding me to the authors part. Very honoured! I'll get on and install the new patches! Talk to you soon Tom grantg@spamarrest.com via RT wrote: Show quoted text
>That's exactly where to submit features. Thanks. Traditional format >for a patch is to run "diff -u old_version new_version" and send the >output. > >A similar method exists ("user_name") that returns the logged in >user's name, but this is a good idea. You also probably don't want >to set $self->{user_name} because that'd by convention be the logged >in user's name (i.e. the same as the method of the same name). > >I've changed it to this - it'll be in version 0.20 right under >"user_name". (Patch from 0.19 to 0.20 below). > >(btw, make sure you install version 0.19 - fixes a counting issue >with Comment.pm and Message.pm, and makes the tests work properly). > >Oh, and I added you in the AUTHORS section - is the mention below >good? Would you like an email address included to help increase your >spam (or anything else)? > >Index: Myspace.pm >=================================================================== >RCS file: /export/home0/src/projects/WWW-Myspace/lib/WWW/Myspace.pm,v >retrieving revision 1.21 >diff -u -r1.21 Myspace.pm >--- Myspace.pm 5 Feb 2006 03:01:59 -0000 1.21 >+++ Myspace.pm 5 Feb 2006 06:24:25 -0000 >@@ -38,11 +38,11 @@ >=head1 VERSION >-Version 0.19 >+Version 0.20 >=cut >-our $VERSION = '0.19'; >+our $VERSION = '0.20'; >=head1 SYNOPSIS >@@ -299,6 +299,30 @@ >} >+=head2 friend_user_name( friend_id ) >+ >+Returns the profile name of the friend specified by friend_id. >+This is the name that shows up at the top of their profile page >+above their picture. (Note, DON'T go using this to sign comments >+because most users use funky names and it'll just look cheesy. >+If you really want to personalize things, write a table mapping >+friend IDs to first names - you'll have to enter them yourself). >+ >+=cut >+ >+sub friend_user_name { >+ >+ my $page = $self->get_profile( @_ ); >+ >+ # Pattern matching inside title tag. \s is needed because for >some >+ # reason myspace surrounds title text with whitespace: >+ if ( $page->content =~ /\<title\>[\s]*www.myspace\.com\/([\S] >*)[\s]*\<\/title\>/ ) { >+ return $1; >+ } else { >+ return ""; >+ } >+} >+ >=head2 friend_count >Returns the logged in user's friend count as displayed on the >@@ -1625,6 +1649,9 @@ >Grant Grueninger, C<< <grantg at cpan.org> >> >+Thanks to: >+Tom Kerswill for the friend_user_name method. >+ >=head1 KNOWN ISSUES >=over 4 > > > >On Feb 4, 2006, at 3:05 AM, Guest via RT wrote: > > >
>>Sat Feb 04 06:05:43 2006: Request 17476 was acted upon. >>Transaction: Ticket created by guest >> Queue: WWW-Myspace >> Subject: Patch submission for getting username >> Owner: Nobody >> Requestors: info@tomkerswill.co.uk >> Status: new >> Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=17476 > >> >> >>Hi Grant... >> >>OK - I'm very new to Perl so I'm not sure whether this is the >>correct place to submit a patch. >>Sorry if it's something that is already in the script but I missed, >>but I thought it would be >>good to have a method to extract the person's username. Also >>apologies if it's rubbishly >>programmed ;-) >> >>WWW::Myspace is working great for me... really useful bit of kit. >>Cheers! >> >>Anyway, for what it's worth: >> >>#Begin added by Tom Kerswill >>=head2 get_user_name ($friend_id) >> >>Gives the user_name for a given friend_id. It looks inside the >><title> tag of a myspace profile >>page. >> >>=cut >> >>sub get_user_name { >> my $page_source = $self->get_profile (@_); >> #Pattern matching inside title tag. \s is needed because for >>some reason myspace >>surrounds title text with whitespace: >> if ( $page_source->content =~ /\<title\>[\s]*www.myspace\.com\/ >>([\S]*)[\s]*\<\/title >>\>/ ) { >> $self->{user_name} = $1; >> } >> return $self->{user_name}; >>} >> >>#End added by Tom Kerswill >> >> >> >> >> >>
> > > >
Subject: Re: [rt.cpan.org #17476] Patch submission for getting username
Date: Sun, 05 Feb 2006 10:56:34 +0000
To: bug-WWW-Myspace [...] rt.cpan.org
From: Tom Kerswill <info [...] tomkerswill.co.uk>
Ah, yes, you're right! I did mean to get the URL... so I guess friend_url is a more appropriate name? Anyway I'll patch all these up to my copy, Thanks Tom via RT wrote: Show quoted text
>Hmm, seems your regexp gets the custom URL instead of what I'd call the user name (what >appears above their picture). I changed the regexp to grab that name instead (patch from >what I last sent is below). Did you mean to grab the custom URL for some reason? Maybe we >need a friend_url method? > >Index: lib/WWW/Myspace.pm >========================================================= >========== >RCS file: /export/home0/src/projects/WWW-Myspace/lib/WWW/Myspace.pm,v >retrieving revision 1.22 >diff -u -r1.22 Myspace.pm >--- lib/WWW/Myspace.pm 5 Feb 2006 06:48:00 -0000 1.22 >+++ lib/WWW/Myspace.pm 5 Feb 2006 07:02:06 -0000 >@@ -316,7 +316,7 @@ > >- if ( $page->content =~ /\<title\>[\s]*www.myspace\.com\/([\S]*)[\s]*\<\/title\>/ ) { >+ if ( $page->content =~ /index\.cfm\?fuseaction=user\&circuitaction >\=viewProfile_commentForm\&friendID\=[0-9]+\&name\=([^\&]+)\&/ ) { > return $1; > } else { > return ""; > > >
Included friend_url and friend_user_name methods in version 0.20.