diff --git a/modules/tinder/__init__.py b/modules/tinder/__init__.py
new file mode 100644
index 00000000..604bb6c2
--- /dev/null
+++ b/modules/tinder/__init__.py
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+
+# Copyright(C) 2014 Roger Philibert
+#
+# This file is part of weboob.
+#
+# weboob is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# weboob is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with weboob. If not, see .
+
+
+from .backend import TinderBackend
+
+
+__all__ = ['TinderBackend']
diff --git a/modules/tinder/backend.py b/modules/tinder/backend.py
new file mode 100644
index 00000000..0690c774
--- /dev/null
+++ b/modules/tinder/backend.py
@@ -0,0 +1,83 @@
+# -*- coding: utf-8 -*-
+
+# Copyright(C) 2014 Roger Philibert
+#
+# This file is part of weboob.
+#
+# weboob is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# weboob is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with weboob. If not, see .
+
+
+from weboob.capabilities.dating import ICapDating, Optimization
+from weboob.tools.backend import BaseBackend, BackendConfig
+from weboob.tools.value import Value, ValueBackendPassword
+from weboob.tools.log import getLogger
+
+from .browser import TinderBrowser, FacebookBrowser
+
+
+__all__ = ['TinderBackend']
+
+
+class ProfilesWalker(Optimization):
+ def __init__(self, sched, storage, browser):
+ self.sched = sched
+ self.storage = storage
+ self.browser = browser
+ self.logger = getLogger('walker', browser.logger)
+
+ self.view_cron = None
+
+ def start(self):
+ self.view_cron = self.sched.schedule(1, self.view_profile)
+ return True
+
+ def stop(self):
+ self.sched.cancel(self.view_cron)
+ self.view_cron = None
+ return True
+
+ def set_config(self, params):
+ pass
+
+ def is_running(self):
+ return self.view_cron is not None
+
+ def view_profile(self):
+ try:
+ self.browser.like_profile()
+ finally:
+ if self.view_cron is not None:
+ self.view_cron = self.sched.schedule(1, self.view_profile)
+
+
+class TinderBackend(BaseBackend, ICapDating):
+ NAME = 'tinder'
+ DESCRIPTION = u'Tinder dating mobile application'
+ MAINTAINER = u'Roger Philibert'
+ EMAIL = 'roger.philibert@gmail.com'
+ LICENSE = 'AGPLv3+'
+ VERSION = '0.i'
+ CONFIG = BackendConfig(Value('username', label='Facebook email'),
+ ValueBackendPassword('password', label='Facebook password'))
+
+ BROWSER = TinderBrowser
+
+ def create_default_browser(self):
+ facebook = FacebookBrowser()
+ facebook.login(self.config['username'].get(),
+ self.config['password'].get())
+ return TinderBrowser(facebook)
+
+ def init_optimizations(self):
+ self.add_optimization('PROFILE_WALKER', ProfilesWalker(self.weboob.scheduler, self.storage, self.browser))
diff --git a/modules/tinder/browser.py b/modules/tinder/browser.py
new file mode 100644
index 00000000..5cdee653
--- /dev/null
+++ b/modules/tinder/browser.py
@@ -0,0 +1,108 @@
+# -*- coding: utf-8 -*-
+
+# Copyright(C) 2014 Roger Philibert
+#
+# This file is part of weboob.
+#
+# weboob is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# weboob is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with weboob. If not, see .
+
+
+import re
+
+from weboob.tools.browser2 import DomainBrowser, HTMLPage, Profile
+from weboob.tools.browser import BrowserIncorrectPassword
+from weboob.tools.json import json
+
+
+__all__ = ['TinderBrowser', 'FacebookBrowser']
+
+
+class FacebookBrowser(DomainBrowser):
+ BASEURL = 'https://graph.facebook.com'
+
+ CLIENT_ID = "464891386855067"
+ access_token = None
+ info = None
+
+ def login(self, username, password):
+ self.location('https://www.facebook.com/dialog/oauth?client_id=%s&redirect_uri=https://www.facebook.com/connect/login_success.html&scope=basic_info,email,public_profile,user_about_me,user_activities,user_birthday,user_education_history,user_friends,user_interests,user_likes,user_location,user_photos,user_relationship_details&response_type=token' % self.CLIENT_ID)
+ page = HTMLPage(self, self.response)
+ form = page.get_form('//form[@id="login_form"]')
+ form['email'] = username
+ form['pass'] = password
+ form['persistent'] = 1
+ form.submit(allow_redirects=False)
+ if not 'Location' in self.response.headers:
+ raise BrowserIncorrectPassword()
+
+ self.location(self.response.headers['Location'])
+ m = re.search('access_token=([^&]+)&', self.url)
+ if m:
+ self.access_token = m.group(1)
+
+ self.info = self.request('/me')
+
+ def request(self, url, *args, **kwargs):
+ url += '?access_token=' + self.access_token
+ self.location(self.absurl(url, base=True), *args, **kwargs)
+ return json.loads(self.response.content)
+
+
+class IPhoneClient(Profile):
+ def setup_session(self, session):
+ session.headers["Accept-Language"] = "en;q=1, fr;q=0.9, de;q=0.8, ja;q=0.7, nl;q=0.6, it;q=0.5"
+ session.headers["Accept"] = "*/*"
+ session.headers["UserAgent"] = "Tinder/3.0.2 (iPhone; iOS 7.1; Scale/2.00)"
+ session.headers["Accept-Encoding"] = "gzip, deflate"
+ session.headers["Content-Type"] = "application/json"
+
+
+class TinderBrowser(DomainBrowser):
+ BASEURL = 'https://api.gotinder.com/'
+ PROFILE = IPhoneClient()
+
+ recs = None
+
+ def __init__(self, facebook, *args, **kwargs):
+ super(TinderBrowser, self).__init__(*args, **kwargs)
+ self.facebook = facebook
+
+ me = self.request('/auth', data={'facebook_id': facebook.info['id'], 'facebook_token': facebook.access_token})
+ self.session.headers['Authorization'] = 'Token token="%s"' % me['token']
+ self.session.headers['X-Auth-Token'] = me['token']
+
+ self.update_recs()
+
+ def update_recs(self):
+ self.recs = self.request('/user/recs')['results']
+
+ def request(self, *args, **kwargs):
+ if 'data' in kwargs:
+ kwargs['data'] = json.dumps(kwargs['data'])
+
+ self.location(*args, **kwargs)
+ return json.loads(self.response.content)
+
+ def like_profile(self):
+ if len(self.recs) == 0:
+ self.update_recs()
+ if len(self.recs) == 0:
+ return
+
+ profile = self.recs.pop()
+ resp = self.request('/like/%s' % profile['_id'])
+ if resp['match']:
+ self.logger.error('Match with %s!' % profile['name'])
+ else:
+ self.logger.info('Liked %s' % profile['name'])
diff --git a/modules/tinder/favicon.png b/modules/tinder/favicon.png
new file mode 100644
index 00000000..c252e3bc
Binary files /dev/null and b/modules/tinder/favicon.png differ
diff --git a/modules/tinder/test.py b/modules/tinder/test.py
new file mode 100644
index 00000000..31294a80
--- /dev/null
+++ b/modules/tinder/test.py
@@ -0,0 +1,28 @@
+# -*- coding: utf-8 -*-
+
+# Copyright(C) 2014 Roger Philibert
+#
+# This file is part of weboob.
+#
+# weboob is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# weboob is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with weboob. If not, see .
+
+
+from weboob.tools.test import BackendTest
+
+
+class TinderTest(BackendTest):
+ BACKEND = 'tinder'
+
+ def test_tinder(self):
+ self.backend.browser.like_profile()