<commit_before>import discord
import urllib
import re
import random
import requests
import wikipedia
from bs4 import BeautifulSoup
from discord.ext import commands

class Search():
    def __init__(self, bot):
        self.bot = bot

    @commands.command()    
    async def wiki(self, *, query : str):
        """Returns a wikipedia summary"""
        ans = wikipedia.summary(query)
        await self.bot.say(ans)
  
    @commands.command()
    async def scrabble (self, word:str):
        """Returns the scrabble points of the word"""
        webpage = "http://www.dictionary.com/browse/" + word
        r = requests.get(webpage).text
        soup = BeautifulSoup(r)
        try:
            points = soup.find_all('div', {'class':'game-scrabble'})[0].text
        except IndexError:
            points = 0
        await self.bot.say(points)
    
    @commands.command()
    async def youtube(self, *, query:str):
        """Returns the first youtube video"""        
        webpage = 'https://www.youtube.com/results?search_query=' + query.replace(" ", "+")
        html_content = urllib.request.urlopen(webpage)
        str_html = html_content.read().decode("utf-8")
        match = re.search(r'href="/watch?([^\'" >]+)', str_html)
        if match:
            end = match.group(0).split("\"")
            await self.bot.say(webpage + ' https://www.youtube.com' + end[1])
        else:
            await self.bot.say('https://www.youtube.com/watch?v=rbeEbJdlAX4')
       
    @commands.command(pass_context=True)
    async def bImage(self, ctx, query:str, num:int = 1):
        """Returns the first image from the bing search"""
        webpage = "http://www.bing.com/images/search?q=" + query.replace(" ", "+") + "&view=detailv2&adlt=off&selectedIndex=0"
        html_content = urllib.request.urlopen(webpage)
        str_html = html_content.read().decode("utf-8")
        match = re.findall(r'src="http://?([^\'" >]+)', str_html)
        if match:
            try:
                await self.bot.say("http://" + match[num-1])
            except:<commit_msg>Updated youtube command<commit_after>import discord
import urllib
import re
import random
import requests
import wikipedia
from bs4 import BeautifulSoup
from discord.ext import commands

class Search():
    def __init__(self, bot):
        self.bot = bot

    @commands.command()    
    async def wiki(self, *, query : str):
        """Returns a wikipedia summary"""
        ans = wikipedia.summary(query)
        await self.bot.say(ans)
  
    @commands.command()
    async def scrabble (self, word:str):
        """Returns the scrabble points of the word"""
        webpage = "http://www.dictionary.com/browse/" + word
        r = requests.get(webpage).text
        soup = BeautifulSoup(r)
        try:
            points = soup.find_all('div', {'class':'game-scrabble'})[0].text
        except IndexError:
            points = 0
        await self.bot.say(points)
    
    @commands.command()
    async def youtube(self, *, query:str):
        """Returns the first youtube video"""        
        isNotAVideo = True
        url = 'https://youtube.com/results?search_query=' + query.replace(" ", "+")
        r = requests.get(url).text
        soup = BeautifulSoup(r)
        yt = soup.find_all("div", {"class": "yt-lockup-content"})
        num = 0
        while isNotAVideo:
            try:
                if (not 'list' in yt[num].a.get('href') and 'watch' in yt[num].a.get('href') and len(yt[num].get('class')) < 2):
                    isNotAVideo = False
                else:
                    num = num + 1
            except AttributeError:
                num = num + 1
                
        link = yt[num].a.get('href')
        page = 'https://youtube.com' + link
        await self.bot.say(page)
       
    @commands.command(pass_context=True)
    async def bImage(self, ctx, query:str, num:int = 1):
        """Returns the first image from the bing search"""
        webpage = "http://www.bing.com/images/search?q=" + query.replace(" ", "+") + "&view=detailv2&adlt=off&selectedIndex=0"
        html_content = urllib.request.urlopen(webpage)
        str_html = html_content.read().decode("utf-8")
        match = re.findall(r'src="http://?([^\'" >]+)', str_html)
        if match:
            try:
                await self.bot.say("http://" + match[num-1])
            except:
{'fraction_non_alphanumeric': 0.14785992217898833, 'fraction_numerical': 0.005493247882810712, 'mean_word_length': 2.229859571322986, 'pattern_counts': {'":': 1, '<': 4, '<?xml version=': 0, '>': 6, 'https://': 5, 'lorem ipsum': 0, 'www.': 7, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4567659', 'n_tokens_mistral': 1372, 'n_tokens_neox': 1337, 'n_words': 300}