Skip to content

Commit

Permalink
fixed broken get_channel_id
Browse files Browse the repository at this point in the history
  • Loading branch information
NotJoeMartinez committed Jul 5, 2024
1 parent aefb29c commit 3f9c408
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "yt-fts"
version = "0.1.50"
version = "0.1.51"
description = "Search all of a YouTube channel from the command line"
readme = "README.md"
requires-python = ">=3.8"
Expand Down
24 changes: 17 additions & 7 deletions yt_fts/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 23,23 @@ def get_channel_id(url, s): # yt_fts
"""
Scrapes channel id from the channel page
"""
# TODO: wrap in try except
res = s.get(url)
if res.status_code == 200:
html = res.text
channel_id = re.search('channelId":"(.{24})"', html).group(1)
return channel_id
else:
try:
res = s.get(url)
if res.status_code == 200:
html = res.text
soup = BeautifulSoup(html, 'html.parser')
meta_tag = soup.find('meta', property='og:url')
if meta_tag:
content_url = meta_tag['content']
else:
console.print('Error: Could not find channel url')
return None

channel_id = content_url.split('/')[-1]
return channel_id

except Exception as e:
console.print(f'Error: {e}')
return None


Expand Down
2 changes: 1 addition & 1 deletion yt_fts/yt_fts.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 11,7 @@
from .utils import *
from rich.console import Console

YT_FTS_VERSION = "0.1.50"
YT_FTS_VERSION = "0.1.51"
console = Console()

@click.group(context_settings={"help_option_names": ["-h", "--help"]})
Expand Down

0 comments on commit 3f9c408

Please sign in to comment.