Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
api
Manage
Activity
Members
Labels
Plan
Issues
5
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
retribute.me
api
Commits
b64e9210
Verified
Commit
b64e9210
authored
5 years ago
by
Eliot Berriot
Browse files
Options
Downloads
Patches
Plain Diff
More providers
parent
75975ceb
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
retribute_api/providers.py
+19
-9
19 additions, 9 deletions
retribute_api/providers.py
tests/search/test_means.py
+6
-0
6 additions, 0 deletions
tests/search/test_means.py
with
25 additions
and
9 deletions
retribute_api/providers.py
+
19
−
9
View file @
b64e9210
...
...
@@ -20,7 +20,7 @@ registry = Registry()
class
Provider
(
object
):
id
=
None
domain
s
=
[]
domain
_regex
=
None
username_regex
=
None
...
...
@@ -28,14 +28,12 @@ class BasicUsernameProvider(Provider):
username_regex
=
r
"
^\/([\w\.]+)/?$
"
def
match_from_url
(
self
,
parsed_url
):
if
not
self
.
domain
s
and
not
self
.
username_regex
:
if
not
self
.
domain
_regex
and
not
self
.
username_regex
:
return
if
parsed_url
.
hostname
not
in
self
.
domains
:
if
not
re
.
match
(
self
.
domain_regex
,
parsed_url
.
hostname
):
return
compiled
=
re
.
compile
(
self
.
username_regex
)
result
=
compiled
.
match
(
parsed_url
.
path
)
result
=
re
.
match
(
self
.
username_regex
,
parsed_url
.
path
)
if
not
result
:
return
username
=
result
.
groups
()[
0
]
...
...
@@ -45,16 +43,28 @@ class BasicUsernameProvider(Provider):
@registry.register
class
Patreon
(
BasicUsernameProvider
):
id
=
"
patreon
"
domains
=
[
"
patreon.com
"
]
domain_regex
=
r
"
^(\w+\.)*patreon\.com
"
@registry.register
class
Paypal
(
BasicUsernameProvider
):
id
=
"
paypal
"
domain_regex
=
r
"
^(\w+\.)*paypal\.me
"
@registry.register
class
Tipeee
(
BasicUsernameProvider
):
id
=
"
tipeee
"
domain_regex
=
r
"
^(\w+\.)*tipeee\.com
"
@registry.register
class
Liberapay
(
BasicUsernameProvider
):
id
=
"
liberapay
"
domain
s
=
[
"
liberapay.com
"
]
domain
_regex
=
r
"
^(\w+\.)*
liberapay
\
.com
"
@registry.register
class
KoFi
(
BasicUsernameProvider
):
id
=
"
ko-fi
"
domain
s
=
[
"
ko-fi.com
"
]
domain
_regex
=
r
"
^(\w+\.)*
ko-fi
\
.com
"
This diff is collapsed.
Click to expand it.
tests/search/test_means.py
+
6
−
0
View file @
b64e9210
...
...
@@ -6,8 +6,14 @@ from retribute_api.search import means
"
input, expected
"
,
[
(
"
https://patreon.com/username
"
,
{
"
provider
"
:
"
patreon
"
,
"
id
"
:
"
username
"
}),
(
"
https://www.patreon.com/username
"
,
{
"
provider
"
:
"
patreon
"
,
"
id
"
:
"
username
"
}),
(
"
https://notpatreon.com/username
"
,
None
),
(
"
https://liberapay.com/username
"
,
{
"
provider
"
:
"
liberapay
"
,
"
id
"
:
"
username
"
}),
(
"
https://ko-fi.com/username
"
,
{
"
provider
"
:
"
ko-fi
"
,
"
id
"
:
"
username
"
}),
(
"
https://paypal.me/username
"
,
{
"
provider
"
:
"
paypal
"
,
"
id
"
:
"
username
"
}),
(
"
https://www.paypal.me/username
"
,
{
"
provider
"
:
"
paypal
"
,
"
id
"
:
"
username
"
}),
(
"
https://fr.tipeee.com/username
"
,
{
"
provider
"
:
"
tipeee
"
,
"
id
"
:
"
username
"
}),
(
"
https://tipeee.com/username
"
,
{
"
provider
"
:
"
tipeee
"
,
"
id
"
:
"
username
"
}),
(
"
https://patreon.com/username/nope
"
,
None
),
],
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment