From 7fe92c0906dc223fdf952d03491e8067b013288a Mon Sep 17 00:00:00 2001
From: Eliot Berriot <contact@eliotberriot.com>
Date: Sun, 9 Jun 2019 12:46:02 +0200
Subject: [PATCH] Added support for Etsy shops

---
 retribute_api/providers.py | 9 +++++++++
 tests/search/test_means.py | 4 ++++
 2 files changed, 13 insertions(+)

diff --git a/retribute_api/providers.py b/retribute_api/providers.py
index ebb3069..61d1c21 100644
--- a/retribute_api/providers.py
+++ b/retribute_api/providers.py
@@ -112,6 +112,15 @@ class OpenCollective(BasicUsernameInPathProvider):
     domain_regex = r"^(\w+\.)*opencollective\.com"
 
 
+@registry.register
+class Etsy(BasicUsernameInPathProvider):
+    id = "etsy"
+    label = "Etsy"
+    url = "https://etsy.com"
+    domain_regex = r"^(\w+\.)*etsy\.com"
+    username_regex = r"^\/[a-zA-Z-_]+/shop/([\w\.]+)/?$"
+
+
 @registry.register
 class BandCamp(BasicUsernameInDomainProvider):
     id = "bandcamp"
diff --git a/tests/search/test_means.py b/tests/search/test_means.py
index 0a3db70..fffa4f9 100644
--- a/tests/search/test_means.py
+++ b/tests/search/test_means.py
@@ -13,6 +13,10 @@ from retribute_api.search import means
         ("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://www.etsy.com/fr_CA/shop/xxPETRICHORxx",
+            {"provider": "etsy", "id": "xxPETRICHORxx"},
+        ),
         ("https://tipeee.com/username", {"provider": "tipeee", "id": "username"}),
         (
             "https://custom.com/username?retribute",
-- 
GitLab