API with Lyrics and Timestamps - javascript

I'm trying to make an app that uses lyrics with timestamps! I've looked into Genius and musiXmatch API but have had 0 success. MusiXMatch in particular requires a commercial plan to access their subtitled songs but I am making a personal app. Is there a lyrics API with timestamps that I can get access to?

https://textyl.co/ has lyrics with timestamps and you don't need to sign up for anything. However, it doesn't have great documentation and doesn't always get the song correctly, even with the artist and song name.
Example: https://api.textyl.co/api/lyrics?q=the%20beatles%20norwegian%20wood

I am unsure about an API, but I understand that some of my friends have used this https://en.wikipedia.org/wiki/LRC_(file_format). Seems useful to what you are trying to do and I do think there are some websites/APIs that provide LRC files for songs.

You can check the API I created on RapidAPI, there you can pass the name of any song and it will extract the lyrics of the song of whatever language it will be. The link to check for my API is given below
https://rapidapi.com/yashmakan261/api/timestamp-lyrics

Related

How to get Youtube Video URL from catchphrase using javascript/node.js

I want to get the first video from youtube which is listed when I enter a certain catchphrase, e.g. when I enter 'Kill You Eminem' it should give me the URL for the first video, in this case 'https://www.youtube.com/watch?v=D1I1x2pYMK0'.
I want to achieve this using javascript/node.js
You can use the YouTube API to obtain data. Just use axios or the fetch api to create a get request to their endpoint and get the first item of the return array. Here is the complete documentation of YouTube's API. If you need help with the code, HMU in messages.
Here is sample for getting the most viewed videos:
GET {base_URL}/search?part=snippet
&forMine=true
&order=viewCount
&type=video
Here is the whole documentation of YouTube's API:
https://developers.google.com/youtube/v3/sample_requests

Youtube API V3 get video details by URL

Recently , the youtube API has been updated to V3 , and I have a question:
How can I get the video details (views, name , description etc..) through Javascript using the url of the video ?
Example :
I have this url https://www.youtube.com/watch?v=DQ5w8LBI0kI&ab_channel=YT
and I want to get via Javascript the name and description of it.
How can I do this ?
You can find a detailed information about how to retrieve any kind of data you want in the official documentation of youtube api.Here
The API documentation is quite involved. Two good points to start from are the following:
YouTube Data API Overview, and
JavaScript Quickstart.
Upon reading them -- and surely more for that matter -- do come back with concrete (programming!) questions.
One more hint: the API endpoint that provides you with the information attached to a given video is Videos.list. But that doc page becomes meaningful only after you familiarize yourself with the surrounding (programming) environment.
Steps to achieve:
See the answer here to see how to get/parse video Id from a youtube video url.
After you get a videoId e.g. DQ5w8LBI0kI, you have to use that in the below API to get views, name, description etc.
https://www.googleapis.com/youtube/v3/videos?part=snippet%2CcontentDetails%2Cstatistics&id=DQ5w8LBI0kI&key=[YOUR_API_KEY]
See more about this Youtube API here

Get ChannelID from Youtube Custom URL

Is there any way that I can get the channel ID of a Youtube Channel by having its custom url (using the Youtube API) ?
Example:
A custom url is like:
https://www.youtube.com/onepiece
I want to get its channelID, so that I have the link like:
www.youtube.com/user/OnePieceUK
Elaborating on this answer of mine, I'll note here the following facts:
In YouTube URLs of form https://www.youtube.com/c/NAME or https://www.youtube.com/NAME, NAME is a channel's custom URL. (See this official account from Google support.)
In YouTube URLs of form https://www.youtube.com/user/NAME, NAME is a channel's user name. User names are a legacy feature of the API v3; not every channel has one attached; no channel is required to have one attached. (See this official statement from Google staff from 2013-07-11.)
The two API concepts -- custom URLs and user names -- encompass two different categories.
The public (MIT licensed) Python 3 script youtube-search.py referred by my answer quoted above is able to search the API for custom URLs and respectively query the API for user names:
$ python3 youtube-search.py --custom-url onepiece
UC6LPb3zSebrzU_0Yclpwb4Q
$ python3 youtube-search.py --user-name OnePieceUK
UC6LPb3zSebrzU_0Yclpwb4Q
Note that youtube-search.py requires a valid API key to be passed to it as argument of the command line option --app-key or, otherwise, passed on as the environment variable YOUTUBE_DATA_APP_KEY. (Use the command line option --help for brief helping info.)
try this
import requests
from bs4 import BeautifulSoup
resp = requests.get('https://www.youtube.com/onepiece')
soup = BeautifulSoup(resp.text, 'html.parser')
channel_id = soup.select_one('meta[property="og:url"]')['content'].strip('/').split('/')[-1]
I recently had a similar requirement where I knew the custom URL of a youtube channel and I want to get the channel id. So I went to the YouTube channel and clicked on a random video to get the Video ID from the web browser url. Once I get the Video Id, then I used the "Videos: list" API to get the video details:
https://youtube.googleapis.com/youtube/v3/videos?part=snippet&id=[VEDIO_ID]&key=[YOUR_API_KEY]
The retuned data contained all the metadata information about the video, including ChannelId :-).
It may not be the most smartest and elegant way of doing things, but it solved my purpose.

Find location of tower using google geolocation api

I am trying to find the location of cell towers using MNC, MCC, lac and CellID.
I have tried many api's such as opencell, combian etc. But none of them are free.
Is there any rest free API available, but for the moment I am using Google geolocation api.
I am sending request in javascript like this
https://www.googleapis.com/geolocation/v1/geolocate?key=xxx&homeMobileNetworkCode=410&homeMobileCountryCode=310&locationAreaCode=415&cellId=42&format=json
and all the time it return "Not Found"
I checked many places on stackover, but could not find good solution or hint. In addition is there any Free Api Available for getting operator name by using data mnc, mcc, cellid and lac.
In addition, I have also tried to use this link to get location but I could not as I can not find what parameter I need to pass and what should be the url I need to create.
Please provide me some guidelines to get location and operator name for specific tower by using information such as mnc, mcc etc.
Thanks appreciated
Google describes the geolocate API endpoint in their docs. You tried to do a GET request, but they say that you should use POST, with JSON-Formatted data:
Communication is done over HTTPS using POST. Both request and response are formatted as JSON, and the content type of both is application/json.
If you want to use the undocumented API from your link, the URL is http://www.google.com/glm/mmap and the POST-data is what is written in the function WriteData. See the Java Docs for DataOutputStream if you are unfamiliar with the output produced by the various write..-methods.
As for getting the operator name, there are free databases available for that (alternative 1, alternative 2; search google for more, there are plenty).

How to get my entire YouTube watch history?

I'm trying to get a full list of watched videos for a given user in my YouTube API application. I want to add up total duration of all videos.
When I get the list of videos from history playlist, the API caps it at 50 items. There's pagination but total amount of items is 50 (not just per page); I can't access more data with the API it appears.
Is there any way I can get this playlist without the data cap? I'm hoping for another method (of using the API) or a way to do it without the API. I know YouTube stores this data because I can view my entire history (far more that 50 videos).
I'm using this code:
var requestOptions = {
playlistId: playlistId,
part: 'snippet',
maxResults: 50
};
gapi.client.youtube.playlistItems.list(requestOptions);
where playlistId is the id of the history playlist I got from a gapi.client.youtube.channels.list request.
Edit (2017): I want to clarify that it was always my intention to download my own history, just out of interest to see how much time I have spent watching videos. I still have not been able to do this.
The API currently only retrieves the last two weeks of Watch History. For more information refer to the Bug Issue reported: https://code.google.com/p/gdata-issues/issues/detail?id=4642
Note:
There is a similar question on SO asked here: YouTube API v3 returns truncated watch history
I wrote a scraper(in Python 2.7(updated for 3.5) and Scrapy) for this task a while ago.
Sans official API, it uses a logged in session cookie and html parsing. Dumps to SQLite by default.
https://github.com/zvodd/Youtube-Watch-History-Scraper
How it's done: essentially it opens the url
https://www.youtube.com/feed/history'
with a valid(logged in) session cookie taken from Chrome. Scrapes all video entries for name, vid(url), channel/user, description, length. Then it finds the button at the bottom of the page with the attribute data-uix-load-more-href which contains the link to the next page, something like:
"/browse_ajax?action_continuation=1&continuation=98h32hfoasau0fu928hf2hf908h98hr%253D%253D&target_id=item-section-552363&direct_render=1"
... re-scrapes the video entries from there and dumps them all into an sqlite database; which you can search entries by any of the fields (name, length, user, description, etc).
So until they change their feed/history page, it's doable and done.
I might even update it.
While this isn't currently possible using just the YouTube API, there is an (albeit slightly involved) method to calculate your watch time):
download a list of your watch history as a JSON file using Google Takeout.
Unfortunately the JSON file doesn't include the video durations, so the next step is to extract the video IDs (the part after "watch?v=" in the "titleURL" object
Now take your list of video IDs, and send a request to the youtube API that looks something like this:
function execute() {
return gapi.client.youtube.videos.list({
"part": [
"contentDetails"
],
"id": [
"VIDEO IDs"
],
"fields": "items(contentDetails(duration))"
})
(Code created using YouTube API Explorer)
Note: You may need to break the list of video IDs into smaller lists (I had to) or the API may reject the request. As [pointed out by stvar in the comments] the ID list maximum length is 50, so this is the maximum length your lists can be. (full disclosure: I was using Python to send the requests)
Finally, just extract the duration values and add them up (though this might not be quite as easy as it sounds)
The best part of this is I don't believe this actually violates any ToS.
It seems like this is a known bug originally reported in 2013. The exact same behavior is explained on a Google Code thread: https://code.google.com/p/gdata-issues/issues/detail?id=4642
Brainstorming, never tried: Have you tried not using the API and instead parsing the https://www.youtube.com/feed/history URL?
Theoretically, the user browsing could be emulated, including the pagination. I am not aware of how hard though (probably very), since you need to deal with authentication and YouTube probably tries to verify that a human is browsing.
I was looking for some way to get the list of YouTube history.
I just found out that Google has a tool for this. In Google Takeout you have a option taht you can get the entire list of watched videos. My list went back util 2011.
To get explanation short there are two videos explaining how to do this:
https://www.youtube.com/watch?v=zlzzO1e6dws
https://www.youtube.com/watch?v=dto8jGMxHxY

Categories

Resources