Example #1
0
def get_top_500():
    data = set()
    jikan = Jikan()

    for i in range(1, 11):
        time.sleep(2)
        print(f"Processing page: {i}")
        top_anime = jikan.top(type='anime', page=i, subtype='bypopularity')
        for j in range(0, 50):
            if top_anime["top"][j]["type"] not in ["OVA", "Music", "Special"]:
                data.add(top_anime["top"][j]["title"])

    for i in range(11, 16):
        time.sleep(2)
        print(f"Processing page: {i}")
        top_anime = jikan.top(type='anime', page=i, subtype='bypopularity')
        for j in range(0, 50):
            if (top_anime["top"][j]["type"] not in [
                    "OVA", "Music", "Special"
            ]) and top_anime["top"][j]["score"] >= 7.4:
                data.add(top_anime["top"][j]["title"])

    for i in range(16, 21):
        time.sleep(2)
        print(f"Processing page: {i}")
        top_anime = jikan.top(type='anime', page=i, subtype='bypopularity')
        for j in range(0, 50):
            if (top_anime["top"][j]["type"] not in [
                    "OVA", "Music", "Special"
            ]) and top_anime["top"][j]["score"] >= 7.8:
                data.add(top_anime["top"][j]["title"])

    return data
Example #2
0
def rand(filename, is_header, page, start):
    import csv
    import time
    from jikanpy import Jikan, exceptions
    jikan = Jikan()

    def write_row(info, fieldnames, writer):
        f = (info.title, info.type, info.episodes, info.studio, info.source,
             info.genre, info.score, info.synopsis, info.url, info.image_url)
        row = {x: y for x, y in zip(fieldnames, f)}
        writer.writerow(row)
        #  time.sleep(15)

    with open(filename, 'a', newline='', encoding='UTF-8') as csvfile:
        fieldnames = [
            'title', 'type', 'episodes', 'studio', 'src', 'genre', 'score',
            'synopsis', 'url', 'image_url'
        ]
        writer = csv.DictWriter(csvfile, fieldnames=fieldnames)

        if is_header:
            writer.writeheader()

        top_anime = jikan.top(type='anime')
        for index, each in enumerate(top_anime['top'][start:]):
            print('Processing anime number [{}].'.format(index + start))
            try:
                info = AnimePageInfo(each['mal_id'])
            except exceptions.APIException:
                print('FAIL.')
                exit(1)
            else:
                write_row(info, fieldnames, writer)
Example #3
0
 def top_animes(self, message, name_sender):
     jikan = Jikan()
     anime_name = []
     top_anime = jikan.top(type='anime')
     for episode in top_anime['top']:
         anime_name.append([episode['title']])
     self.post(message="Top_5 animes \n 1°%s\n2°%s\n3°%s\n4°%s\n5°%s." %
               (anime_name[0], anime_name[1], anime_name[2], anime_name[3],
                anime_name[4]))
Example #4
0
    def handle(self, *args, **options):
        jikan = Jikan()

        resp = jikan.top('anime')
        for data in resp['top']:
            print(data)
            form = AnimeForm(data=data)
            if form.is_valid():
                form.save()
            else:
                print(form.errors)
Example #5
0
	async def top_anime(ctx,rank=9999):
		jk = Jikan()
		top_anime = jk.top(type="anime")['top']
		if rank != 9999:
			if rank > len(top_anime):
				await ctx.send('baka, only top 50 exists')
			else:
				rank = rank -1
				data = "{} \n\nName: {}\nRank: {}\nMovie\nScore {}".format(top_anime[rank]['image_url'],top_anime[rank]['title'],top_anime[rank]['rank'],top_anime[rank]['score'])
				await ctx.send(data)
		else:

			for i in range(10):
				if top_anime[i]['episodes'] == 1:
					data = "{} \n\nName: {}\nRank: {}\nMovie\nScore {}".format(top_anime[i]['image_url'],top_anime[i]['title'],top_anime[i]['rank'],top_anime[i]['score'])
				else:
					data = "{} \n\nName: {}\nRank: {}\nEpisodes: {}\nScore: {}".format(top_anime[i]['image_url'],top_anime[i]['title'],top_anime[i]['rank'],top_anime[i]['episodes'],top_anime[i]['score'])
				await ctx.send(data)
Example #6
0
def main():
    conn = connect_to_db()
    jikan = Jikan()
    for i in range(1, 171):
        anime = jikan.top(type="anime", page=i)
        top_anime = anime["top"]
        for anime in top_anime:
            mal_id = anime["mal_id"]
            try:
                insert_top_anime_record(conn, mal_id=mal_id)
            except psycopg2.errors.UniqueViolation:
                continue

            find_and_insert_anime_chars_for_mal_id(conn, anime_mal_id=mal_id)

        time.sleep(2)

    conn.close()
Example #7
0
def get_top_anime_mal_ids(num_top_anime=1000):
    """Returns list of MyAnimeList anime IDs for anime listed on top anime pages.

    Args:
        num_top_anime: Number of top anime to scrape anime IDs for.
    """
    jikan = Jikan()
    counter = 0
    mal_ids = []
    num_top_anime_pages = num_top_anime // 50  # 50 anime per top anime page
    for i in range(1, num_top_anime_pages +
                   1):  # +1 because range does not include stop
        result_page = jikan.top(type='anime', page=i)['top']
        time.sleep(2 + 2 * random.random())
        counter += 1
        print(counter)
        for result in result_page:
            mal_ids.append(result['mal_id'])
    return mal_ids
def get_top_anime_ids(num_pages=200):
    """
    Returns a list of anime IDs from MyAnimeList's top anime pages.
    
    Args:
        num_pages: Number of top anime pages to scrape anime IDs for. 
    """
    jikan = Jikan()
    mal_ids = []
    for i in range(0, num_pages + 1):
        try:
            results = jikan.top(type='anime', page=i)['top']
            time.sleep(
                2 + 2 * random.random())  #Jikan requests limit: 2 requests/sec
            for result in results:
                mal_ids.append(result['mal_id'])
        except:
            pass
    return mal_ids
Example #9
0
from hikka.services.anime import AnimeService
from hikka.services.files import FileService
from hikka.tools import helpers
from jikanpy import Jikan
from hikka import utils
import time

jikan = Jikan()
top = jikan.top(type="anime")

for index, item in enumerate(top["top"]):
    data = jikan.anime(item["mal_id"])
    myanimelist = data["mal_id"]

    if data["synopsis"] is None:
        data["synopsis"] = "Lorem ipsum dolor sit amet."

    title = AnimeService.get_title(data["title"])
    anime = AnimeService.create(title, data["synopsis"],
                                helpers.category(data["type"].lower()),
                                helpers.state("released"),
                                utils.create_slug(data["title"]))

    anime.search = utils.create_search(anime.title.ua, data["title_synonyms"])
    anime.external = AnimeService.get_external(myanimelist)
    anime.year = data["aired"]["prop"]["from"]["year"]
    anime.teams = [helpers.team("fanvox")]
    anime.aliases = data["title_synonyms"]
    anime.total = data["episodes"]
    anime.rating = data["score"]
Example #10
0
naruto = jikan.search(search_type='anime', query='naruto')
pprint(naruto)

winter_2018 = jikan.season(year=2018, season='winter')
pprint(winter_2018)

archive = jikan.season_archive()
pprint(archive)

later = jikan.season_later()
pprint(later)

monday = jikan.schedule(day='monday')
pprint(monday)

top_anime = jikan.top(type='anime')
pprint(top_anime)

action = jikan.genre(type='anime', genre_id=1)
pprint(action)

deen = jikan.producer(producer_id=37)
pprint(deen)

jump = jikan.magazine(magazine_id=83)
pprint(jump)

nekomata1037 = jikan.user(username='******')
pprint(nekomata1037)

fantasy_anime_league = jikan.club(379)
Example #11
0
naruto = jikan.search(search_type="anime", query="naruto")
pprint(naruto)

winter_2018 = jikan.season(year=2018, season="winter")
pprint(winter_2018)

archive = jikan.season_archive()
pprint(archive)

later = jikan.season_later()
pprint(later)

monday = jikan.schedule(day="monday")
pprint(monday)

top_anime = jikan.top(type="anime")
pprint(top_anime)

action = jikan.genre(type="anime", genre_id=1)
pprint(action)

deen = jikan.producer(producer_id=37)
pprint(deen)

jump = jikan.magazine(magazine_id=83)
pprint(jump)

nekomata1037 = jikan.user(username="******")
pprint(nekomata1037)

fantasy_anime_league = jikan.club(379)
Example #12
0
class Graphs:
    def __init__(self,
                 app_name,
                 graph_title,
                 graph_id,
                 slider_id,
                 top_bool,
                 app_input_state_list,
                 graph_color='Crimson',
                 time_scale='12-m',
                 anime_name="default"):
        self.jikan = Jikan()
        self.app_name = app_name
        self.graph_title = graph_title
        self.graph_id = graph_id
        self.slider_id = slider_id
        self.top_bool = top_bool
        self.app_input_state_list = app_input_state_list
        self.graph_color = graph_color
        self.time_scale = time_scale
        self.anime_name = anime_name
        self.app = DjangoDash(app_name,
                              external_stylesheets=external_stylesheets)
        self.app.layout = html.Div([
            html.H1(graph_title),
            #html.Button("Custom export", id="export_table", **{"data-dummy": ""}),
            self.return_graph(
            ),  # dcc.Graph(id=graph_id, animate=True, style={"backgroundColor": "#1a2d46", 'color': '#ffffff'})
            # html.Button("Custom export", id="export_table", **{"data-dummy": ""}),
            # dcc.Slider(
            #     id=slider_id,
            #     marks={i: '{}'.format(i) for i in range(20)},
            #     max=20,
            #     value=2,
            #     step=1,
            #     updatemode='drag',
            #     min=0,
            # ),
        ])

        self.app.clientside_callback(
            """
            function(n_clicks) {
                if (n_clicks > 0)
                    document.querySelector("#topanime a.modebar-btn").click()
                return ""
            }
            """, Output("export_table", "data-dummy"),
            [Input("export_table", "n_clicks")])

        @self.app.callback(Output(graph_id, 'figure'), app_input_state_list)
        def display_value(value):

            trendshow = TrendReq(hl='en-US', tz=360)

            kw_list = []
            if top_bool:
                for k in range(0, 5):
                    kw_list.append(self.get_top_anime_names(k, 'tv'))
            else:
                kw_list.append(self.search_anime(anime_name))
            kw_group = list(zip(*[iter(kw_list)] * 1))
            kw_grplist = [list(x) for x in kw_group]
            dic = {}
            i = 0
            for kw in kw_grplist:
                trendshow.build_payload(kw, timeframe='today 1-w', geo='')
                dic[i] = trendshow.interest_over_time()
                i += 1

            trendframe = pd.concat(dic, axis=1)
            trendframe.columns = trendframe.columns.droplevel(0)
            trendframe = trendframe.drop('isPartial', axis=1)

            trace = [
                go.Scatter(x=trendframe.index, y=trendframe[col], name=col)
                for col in trendframe.columns
            ]
            layout = dict(paper_bgcolor='#27293d',
                          plot_bgcolor='rgba(0,0,0,0)',
                          font=dict(color='white'),
                          showlegend=True)
            return {'data': trace, 'layout': layout}

    def get_top_anime_names(self, rank: int, subtype: str):
        top_anime = self.jikan.top(type='anime', page=1, subtype=subtype)
        time.sleep(0.5)
        return top_anime["top"][rank]["title"]

    def search_anime(self, anime_name):
        search = self.jikan.search('anime', anime_name)
        time.sleep(0.5)
        return search["results"][0]["title"]

    def return_graph(self):
        trendshow = TrendReq(hl='en-US', tz=360)

        kw_list = []
        if self.top_bool:
            for k in range(0, 5):
                kw_list.append(self.get_top_anime_names(k, 'tv'))
        else:
            kw_list.append(self.search_anime(self.anime_name))
        kw_group = list(zip(*[iter(kw_list)] * 1))
        kw_grplist = [list(x) for x in kw_group]
        dic = {}
        i = 0
        for kw in kw_grplist:
            trendshow.build_payload(kw,
                                    timeframe='today ' + self.time_scale,
                                    geo='')
            dic[i] = trendshow.interest_over_time()
            i += 1

        trendframe = pd.concat(dic, axis=1)
        trendframe.columns = trendframe.columns.droplevel(0)
        trendframe = trendframe.drop('isPartial', axis=1)

        fig = {
            'data': [
                go.Scatter(x=trendframe.index,
                           y=trendframe[col],
                           name=col,
                           line=dict(color=self.graph_color))
                for col in trendframe.columns
            ],
            'layout':
            dict(
                #legend=dict(font=dict(color='#7f7f7f')),
                paper_bgcolor='#27293d',
                plot_bgcolor='rgba(0,0,0,0)',
                font=dict(color='white'),
                showlegend=True)
        }

        return dcc.Graph(id=self.graph_id, figure=fig)

    def return_layout(self):
        return self.app.layout
Example #13
0

@app.route("/trending", methods=["POST", "GET","HEAD","PUT"])
def trending():
    
    
<<<<<<< HEAD
=======
    
>>>>>>> 2c3276570432b60eb87f072acb27c369f3115ac9
    

    #res = requests.get("https://kitsu.io/api/edge/users?sort=-rating" )
   # if res.status_code != 200:
    #    raise Exception("ERROR: API request unsuccessful.")
    data = jikan.top(type='anime')
    data_1=[]
    for i in range (0,25) :
        rate_1=data["top"][i]["title"]
        e=data["top"][i]["url"]
        img_src=data["top"][i]["image_url"]
        l=[rate_1, img_src,e]
        data_1.append(l)
    
    return render_template("trend.html",data_1=data_1)
    
@app.route("/ko",methods=["GET"])
def indexy():
    data=[]
    i=0
    while i<10 :