Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions plugin.video.anime/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
def CATEGORIES():
addon.addDir("Szukaj anime", '', mode=1)
addon.addDir("Alfabetycznie", '', mode=10)
addon.addDir("Alfabetyczniefilmy", '', mode=15)
addon.addDir("Gatunki", '', mode=20)
addon.addDir("Sezony", '', mode=30)
addon.addDir("Rankingi", '', mode=40)
Expand Down Expand Up @@ -77,7 +78,7 @@ def Wyszukiwanie():
def Alfabetycznie():
url = 'http://animezone.pl'

r = client.request('http://animezone.pl/anime/lista')
r = client.request('https://www.animezone.pl/anime/lista')

result = client.parseDOM(r, 'div', attrs={'class': 'btn-group btn-group-xs'})
linki_litery = client.parseDOM(result, 'a', ret='href')
Expand All @@ -88,6 +89,19 @@ def Alfabetycznie():
addon.addDir(str(litery[counter]), link, mode=3)
counter += 1

def Alfabetyczniefilmy():
url = 'http://animezone.pl'

r = client.request('https://www.animezone.pl/anime/filmy')

result = client.parseDOM(r, 'div', attrs={'class': 'btn-group btn-group-xs'})
linki_litery = client.parseDOM(result, 'a', ret='href')
litery = client.parseDOM(result, 'a')
counter = 0
for link in linki_litery:
link = url + link
addon.addDir(str(litery[counter]), link, mode=3)
counter += 1

def ListowanieAnime():
url = params['url']
Expand Down Expand Up @@ -321,6 +335,9 @@ def OdpalanieLinku():
elif mode == 10:
Alfabetycznie()

elif mode == 15:
Alfabetyczniefilmy()

elif mode == 20:
addon.addDir("Typ widowni", '', mode=21)
addon.addDir("Gatunek", '', mode=22)
Expand All @@ -331,17 +348,17 @@ def OdpalanieLinku():
Gatunki('http://www.animezone.pl/gatunki?type=', 0)

elif mode == 22:
Gatunki('http://www.animezone.pl/gatunki?species=', 1)
Gatunki('http://www.animezone.pl/gatunki?species[]=', 1)

elif mode == 23:
Gatunki('http://www.animezone.pl/gatunki?topic=', 2)
Gatunki('http://www.animezone.pl/gatunki?topic[]=', 2)

elif mode == 24:
Gatunki('http://www.animezone.pl/gatunki?years=', 3)

elif mode == 30:
counter = 1982
while counter <= 2019:
counter = 2019
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jako ciekawostkę, bo nie wymagam zmiany (było też tak sobie), podaję alternatywę:

    for counter in xrange(2019, 1982, -1):
        ...

Wtedy już by nie było odejmowania counter na końcu.

while counter > 1982:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@po50on, Tutaj pytanie, poprzednio było od 1982 do 2019 (włącznie).
Teraz jest od 2019 do 1983 (włącznie). Czy 1982 ma teraz nie wchodzić w zakres?
Jeśli ma wejść to powinno być:

    while counter >= 1982:
        ...

albo w mojej propozycji (drugi parametr xrange() i range() czyli koniec zakresu zawsze nie wchodzi):

    for counter in xrange(2019, 1981, -1):
        ...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

twoja propozycja mi sie podoba

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

można jeszcze 2019 zamienić na:
int(datetime.date.today().year) + 1
oczywiście wcześniej importując datetime

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jak to jest rok, to jasne. Nawet int nie jest potrzebny

import datetime.date
datetime.date.today().year + 1

addon.addDir("Sezon Wiosna " + str(counter), 'http://www.animezone.pl/anime/sezony/' + str(counter) + '/wiosna',
mode=3)
addon.addDir("Sezon Lato " + str(counter), 'http://www.animezone.pl/anime/sezony/' + str(counter) + '/lato',
Expand All @@ -350,7 +367,7 @@ def OdpalanieLinku():
mode=3)
addon.addDir("Sezon Zima " + str(counter), 'http://www.animezone.pl/anime/sezony/' + str(counter) + '/zima',
mode=3)
counter += 1
counter = counter - 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To już poproszę na wzór oryginału, nieco bardziej czytelne czyli:

counter -= 1


elif mode == 40:
addon.addDir("Ranking ocen", 'http://www.animezone.pl/anime/ranking/ocen', mode=41)
Expand Down