Skip to content

Commit

Permalink
Using pytubefix module instead of pytube
Browse files Browse the repository at this point in the history
  • Loading branch information
TrifanBogdan24 committed Oct 25, 2024
1 parent c851f80 commit 72a71d4
Show file tree
Hide file tree
Showing 42 changed files with 101 additions and 70 deletions.
71 changes: 51 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
>
> Bring your YouTube links to life!

🤖 Automate the boring stuff with Python!


🚀 Glow up your HTML/Markdown files with this simple Python script!
Just provide a YouTube URL as input, and it generates a sleek, clickable YouTube card for you.
Perfect for embedding videos in your blog, documentation, or personal projects.
Expand Down Expand Up @@ -40,26 +44,26 @@ Clean, ready-to-use HTML that you can drop anywhere:
```html
<!-- Markdown Crash Course - Beginner Tutorial -->
<div style="border: 1px solid #ddd; padding: 10px; max-width: 300px; position: relative; display: inline-block;">
<a href="https://youtu.be/34_dRW42kYI" target="_blank" style="display: block; position: relative;">
<!-- Thumbnail -->
<img src="https://i.ytimg.com/vi/34_dRW42kYI/hq720.jpg" alt="YouTube Thumbnail" style="width: 100%; display: block;">
<!-- Play button in the center -->
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 60px; height: 60px; background: rgba(255, 0, 0, 0.8); border-radius: 50%; display: flex; align-items: center; justify-content: center;">
<div style="width: 0; height: 0; border-left: 15px solid white; border-top: 10px solid transparent; border-bottom: 10px solid transparent;"></div>
</div>
<!-- Black rectangle with duration at bottom-right -->
<div style="position: absolute; bottom: 8px; right: 8px; background: rgba(0, 0, 0, 0.8); color: white; padding: 2px 6px; font-size: 12px; border-radius: 3px;">
21:24
</div>
</a>
<div style="margin: 0 auto; width: 90%; text-align: left;">
<!-- Text of URL -->
<p style="margin: 10px 0;"><a href="https://youtu.be/34_dRW42kYI" target="_blank">https://youtu.be/34_dRW42kYI</a></p>
<!-- Separation line -->
<hr style="border: 0; height: 1px; background: #ddd; margin: 10px 0;">
<!-- Text of Title -->
<p style="margin: 10px 0;"><a href="https://youtu.be/34_dRW42kYI" target="_blank">Markdown Crash Course - Beginner Tutorial</a></p>
</div>
<a href="https://youtu.be/34_dRW42kYI" target="_blank" style="display: block; position: relative;">
<!-- Thumbnail -->
<img src="https://i.ytimg.com/vi/34_dRW42kYI/sddefault.jpg" alt="YouTube Thumbnail" style="width: 100%; display: block;">
<!-- Play button in the center -->
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 60px; height: 60px; background: rgba(255, 0, 0, 0.8); border-radius: 50%; display: flex; align-items: center; justify-content: center;">
<div style="width: 0; height: 0; border-left: 15px solid white; border-top: 10px solid transparent; border-bottom: 10px solid transparent;"></div>
</div>
<!-- Black rectangle with duration at bottom-right -->
<div style="position: absolute; bottom: 8px; right: 8px; background: rgba(0, 0, 0, 0.8); color: white; padding: 2px 6px; font-size: 12px; border-radius: 3px;">
21:24
</div>
</a>
<div style="margin: 0 auto; width: 90%; text-align: left;">
<!-- Text of URL -->
<p style="margin: 10px 0;"><a href="https://youtu.be/34_dRW42kYI" target="_blank">https://youtu.be/34_dRW42kYI</a></p>
<!-- Separation line -->
<hr style="border: 0; height: 1px; background: #ddd; margin: 10px 0;">
<!-- Text of Title -->
<p style="margin: 10px 0;"><a href="https://youtu.be/34_dRW42kYI" target="_blank">Markdown Crash Course - Beginner Tutorial</a></p>
</div>
</div>

```
Expand Down Expand Up @@ -119,12 +123,39 @@ The HTML/MD code will also include relevant comments.
This tool uses the `pytube` module.




```bash
$ pip3 install pytube # getting YouTube clip info
```




> IMPORTANT NOTE:
>
> Given the numerous problems and errors caused by the `pytube` module,
> please check this link <https://github.com/pytube/pytube/issues/2059>,
> my project now uses the `pytubefix` module.
>
> The `pytubefix` module's documentation is available on the GitHub page,
> at the following link: <https://github.com/JuanBindez/pytubefix.git>.



```bash
$ pip3 install pytubefix
```


Also, when running the `html_md_yt_card` **CLI tool** for the first time,
it **might** ask for authentication on Google.
Without authentication, you'll be seen as a bot and an error message will be dispalyed.




## Installation


Expand Down
2 changes: 1 addition & 1 deletion Tests/out/1.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div style="border: 1px solid #ddd; padding: 10px; max-width: 300px; position: relative; display: inline-block;">
<a href="https://youtu.be/gZx9yCbQg50" target="_blank" style="display: block; position: relative;">
<!-- Thumbnail -->
<img src="https://i.ytimg.com/vi/gZx9yCbQg50/hq720.jpg" alt="YouTube Thumbnail" style="width: 100%; display: block;">
<img src="https://i.ytimg.com/vi/gZx9yCbQg50/sddefault.jpg" alt="YouTube Thumbnail" style="width: 100%; display: block;">
<!-- Play button in the center -->
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 60px; height: 60px; background: rgba(255, 0, 0, 0.8); border-radius: 50%; display: flex; align-items: center; justify-content: center;">
<div style="width: 0; height: 0; border-left: 15px solid white; border-top: 10px solid transparent; border-bottom: 10px solid transparent;"></div>
Expand Down
2 changes: 1 addition & 1 deletion Tests/out/10.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div style="border: 1px solid #ddd; padding: 10px; max-width: 300px; position: relative; display: inline-block;">
<a href="https://www.youtube.com/watch?v=M44e92KoIaE" target="_blank" style="display: block; position: relative;">
<!-- Thumbnail -->
<img src="https://i.ytimg.com/vi/M44e92KoIaE/hqdefault.jpg?sqp=-oaymwEXCJADEOABSFryq4qpAwkIARUAAIhCGAE=&rs=AOn4CLBcsURFQwIvDUf5RGlqCkKCVWrPug" alt="YouTube Thumbnail" style="width: 100%; display: block;">
<img src="https://i.ytimg.com/vi/M44e92KoIaE/sddefault.jpg" alt="YouTube Thumbnail" style="width: 100%; display: block;">
<!-- Play button in the center -->
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 60px; height: 60px; background: rgba(255, 0, 0, 0.8); border-radius: 50%; display: flex; align-items: center; justify-content: center;">
<div style="width: 0; height: 0; border-left: 15px solid white; border-top: 10px solid transparent; border-bottom: 10px solid transparent;"></div>
Expand Down
2 changes: 1 addition & 1 deletion Tests/out/11.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div style="border: 1px solid #ddd; padding: 10px; max-width: 300px; position: relative; display: inline-block;">
<a href="https://youtu.be/M44e92KoIaE" target="_blank" style="display: block; position: relative;">
<!-- Thumbnail -->
<img src="https://i.ytimg.com/vi/M44e92KoIaE/hqdefault.jpg?sqp=-oaymwEXCJADEOABSFryq4qpAwkIARUAAIhCGAE=&rs=AOn4CLBcsURFQwIvDUf5RGlqCkKCVWrPug" alt="YouTube Thumbnail" style="width: 100%; display: block;">
<img src="https://i.ytimg.com/vi/M44e92KoIaE/sddefault.jpg" alt="YouTube Thumbnail" style="width: 100%; display: block;">
<!-- Play button in the center -->
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 60px; height: 60px; background: rgba(255, 0, 0, 0.8); border-radius: 50%; display: flex; align-items: center; justify-content: center;">
<div style="width: 0; height: 0; border-left: 15px solid white; border-top: 10px solid transparent; border-bottom: 10px solid transparent;"></div>
Expand Down
2 changes: 1 addition & 1 deletion Tests/out/12.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div style="border: 1px solid #ddd; padding: 10px; max-width: 300px; position: relative; display: inline-block;">
<a href="http://www.youtube.com/v/0zM3nApSvMg?fs=1&hl=en_US&rel=0" target="_blank" style="display: block; position: relative;">
<!-- Thumbnail -->
<img src="https://i.ytimg.com/vi/0zM3nApSvMg/hqdefault.jpg?sqp=-oaymwExCJADEOABSFryq4qpAyMIARUAAIhCGAHwAQH4Af4EgALgA4oCDAgAEAEYTiBlKF8wDw==&rs=AOn4CLDNtGGujQcmUimMz2xorlRZx_9xtQ" alt="YouTube Thumbnail" style="width: 100%; display: block;">
<img src="https://i.ytimg.com/vi/0zM3nApSvMg/hqdefault.jpg?sqp=-oaymwEmCOADEOgC8quKqQMa8AEB-AH-BIAC4AOKAgwIABABGE4gZShfMA8=&rs=AOn4CLBDLrdweXbGh8jzEgX1ZGnusOjJ_w" alt="YouTube Thumbnail" style="width: 100%; display: block;">
<!-- Play button in the center -->
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 60px; height: 60px; background: rgba(255, 0, 0, 0.8); border-radius: 50%; display: flex; align-items: center; justify-content: center;">
<div style="width: 0; height: 0; border-left: 15px solid white; border-top: 10px solid transparent; border-bottom: 10px solid transparent;"></div>
Expand Down
2 changes: 1 addition & 1 deletion Tests/out/13.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div style="border: 1px solid #ddd; padding: 10px; max-width: 300px; position: relative; display: inline-block;">
<a href="http://www.youtube.com/embed/0zM3nApSvMg?rel=0" target="_blank" style="display: block; position: relative;">
<!-- Thumbnail -->
<img src="https://i.ytimg.com/vi/0zM3nApSvMg/hqdefault.jpg?sqp=-oaymwExCJADEOABSFryq4qpAyMIARUAAIhCGAHwAQH4Af4EgALgA4oCDAgAEAEYTiBlKF8wDw==&rs=AOn4CLDNtGGujQcmUimMz2xorlRZx_9xtQ" alt="YouTube Thumbnail" style="width: 100%; display: block;">
<img src="https://i.ytimg.com/vi/0zM3nApSvMg/hqdefault.jpg?sqp=-oaymwEmCOADEOgC8quKqQMa8AEB-AH-BIAC4AOKAgwIABABGE4gZShfMA8=&rs=AOn4CLBDLrdweXbGh8jzEgX1ZGnusOjJ_w" alt="YouTube Thumbnail" style="width: 100%; display: block;">
<!-- Play button in the center -->
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 60px; height: 60px; background: rgba(255, 0, 0, 0.8); border-radius: 50%; display: flex; align-items: center; justify-content: center;">
<div style="width: 0; height: 0; border-left: 15px solid white; border-top: 10px solid transparent; border-bottom: 10px solid transparent;"></div>
Expand Down
2 changes: 1 addition & 1 deletion Tests/out/14.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div style="border: 1px solid #ddd; padding: 10px; max-width: 300px; position: relative; display: inline-block;">
<a href="http://www.youtube.com/watch?v=0zM3nApSvMg&feature=feedrec_grec_index" target="_blank" style="display: block; position: relative;">
<!-- Thumbnail -->
<img src="https://i.ytimg.com/vi/0zM3nApSvMg/hqdefault.jpg?sqp=-oaymwExCJADEOABSFryq4qpAyMIARUAAIhCGAHwAQH4Af4EgALgA4oCDAgAEAEYTiBlKF8wDw==&rs=AOn4CLDNtGGujQcmUimMz2xorlRZx_9xtQ" alt="YouTube Thumbnail" style="width: 100%; display: block;">
<img src="https://i.ytimg.com/vi/0zM3nApSvMg/hqdefault.jpg?sqp=-oaymwEmCOADEOgC8quKqQMa8AEB-AH-BIAC4AOKAgwIABABGE4gZShfMA8=&rs=AOn4CLBDLrdweXbGh8jzEgX1ZGnusOjJ_w" alt="YouTube Thumbnail" style="width: 100%; display: block;">
<!-- Play button in the center -->
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 60px; height: 60px; background: rgba(255, 0, 0, 0.8); border-radius: 50%; display: flex; align-items: center; justify-content: center;">
<div style="width: 0; height: 0; border-left: 15px solid white; border-top: 10px solid transparent; border-bottom: 10px solid transparent;"></div>
Expand Down
2 changes: 1 addition & 1 deletion Tests/out/15.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div style="border: 1px solid #ddd; padding: 10px; max-width: 300px; position: relative; display: inline-block;">
<a href="http://www.youtube.com/watch?v=0zM3nApSvMg" target="_blank" style="display: block; position: relative;">
<!-- Thumbnail -->
<img src="https://i.ytimg.com/vi/0zM3nApSvMg/hqdefault.jpg?sqp=-oaymwExCJADEOABSFryq4qpAyMIARUAAIhCGAHwAQH4Af4EgALgA4oCDAgAEAEYTiBlKF8wDw==&rs=AOn4CLDNtGGujQcmUimMz2xorlRZx_9xtQ" alt="YouTube Thumbnail" style="width: 100%; display: block;">
<img src="https://i.ytimg.com/vi/0zM3nApSvMg/hqdefault.jpg?sqp=-oaymwEmCOADEOgC8quKqQMa8AEB-AH-BIAC4AOKAgwIABABGE4gZShfMA8=&rs=AOn4CLBDLrdweXbGh8jzEgX1ZGnusOjJ_w" alt="YouTube Thumbnail" style="width: 100%; display: block;">
<!-- Play button in the center -->
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 60px; height: 60px; background: rgba(255, 0, 0, 0.8); border-radius: 50%; display: flex; align-items: center; justify-content: center;">
<div style="width: 0; height: 0; border-left: 15px solid white; border-top: 10px solid transparent; border-bottom: 10px solid transparent;"></div>
Expand Down
2 changes: 1 addition & 1 deletion Tests/out/16.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div style="border: 1px solid #ddd; padding: 10px; max-width: 300px; position: relative; display: inline-block;">
<a href="http://youtu.be/0zM3nApSvMg" target="_blank" style="display: block; position: relative;">
<!-- Thumbnail -->
<img src="https://i.ytimg.com/vi/0zM3nApSvMg/hqdefault.jpg?sqp=-oaymwExCJADEOABSFryq4qpAyMIARUAAIhCGAHwAQH4Af4EgALgA4oCDAgAEAEYTiBlKF8wDw==&rs=AOn4CLDNtGGujQcmUimMz2xorlRZx_9xtQ" alt="YouTube Thumbnail" style="width: 100%; display: block;">
<img src="https://i.ytimg.com/vi/0zM3nApSvMg/hqdefault.jpg?sqp=-oaymwEmCOADEOgC8quKqQMa8AEB-AH-BIAC4AOKAgwIABABGE4gZShfMA8=&rs=AOn4CLBDLrdweXbGh8jzEgX1ZGnusOjJ_w" alt="YouTube Thumbnail" style="width: 100%; display: block;">
<!-- Play button in the center -->
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 60px; height: 60px; background: rgba(255, 0, 0, 0.8); border-radius: 50%; display: flex; align-items: center; justify-content: center;">
<div style="width: 0; height: 0; border-left: 15px solid white; border-top: 10px solid transparent; border-bottom: 10px solid transparent;"></div>
Expand Down
6 changes: 3 additions & 3 deletions Tests/out/17.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!-- Never Gonna Give You Up -->
<!-- Rick Astley - Never Gonna Give You Up (Official Music Video) -->
<div style="border: 1px solid #ddd; padding: 10px; max-width: 300px; position: relative; display: inline-block;">
<a href="http://youtu.be/dQw4w9WgXcQ" target="_blank" style="display: block; position: relative;">
<!-- Thumbnail -->
<img src="https://i.ytimg.com/vi/dQw4w9WgXcQ/hq720.jpg?sqp=-oaymwEXCNUGEOADIAQqCwjVARCqCBh4INgESFo&rs=AOn4CLBX-HcaMSEAucUr5J0qD5nEyiPAoQ" alt="YouTube Thumbnail" style="width: 100%; display: block;">
<img src="https://i.ytimg.com/vi/dQw4w9WgXcQ/sddefault.jpg" alt="YouTube Thumbnail" style="width: 100%; display: block;">
<!-- Play button in the center -->
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 60px; height: 60px; background: rgba(255, 0, 0, 0.8); border-radius: 50%; display: flex; align-items: center; justify-content: center;">
<div style="width: 0; height: 0; border-left: 15px solid white; border-top: 10px solid transparent; border-bottom: 10px solid transparent;"></div>
Expand All @@ -18,7 +18,7 @@
<!-- Separation line -->
<hr style="border: 0; height: 1px; background: #ddd; margin: 10px 0;">
<!-- Text of Title -->
<p style="margin: 10px 0;"><a href="http://youtu.be/dQw4w9WgXcQ" target="_blank">Never Gonna Give You Up</a></p>
<p style="margin: 10px 0;"><a href="http://youtu.be/dQw4w9WgXcQ" target="_blank">Rick Astley - Never Gonna Give You Up (Official Music Video)</a></p>
</div>
</div>

6 changes: 3 additions & 3 deletions Tests/out/18.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!-- Never Gonna Give You Up -->
<!-- Rick Astley - Never Gonna Give You Up (Official Music Video) -->
<div style="border: 1px solid #ddd; padding: 10px; max-width: 300px; position: relative; display: inline-block;">
<a href="http://www.youtube.com/watch?feature=player_embedded&v=dQw4w9WgXcQ" target="_blank" style="display: block; position: relative;">
<!-- Thumbnail -->
<img src="https://i.ytimg.com/vi/dQw4w9WgXcQ/hq720.jpg?sqp=-oaymwEXCNUGEOADIAQqCwjVARCqCBh4INgESFo&rs=AOn4CLBX-HcaMSEAucUr5J0qD5nEyiPAoQ" alt="YouTube Thumbnail" style="width: 100%; display: block;">
<img src="https://i.ytimg.com/vi/dQw4w9WgXcQ/sddefault.jpg" alt="YouTube Thumbnail" style="width: 100%; display: block;">
<!-- Play button in the center -->
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 60px; height: 60px; background: rgba(255, 0, 0, 0.8); border-radius: 50%; display: flex; align-items: center; justify-content: center;">
<div style="width: 0; height: 0; border-left: 15px solid white; border-top: 10px solid transparent; border-bottom: 10px solid transparent;"></div>
Expand All @@ -18,7 +18,7 @@
<!-- Separation line -->
<hr style="border: 0; height: 1px; background: #ddd; margin: 10px 0;">
<!-- Text of Title -->
<p style="margin: 10px 0;"><a href="http://www.youtube.com/watch?feature=player_embedded&v=dQw4w9WgXcQ" target="_blank">Never Gonna Give You Up</a></p>
<p style="margin: 10px 0;"><a href="http://www.youtube.com/watch?feature=player_embedded&v=dQw4w9WgXcQ" target="_blank">Rick Astley - Never Gonna Give You Up (Official Music Video)</a></p>
</div>
</div>

2 changes: 1 addition & 1 deletion Tests/out/19.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div style="border: 1px solid #ddd; padding: 10px; max-width: 300px; position: relative; display: inline-block;">
<a href="https://youtu.be/4UcfECYbDYQ?list=PL1eC1aP-LYNg2ya1ywPj0pipd0y2EWGEl" target="_blank" style="display: block; position: relative;">
<!-- Thumbnail -->
<img src="https://i.ytimg.com/vi/4UcfECYbDYQ/hq720.jpg" alt="YouTube Thumbnail" style="width: 100%; display: block;">
<img src="https://i.ytimg.com/vi/4UcfECYbDYQ/sddefault.jpg" alt="YouTube Thumbnail" style="width: 100%; display: block;">
<!-- Play button in the center -->
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 60px; height: 60px; background: rgba(255, 0, 0, 0.8); border-radius: 50%; display: flex; align-items: center; justify-content: center;">
<div style="width: 0; height: 0; border-left: 15px solid white; border-top: 10px solid transparent; border-bottom: 10px solid transparent;"></div>
Expand Down
2 changes: 1 addition & 1 deletion Tests/out/2.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div style="border: 1px solid #ddd; padding: 10px; max-width: 300px; position: relative; display: inline-block;">
<a href="https://youtu.be/gZx9yCbQg50?t=108" target="_blank" style="display: block; position: relative;">
<!-- Thumbnail -->
<img src="https://i.ytimg.com/vi/gZx9yCbQg50/hq720.jpg" alt="YouTube Thumbnail" style="width: 100%; display: block;">
<img src="https://i.ytimg.com/vi/gZx9yCbQg50/sddefault.jpg" alt="YouTube Thumbnail" style="width: 100%; display: block;">
<!-- Play button in the center -->
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 60px; height: 60px; background: rgba(255, 0, 0, 0.8); border-radius: 50%; display: flex; align-items: center; justify-content: center;">
<div style="width: 0; height: 0; border-left: 15px solid white; border-top: 10px solid transparent; border-bottom: 10px solid transparent;"></div>
Expand Down
2 changes: 1 addition & 1 deletion Tests/out/20.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div style="border: 1px solid #ddd; padding: 10px; max-width: 300px; position: relative; display: inline-block;">
<a href="https://youtu.be/4UcfECYbDYQ?list=PL1eC1aP-LYNg2ya1ywPj0pipd0y2EWGEl&t=51" target="_blank" style="display: block; position: relative;">
<!-- Thumbnail -->
<img src="https://i.ytimg.com/vi/4UcfECYbDYQ/hq720.jpg" alt="YouTube Thumbnail" style="width: 100%; display: block;">
<img src="https://i.ytimg.com/vi/4UcfECYbDYQ/sddefault.jpg" alt="YouTube Thumbnail" style="width: 100%; display: block;">
<!-- Play button in the center -->
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 60px; height: 60px; background: rgba(255, 0, 0, 0.8); border-radius: 50%; display: flex; align-items: center; justify-content: center;">
<div style="width: 0; height: 0; border-left: 15px solid white; border-top: 10px solid transparent; border-bottom: 10px solid transparent;"></div>
Expand Down
Loading

0 comments on commit 72a71d4

Please sign in to comment.