Comments (5)
As i said, it depends if we want to make a yt-api key mandatory.
If so, we could also just go with the origin google-api-python-client, no need for any "middleware". After all, for now its just a simple request against /search.
Also, did someone consider music.youtube.com?
Mby for another skill like "JARVIS play music mozart" (i don't actually know if theres any difference in the videos/music)?
Just stumbled upon https://github.com/sigma67/ytmusicapi
However, lots of possibilities :D
I guess for now i'll just upload the simple webscrape-fix, its done anyway and we postpone the yt-api till later.
from python-ai-assistant.
Yeah its probably outdated and I wanted to rework the implementation of the yt search but it would be great if you could do it 👍
I wanted to use the youtubei api, references on how to use the internal youtube api can be found here from the invidious project or here. But you're of course free to do implementation however you want
from python-ai-assistant.
Yeah, i had a look on the youtube api, we could use that. But its another api-key you need to have.
The "problem" with the current solution (using requests.get) is, that the yt-searchresult page is build with lots of javascript, meaning you wont get the full page without something like selenium.
But on the bright side, yt initializes the javascript part with a custom jsonstring, containing every information we need.
So without using bs4 u can extract the json from the responsetext with
reg_ex = re.search( "var ytInitialData = (.*);<\/script>", page)
load it as json
json_dict = json.loads(reg_ex.group(1))
and work your way through the dictionary, like
contentList = json_dict["contents"]["twoColumnSearchResultsRenderer"]["primaryContents"]["sectionListRenderer"]["contents"]
ans further...
It works, but obviously it will break again as soon as yt will change a single character in there :/
How are your thought on dependencys?
Thinking about using glom for a better handling on the json 'datastucture'.
Also we could just implement both ways:
If you added a yt api-key in the settings, Jarvis will use the api, otherwise the get-request with some custom regex&json-magic (that might break again in the future).
from python-ai-assistant.
Sounds solid but as you mentioned it can break when YouTube changes things. When I think about it why don't we use ytdl?
from python-ai-assistant.
I really think the simplest way is just using pywhatkit:
import pywhatkit as kit
kit.playonyt("url/keywords")
from python-ai-assistant.
Related Issues (20)
- NLTK Error
- Voice
- api key not connecting to the code HOT 2
- Install nltk failed HOT 1
- Voice Command HOT 1
- My input mode always in text mode HOT 2
- h HOT 1
- System dependencies installation failed HOT 1
- Host Down issue how to solve HOT 2
- Tutorial
- How to have a chain of skills? HOT 1
- except OSError as :e ^ SyntaxError: invalid syntax
- Cydia
- Arch dependencies? HOT 1
- Just
- pymongo not installing properly HOT 2
- Any update on getting this to work on Windows?
- Uninstalling or?
- installation error
- Any update on getting this to work on other operating softwares?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-ai-assistant.