mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-08-05 16:58:59 +00:00
Adding support for hyphens in youtube usernames.
This commit is contained in:
parent
c70d08b384
commit
f552d6f2c7
1 changed files with 5 additions and 1 deletions
|
@ -108,7 +108,8 @@ class YoutubeFetcher:
|
||||||
def extract_username(self, url):
|
def extract_username(self, url):
|
||||||
if "gdata.youtube.com" in url:
|
if "gdata.youtube.com" in url:
|
||||||
try:
|
try:
|
||||||
username_groups = re.search(r"gdata.youtube.com/feeds/\w+/users/(\w+)/", url)
|
# Also handle usernames like `user-name`
|
||||||
|
username_groups = re.search(r"gdata.youtube.com/feeds/\w+/users/([^/]+)/", url)
|
||||||
if not username_groups:
|
if not username_groups:
|
||||||
return
|
return
|
||||||
return username_groups.group(1)
|
return username_groups.group(1)
|
||||||
|
@ -160,6 +161,7 @@ class YoutubeFetcher:
|
||||||
return videos
|
return videos
|
||||||
|
|
||||||
def fetch_channel_videos(self, channel_id):
|
def fetch_channel_videos(self, channel_id):
|
||||||
|
logging.debug(" ***> ~FBFetching YouTube channel: ~SB%s" % channel_id)
|
||||||
channel_json = requests.get(
|
channel_json = requests.get(
|
||||||
"https://www.googleapis.com/youtube/v3/channels?part=snippet,contentDetails&id=%s&key=%s"
|
"https://www.googleapis.com/youtube/v3/channels?part=snippet,contentDetails&id=%s&key=%s"
|
||||||
% (channel_id, settings.YOUTUBE_API_KEY)
|
% (channel_id, settings.YOUTUBE_API_KEY)
|
||||||
|
@ -176,6 +178,7 @@ class YoutubeFetcher:
|
||||||
return self.fetch_playlist_videos(uploads_list_id, title, description)
|
return self.fetch_playlist_videos(uploads_list_id, title, description)
|
||||||
|
|
||||||
def fetch_playlist_videos(self, list_id, title=None, description=None):
|
def fetch_playlist_videos(self, list_id, title=None, description=None):
|
||||||
|
logging.debug(" ***> ~FBFetching YouTube playlist: ~SB%s" % list_id)
|
||||||
if not title and not description:
|
if not title and not description:
|
||||||
playlist_json = requests.get(
|
playlist_json = requests.get(
|
||||||
"https://www.googleapis.com/youtube/v3/playlists?part=snippet&id=%s&key=%s"
|
"https://www.googleapis.com/youtube/v3/playlists?part=snippet&id=%s&key=%s"
|
||||||
|
@ -201,6 +204,7 @@ class YoutubeFetcher:
|
||||||
return video_ids, title, description
|
return video_ids, title, description
|
||||||
|
|
||||||
def fetch_user_videos(self, username, username_key="forUsername"):
|
def fetch_user_videos(self, username, username_key="forUsername"):
|
||||||
|
logging.debug(" ***> ~FBFetching YouTube user: ~SB%s" % username)
|
||||||
channel_json = requests.get(
|
channel_json = requests.get(
|
||||||
"https://www.googleapis.com/youtube/v3/channels?part=snippet,contentDetails&%s=%s&key=%s"
|
"https://www.googleapis.com/youtube/v3/channels?part=snippet,contentDetails&%s=%s&key=%s"
|
||||||
% (username_key, username, settings.YOUTUBE_API_KEY)
|
% (username_key, username, settings.YOUTUBE_API_KEY)
|
||||||
|
|
Loading…
Add table
Reference in a new issue