aboutsummaryrefslogtreecommitdiffstats
path: root/youtube/subscriptions.py
diff options
context:
space:
mode:
Diffstat (limited to 'youtube/subscriptions.py')
-rw-r--r--youtube/subscriptions.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/youtube/subscriptions.py b/youtube/subscriptions.py
index b6a4e0e..e12fa0b 100644
--- a/youtube/subscriptions.py
+++ b/youtube/subscriptions.py
@@ -68,6 +68,20 @@ def with_open_db(function, *args, **kwargs):
with connection as cursor:
return function(cursor, *args, **kwargs)
+def is_subscribed(channel_id):
+ if not os.path.exists(database_path):
+ return False
+
+ with open_database() as connection:
+ with connection as cursor:
+ result = cursor.execute('''SELECT EXISTS(
+ SELECT 1
+ FROM subscribed_channels
+ WHERE yt_channel_id=?
+ LIMIT 1
+ )''', [channel_id]).fetchone()
+ return bool(result[0])
+
def _subscribe(cursor, channels):
''' channels is a list of (channel_id, channel_name) '''