npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@angeligareta/tfapl

v1.0.1

Published

Extension of the Egg languaging program using the YouTube Api.

Downloads

3

Readme

Final Programming Language Project of Ángel Igareta

npm version

Description

The aim of this project was to extend the EGG language that we had previously made with anything we wanted. In this final project, I wanted to try something different.

I have been always a lover of social media, more specific in YouTube, so I decided to try the YouTube API and let it surprise me. After several hours of investigation (due there is not much information) I decided to start experimenting with it and do a npm module explaining what I have learnt.

For not repeating the description of the module, I ask you to follow this link and see what I made: YouTube-API-Features

The next step was to adapt it to egg. To make it clean I decided to use registry pattern and change the egg npm module in order to export the topEnv hash, that contains some functions that we can use in egg language. That's what I made, first I made an main program that receives an egg language program and run it, but before I require a new file: the youtube-egg.js file, that will extend the egg behavior.

YouTube EGG

In this file, first of all I require the YouTube features module that I explained previously and the topEnv map that allow us to extend the egg behaviour. Besides I assign to all the functions that offer the egg YouTube module to an error function, beacuse, in order to use the module, the user first have to 'require' it, by writing 'use("youtube")'.

// Necessary function for using youtube api features module.
const startFunctionOnMode = require('@angeligareta/youtube-api-features');
const fs = require('fs');
const colors = require('colors');
const printTitle = (string) => console.log(colors.yellow(string));

// We require topEnv for adding the necessary functions in order yo use youtube module.
let {topEnv} = require('@angeligareta/egg');

// In case the youtube function has not been required, show error.
topEnv['showYouTubeHelp'] = showError;
topEnv['showComments'] = showError;
topEnv['showChannelInfo'] = showError;
topEnv['showChannelVideos'] = showError;
topEnv['searchVideos'] = showError;
topEnv['searchChannels'] = showError;

function showError() {
	throw new TypeError("In order to use youtube module functions, you must 'use' the youtube module as follow: \n" +
		"\t use(\"youtube\")");
}

After that, I add the function 'use' to the topEnv and assign the correct functions to the functions that offer the egg YouTube module. However, before we must check if the user has the client_secret.json in the working directory, due it's necessary for using the youtube api. If you want to test it I recommend you to follow this tutorial for Node.JS: Node.js QuickStart

// If the user writes 'use("youtube")' we assign the correct functions to the topEnv. However, before we check if the user has
// the client_secret.json in the working directory, due it's necessary for using the youtube api.
topEnv['use'] = function(...argumentArray) {
	if (argumentArray.length !== 1) {
		throw new TypeError('Use function must receive only one argument.');
	}
	else {
		if (argumentArray[0].toLowerCase() === 'youtube') { // Update libraries
			if (!fs.existsSync('client_secret.json')) { // Check if it has the necessary api key.
				throw new TypeError('In order to use youtube module functions, you must have a client_secret.json file!');
			}

			console.log("YouTube Module charged! To show help use: showYouTubeHelp");
			topEnv['showYouTubeHelp'] = showYouTubeHelp;
			topEnv['showComments'] = showComments;
			topEnv['showChannelInfo'] = showChannelInfo;
			topEnv['showChannelVideos'] = showChannelVideos;
			topEnv['searchVideos'] = searchVideos;
			topEnv['searchChannels'] = searchChannels;
		}
	}
};

How to use

For using it the first requisite is to have the client_secret.json file that offer the youtube API. In order to do that follow this tutorial for Node.JS: Node.js QuickStart

After that you have a set of examples in the examples folder to try. You can enter by command line:

npm start

Or

node main.js examples/<example>.egg

Have fun!

Author

Ángel Igareta