Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
A library to interact with the YouTube Music (InnerTube) api.
Note: This library is still in development, and is not ready for production use.
muse works on Deno, Node.js, the browser and any javascript environment that supports ES modules and fetch.
You can read the docs for more information about the usage of each function.
Don't forget to replace VERSION
with the
latest version
import { get_song, search } from "https://deno.land/x/muse@VERSION/mod.ts";
// you can also use the latest version (not recommended) with
// import { get_song, search } from "https://deno.land/x/muse/mod.ts";
// you can also import directly from github
// import { get_song, search } from "https://raw.githubusercontent.com/vixalien/muse/VERSION/mod.ts";
search("drake")
.then((data) => {
console.log("search results", data);
});
get_song("dQw4w9WgXcQ")
.then((data) => {
console.log("song", data);
});
You'll need to use a CDN that supports ES modules, such as esm.sh, jspm.io or skypack.dev.
You'll also need to use a proxy server to get around CORS errors. It's a good idea to self host the proxy server (cors-anywhere and deno_deploy_cors_proxy are good options).
import { search, set_option } from "https://esm.sh/libmuse@VERSION";
// import { search, set_option } from "https://jspm.dev/npm:libmuse@VERSION";
// import { search, set_option } from "https://cdn.skypack.dev/libmuse@VERSION";
set_option("proxy", "https://proxy.example.com/");
search("top radio")
.then((data) => {
console.log("search results", data);
});
First install using your preferred package manager (npm, yarn, pnpm etc.)
npm install libmuse
Then use it in by importing libmuse
. The Node version has the exact same
features as the Deno version.
import { get_song, search } from "libmuse";
// commonjs: const { get_artist } = require("libmuse");
get_artist("UCvyjk7zKlaFyNIPZ-Pyvkng")
.then((data) => {
console.log("artist", data);
});
For the complete list of operations, see the docs.
Currently, muse supports oauth authentication by posing as the YouTube TV app.
Here's the flow:
import { get_option, setup } from "https://deno.land/x/muse@VERSION/mod.ts";
/*
node imports:
import { get_option, setup } from "libmuse";
commonjs imports:
const { get_option, setup } = require("libmuse");
*/
const auth = get_option("auth");
setup({
// make sure to persist the token
store: new DenoFileStore("store/muse-store.json"),
debug: true,
});
// this is the authentication flow
const auth_flow = async () => {
if (auth.has_token()) return;
console.log("Getting login code...");
const loginCode = await auth.get_login_code();
console.log(
`Go to ${loginCode.verification_url} and enter the code: ${loginCode.user_code}`,
);
// not necessary, but saves some requests
confirm("Press enter when you have logged in");
console.log("Loading token...");
await auth.load_token_with_code(
loginCode.device_code,
loginCode.interval,
);
console.log("Logged in!", auth._token);
};
// listen to the `requires-login` event, then resolve pass on a function that
// returns a promise that will resolve when the auth flow is complete
auth.addEventListener("requires-login", (event) => {
const resolve = event.detail;
resolve(auth_flow);
});
In the future, I plan to add support for other auth methods, such as cookies and Youtube TV login codes.
You can pass in a storage object to the client to persist the auth token.
import { setup } from "https://deno.land/x/muse@VERSION/mod.ts";
import {
DenoFileStore,
get_default_store,
LocalStorageStore,
MemoryStore,
Store,
} from "https://deno.land/x/muse@VERSION/store.ts";
/*
npm imports:
import { setup } from "libmuse";
import {
DenoFileStore,
get_default_store,
LocalStorageStore,
MemoryStore,
Store,
} from "libmuse/store.js";
commonjs imports:
const { setup } = require("libmuse");
const {
DenoFileStore,
get_default_store,
LocalStorageStore,
MemoryStore,
Store,
} = require("libmuse/store.js");
*/
// you can use the default store, which is DenoFileStore if available, then LocalStorageStore, then MemoryStore
const client = setup({ store: get_default_store() });
// or you can use any of the built-in stores
const client = setup({ store: new DenoFileStore("/path/to/file.json") });
const client = setup({ store: new LocalStorageStore() });
const client = setup({ store: new MemoryStore() });
// or you can implement your own store
// by extending the Store abstract class
class MyStore extends Store {
get<T>(key: string): T | null;
set(key: string, value: unknown): void;
delete(key: string): void;
}
// then use it accordingly
const client = setup({ store: new MyStore() });
// Do note that setup() can be called multiple times, but it's not recommended.
// this is because setup overrides the global store, so if you call setup()
// multiple times, other options set before will be ignored. example:
setup({ auth: { /* custom auth options */ } });
setup({ store: /* custom store */ });
// the above will only use the custom store, and ignore the custom auth options
I'm currently targetting to match the ytmusicapi's capabilities.
FAQs
A library to interact with the YouTube Music (InnerTube) api.
We found that libmuse demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.