Add Scraper for youtube videos in Wizzy Downloader

in utopian-io •  7 years ago  (edited)

WIzzy Downloader

image.png

It is a project under NJACK WoC which is a competition to contribute in open source projects.

Wizzy Downloader is a project to Download a youtube video easily.

I have done many contributions in it.
I have attached Pull request of three tasks -

1. Modifying regex to check if its a youtube video URL.

It was my first time trying out regex so I tried out different things. Then I finally got a gist which helped me a lot and finally I got the regex which worked out for me.

\(youtu\.be\/|youtube\.com\/(watch\?(.*&)?v=|(embed|v)\/))([^\?&"'>]+)\

I checked the regex online at regex101
Screenshot -
image.png
To execute regex I used the following the code

var match = re.exec(dn_str);
ifr_str += match[5];

We needed the video URL from regex to embed it and it worked out.

2. Updated Readme with installation instructions

The installation instructions given were not complete as it was missing a module pytube in it.
So there were error when tried to install so I added in it readme and adding to it Django 2.0 doesnt support with Python 2.7+ so I need to add correct install command.

In virtual environment

source bin/activate
pip install Django==1.1
pip install pytube
python manage.py runserver

This will run the server on localhost:8000

3. Add scraper to scrape title of youtube video

This was the most difficult task. As I had two choices either to go with the Python module to make a scraper or do it with JS without much hassle. I am not much of a python guy so I tried to go with JS.
While searching everywhere in the web I found out a SO link through it I got to know about scraper API to feed youtube URL and it scrapes detail for you.
noembed yes that was the API
Check out a demo link here
The data it provides in json is given below

{
   "author_url":"https://www.youtube.com/user/RickAstleyVEVO",
   "provider_url":"https://www.youtube.com/",
   "url":"https://www.youtube.com/watch?v=dQw4w9WgXcQ",
   "title":"Rick Astley - Never Gonna Give You Up",
   "type":"video",
   "height":270,
   "author_name":"RickAstleyVEVO",
   "thumbnail_height":360,
   "thumbnail_width":480,
   "provider_name":"YouTube",
   "thumbnail_url":"https://i.ytimg.com/vi/dQw4w9WgXcQ/hqdefault.jpg",
   "html":"\n<iframe width=\" 480\" height=\"270\" src=\"https://www.youtube.com/embed/dQw4w9WgXcQ?feature=oembed\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"></iframe>\n",
   "version":"1.0",
   "width":480
}

FInal task was to embed this scraper into code so my final code was

$.getJSON('https://noembed.com/embed',
            {
                format: 'json',
                url: dn_str
            },
             function (data) {
                var title = data.title;
                var author = data.author_name;
                $(".infoDiv").html("<p class='info'><strong>"+title+"<br><p>Uploader: "+author+"</p><p><em>Click on download to download the best quality mp4</em></strong></p></p>");
            });

This solved the issue and it scraped Video title and author .
Screenshot can be found below-
image.png

Just as a proof of work-
Screenshot from 2018-01-05 08-40-26.png
Screenshot from 2018-01-05 08-43-19.png

Check out the Wizzy Downloader code here.

Thanks!



Posted on Utopian.io - Rewarding Open Source Contributors

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  
  ·  7 years ago (edited)

Updated @wehmoen
Thanks!!

There are so many intelligent people I have been coming across on steemit and I think you are one of them. I wish I can do all this. Great work @ms10398.

@seyiodus.

  ·  7 years ago (edited)

Hey @ms10398 I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x