Get URL of video running in Youtube android app

Answer to query 1:

Yes, it is possible to fetch the url of the video playing in the official YouTube app. You are trying to integrate your app with the YouTube app and there is a standard way of achieving it in android. You may get details of the technique here.

The concern at this point may be does YouTube app provides the url to be fetched from other apps. This requires the concept of content providers (here). One can integrate any app with another app but is restricted only to the data provided by the parent app. YouTube app allows one to fetch the metadata of the current playing video.

This is more related to android rather than YouTube API as you are trying to get information regarding the current state of the YouTube app.

Answer to query 2:

Yes, it will be illegal to develop such an app as per the terms and services of YouTube. That being said, you will not be permitted to publish your app to Google PlayStore. To quote the terms and services of YouTube:

"You shall not download any Content unless you see a “download” or similar link displayed by YouTube on the Service for that Content.You shall not copy, reproduce, make available online or electronically transmit, publish, adapt, distribute, transmit, broadcast, display, sell, license, or otherwise exploit any Content for any other purposes without the prior written consent of YouTube or the respective licensors of the Content. YouTube and its licensors reserve all rights not expressly granted in and to the Service and the Content."

You may read more about the terms and services of YouTube here.

Why would one still bother to develop such as app?

Though it would be illegal to earn financial benefit by such an app as it violates the terms and services of another app it depends on but still, it would be legal to develop such an app for personal use only. Upon quoting the terms and services again:

Content is provided to you AS IS. You may access Content for your information and personal use solely as intended through the provided functionality of the Service and as permitted under these Terms of Service. You shall not download any Content unless you see a “download” or similar link displayed by YouTube on the Service for that Content. You shall not copy, reproduce, make available online or electronically transmit, publish, adapt, distribute, transmit, broadcast, display, sell, license, or otherwise exploit any Content for any other purposes without the prior written consent of YouTube or the respective licensors of the Content. YouTube and its licensors reserve all rights not expressly granted in and to the Service and the Content.

The point of debate at this point might be: Is YouTube a service or content provider? One may argue on both sides.