bertok / pygooglevoice

Automatically exported from code.google.com/p/pygooglevoice
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

GALX hidden input changed. Need to update regex. #76

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. python sms.py
2. login fails

What is the expected output? What do you see instead?

Expect login but get the following error:

Traceback (most recent call last):
  File "examples/sms.py", line 5, in <module>
    voice.login()
  File "/usr/local/lib/python2.7/dist-packages/googlevoice/voice.py", line 72, in login
    galx = re.search(r"name=\"GALX\"\s+value=\"(.+)\"", content).group(1)
AttributeError: 'NoneType' object has no attribute 'group'

Fixed by changing the "holy hackjob" line to

# holy hackjob
galx = re.search(r"name=\"GALX\"\s+type=\"hidden\"\s+value=\"(.+)\"", 
content).group(1)

It looks like google changed the order of (type, name, value) to (name, type, 
value)

Other:
In settings.py I also have 
LOGIN = 'https://accounts.google.com/ServiceLoginAuth?service=grandcentral'

If using the patch from issue 60 the following change is also tested to work:

hidden = 
re.findall(r"name=\"([^\"]+)\"[^>]+type=\"hidden\"[^>]+value=\"([^\"]+)\"", 
content)

Hope this helps someone.

Original issue reported on code.google.com by HermanNo...@gmail.com on 29 Oct 2013 at 1:49

GoogleCodeExporter commented 9 years ago
Hi,  This helped me very much.  Many thanks, I would be more than happy to tip 
you by bitcoin (0.1 BTC) if you are into that.  Pls send me an email to 
bitcointip4u@gmail.com.  Thanks again, Louis

Original comment by bitcoint...@gmail.com on 29 Oct 2013 at 1:37

GoogleCodeExporter commented 9 years ago
Thank you very much for the help!!!!
I posted same issue without reading this because I had the problem about 2 days 
ago.

Original comment by nycparks...@gmail.com on 29 Oct 2013 at 2:15

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Maybe pygooglevoice should use a fallback in case something else changes that 
breaks the regex? Here's how I updated my code:

    try:
        galx = re.search(r"name=\"GALX\" type=\"hidden\"\n *value=\"(.+)\"", content).group(1)
    except:
        galx = ''.join(e for e in content if e.isalnum()) # Remove special characters (leaving only letters & numbers)
        galx = galx[galx.index("GALX"):] # Grab everything from GALX forward
        galx = galx[:galx.index("input")] # Truncate at input (first word after GALX value)
        galx = galx[galx.index("value")+5:] # Extract GALX value

Original comment by njcarr...@gmail.com on 31 Oct 2013 at 5:23

GoogleCodeExporter commented 9 years ago
Thank you so much!!!

Original comment by ed.shap...@gmail.com on 6 Nov 2013 at 12:09

GoogleCodeExporter commented 9 years ago
Thanks, this worked great.

Original comment by andrewmk...@gmail.com on 18 Nov 2013 at 2:12

GoogleCodeExporter commented 9 years ago
I am trying to make the change to mine but can't find the voice.py file to 
change it. Where is it located? 

Original comment by GregStew...@gmail.com on 17 Jun 2014 at 2:14

GoogleCodeExporter commented 9 years ago
Greg...it's a file in the goolgevoice folder within the .tar.gz..

Original comment by darteag...@gmail.com on 25 Jun 2014 at 4:44

GoogleCodeExporter commented 9 years ago
Is this still working? I tried all posted fix but it didn't work. It looks like 
the login URL is not working anymore..

Original comment by romelemp...@gmail.com on 1 Aug 2014 at 5:21