Vlad Svoka avatar Vlad Svoka committed cd9d303

fixed auth again. Version 7.6

Comments (0)

Files changed (2)

xbmc-vk.svoka.com/addon.xml

 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<addon id="xbmc-vk.svoka.com" name="VK-xbmc" version="0.7.2" provider-name="shchvova">
+<addon id="xbmc-vk.svoka.com" name="VK-xbmc" version="0.7.6" provider-name="shchvova">
 	<requires>
 		<import addon="xbmc.python" version="2.0"/>
 <!-- 		<import addon="script.module.simple.downloader.beta" version="0.9.1"/>

xbmc-vk.svoka.com/vkapp.py

 #
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
+import urllib
+
 __author__ = 'Volodymyr Shcherban'
 
 import urllib2, cookielib, xbmcaddon, xbmc, xbmcgui, xbmcplugin, os, re
             return ret
 
         opener = urllib2.build_opener(urllib2.HTTPCookieProcessor())
-        login = opener.open("http://vk.com/login.php?email=%s&pass=%s" % (__settings__.getSetting('username'),
-                                                                          __settings__.getSetting('password')))
-        auth = opener.open(OAUTH_URL)
-        accUrl = ''
-        while login.url.startswith('http://vk.com/login.php'):
-            if not self._askLogin():
-                raise Exception("no valid user/password provided")
-            auth = opener.open(OAUTH_URL)
+        authParams = opener.open(OAUTH_URL).read()
+        print "getting auth url " + OAUTH_URL
+        to = re.findall(r'<input type="hidden" name="to" value="(.*?)"',authParams)[0]
+        ip_h = re.findall(r'<input type="hidden" name="ip_h" value="(.*?)"',authParams)[0]
+        action = 'https://login.vk.com/?act=login&soft=1&utf8=1'
+        login = None
+        accUrl=""
+        isLoginPassword = len(__settings__.getSetting('password')) and len(__settings__.getSetting('username'))
+        while not accUrl:
+            if not isLoginPassword:
+                if not self._askLogin():
+                    raise Exception("no valid user/password provided")
+            data = {'to':to, 'ip_h':ip_h, '_origin': 'http://oauth.vk.com', 'email':__settings__.getSetting('username'),
+                    'pass':__settings__.getSetting('password')}
+            login = opener.open(action, data= urllib.urlencode(data))
+            print "login url now is " + login.url
+            isLoginPassword = False
 
-        if auth.url.startswith('http://oauth.vk.com/blank.html'):
-            accUrl = auth.url
-        else:
-            authorizeForm = auth.read()
-            authLink = re.findall(r'action="(.*?)"', authorizeForm)
-            if authLink:
-                result = opener.open(authLink[0])
-                if "access_token" in result.url:
-                    accUrl = result.url
-
+            if login.url.startswith('http://oauth.vk.com/blank.html'):
+                accUrl = login.url
+            else:
+                authorizeForm = login.read()
+                authLink = re.findall(r'action="(.*?)"', authorizeForm)
+                if authLink:
+                    print authLink[0]
+                    if not authLink[0].startswith('https://login.vk.com'):
+                        result = opener.open(authLink[0])
+                        if "access_token" in result.url:
+                            accUrl = result.url
+                        else:
+                            print result.url
         fl = open(authUrlFile, "w")
         fl.write(accUrl)
         fl.close()
         xbmc.log("CAUGHT ERROR" + str(e))
         if os.path.isfile(authUrlFile):
             os.remove(authUrlFile)
-        return None
+        #return None
+        raise
 
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.