Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
api
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
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
44a56cd5
Verified
Commit
44a56cd5
authored
6 years ago
by
Eliot Berriot
Browse files
Options
Downloads
Patches
Plain Diff
Flattr support
parent
acfe8f98
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
retribute_api/providers.py
+20
-1
20 additions, 1 deletion
retribute_api/providers.py
tests/search/test_means.py
+5
-1
5 additions, 1 deletion
tests/search/test_means.py
with
25 additions
and
2 deletions
retribute_api/providers.py
+
20
−
1
View file @
44a56cd5
...
...
@@ -41,7 +41,17 @@ class BasicUsernameInPathProvider(Provider):
if
not
re
.
match
(
self
.
domain_regex
,
parsed_url
.
hostname
):
return
result
=
re
.
match
(
self
.
username_regex
,
parsed_url
.
path
)
regexes
=
(
self
.
username_regex
if
isinstance
(
self
.
username_regex
,
list
)
else
[
self
.
username_regex
]
)
result
=
None
for
r
in
regexes
:
result
=
re
.
match
(
r
,
parsed_url
.
path
)
if
result
:
break
if
not
result
:
return
username
=
result
.
groups
()[
0
]
...
...
@@ -121,6 +131,15 @@ class Etsy(BasicUsernameInPathProvider):
username_regex
=
r
"
^\/(?:[a-zA-Z-_]+/)?shop/([\w\.]+)/?$
"
@registry.register
class
FLattr
(
BasicUsernameInPathProvider
):
id
=
"
flattr
"
label
=
"
Flattr
"
url
=
"
https://flattr.com
"
domain_regex
=
r
"
^(\w+\.)*flattr\.com
"
username_regex
=
[
r
"
^\/profile/([\w\.]+)/?$
"
,
r
"
^\/@([\w\.]+)/?$
"
]
@registry.register
class
BandCamp
(
BasicUsernameInDomainProvider
):
id
=
"
bandcamp
"
...
...
This diff is collapsed.
Click to expand it.
tests/search/test_means.py
+
5
−
1
View file @
44a56cd5
...
...
@@ -31,12 +31,16 @@ from retribute_api.search import means
{
"
provider
"
:
"
opencollective
"
,
"
id
"
:
"
username
"
},
),
(
"
https://username.bandcamp.com
"
,
{
"
provider
"
:
"
bandcamp
"
,
"
id
"
:
"
username
"
}),
(
"
https://username.bandcamp.com
"
,
{
"
provider
"
:
"
bandcamp
"
,
"
id
"
:
"
username
"
}),
(
"
https://username.bandcamp.com/noop
"
,
{
"
provider
"
:
"
bandcamp
"
,
"
id
"
:
"
username
"
},
),
(
"
https://patreon.com/username/nope
"
,
None
),
(
"
https://flattr.com/@username
"
,
{
"
provider
"
:
"
flattr
"
,
"
id
"
:
"
username
"
}),
(
"
https://flattr.com/profile/username
"
,
{
"
provider
"
:
"
flattr
"
,
"
id
"
:
"
username
"
},
),
],
)
def
test_extract_from_url
(
input
,
expected
):
...
...
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