Skip to content
This repository was archived by the owner on Apr 17, 2023. It is now read-only.

Commit 0c5b614

Browse files
committed
Add util url validator
1 parent e85eac0 commit 0c5b614

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

twitter_video_tools/utils/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# pylint: disable=useless-import-alias
22

33
from .execute_parallel import execute_parallel as execute_parallel
4+
from .url_validator import URLValidator as URLValidator
45
from .youtube_dl_wrapper import youtube_dl_wrapper as youtube_dl_wrapper
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class URLValidator:
2+
link: str
3+
4+
def __init__(self, link: str) -> None:
5+
self.link = link
6+
7+
def is_valid_twitter_media_link(self) -> bool:
8+
return self.is_valid_link() and self._is_twitter_media_link()
9+
10+
def is_valid_twitter_liked_link(self) -> bool:
11+
return self.is_valid_link() and self._is_twitter_liked_link()
12+
13+
def is_valid_link(self) -> bool:
14+
return self.link.startswith('https://twitter.com/') or self.link.startswith('https://monsnode.com/')
15+
16+
def _is_twitter_media_link(self) -> bool:
17+
return self.link.endswith('/media')
18+
19+
def _is_twitter_liked_link(self) -> bool:
20+
return self.link.endswith('/likes')

0 commit comments

Comments
 (0)