-
Notifications
You must be signed in to change notification settings - Fork 4
Update plugin Anime #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
zmiana od @po50on
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dyskusja w toku.
| addon.addDir("Sezon Zima " + str(counter), 'http://www.animezone.pl/anime/sezony/' + str(counter) + '/zima', | ||
| mode=3) | ||
| counter += 1 | ||
| counter = counter - 1 |
There was a problem hiding this comment.
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 == 30: | ||
| counter = 1982 | ||
| while counter <= 2019: | ||
| counter = 2019 |
There was a problem hiding this comment.
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.
| counter = 1982 | ||
| while counter <= 2019: | ||
| counter = 2019 | ||
| while counter > 1982: |
There was a problem hiding this comment.
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):
...There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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|
@po50on, ależ nie ma sprawy, wszyscy się uczymy. Gorzej jak ktoś nie chce się rozwijać.
A gdzie na stronie jest taka informacja? Nie widzę jej przy liście seriali. Masz na myśli listę odcinków? Tam już są flagi. <tr>
<td class="text-center"><strong>12</strong></td>
<td class="episode-title">Świt ciemności.</td>
<td style="padding: 0" class="text-center"><span class="sprites PL"></span></td>
<td class="bg-success text-center filler">Nie</td>
<td class="text-center"><a href="../odcinek/11eyes/12" class="btn btn-xs btn-success _visited">Zobacz</a></td>
</tr>Jeśli tak, to może to wyglądać np. tak: def ListowaniOdcinkow():
url = params['url']
iconimage = params.get('iconimage', '')
r = client.request(url)
result = client.parseDOM(r, 'table', attrs={'class': 'table table-bordered table-striped table-hover episodes'})
for tr in client.parseDOM(result, 'tr'):
link = client.parseDOM(tr, 'a', ret='href')[0]
nazwa = client.parseDOM(tr, 'td', attrs={'class': 'episode-title'})[0]
odcinek = client.parseDOM(tr, 'strong')[0]
lang = client.parseDOM(tr, 'span', ret='class')[0].split()[-1]
nazwa = '{ep:02d}. {title} ({lang})'.format(title=nazwa, ep=int(odcinek), lang=lang)
addon.addDir(nazwa, urljoin(url, link), mode=5, icon=iconimage)Na górze pliku jeszcze trzeba dodać (dla Python 2): from urlparse import urljoinPisałem „w ciemno”, więc musisz to przetestować. Powinna być lista typu: EDIT: |
|
@xulek, jak już dodamy nowy sposób parsowania to może wyglądać tak: def ListowaniOdcinkow():
url = params['url']
iconimage = params.get('iconimage', '')
r = client.request(url)
for a, name, ep, lang in \
pdom.select(r, 'table.episodes tr {a, .episode-title, strong, span}'):
lang = lang.attr('class').split()[-1]
title = '{ep.text}. {title.text} ({lang})'.format(**locals())
addon.addDir(title, urljoin(url, a.href), mode=5, icon=iconimage)Albo, porównawczo, wyciągając od razu wartości węzłów: def ListowaniOdcinkow():
url = params['url']
iconimage = params.get('iconimage', '')
r = client.request(url)
for (link,), (name,), (ep,), (lang,) in pdom.select(r,
'table.episodes tr {a(href), .episode-title::text, strong::text, span(class)}'):
lang = lang.split()[-1]
title = '{ep}. {title} ({lang})'.format(**locals())
addon.addDir(title, urljoin(url, link), mode=5, icon=iconimage) |
|
niestety wywala blad |
|
bardziej mi chodziło o jezyk w linkach |
|
U mnie wtyczka działa bez błędów, a jeśli chodzi o język źródła to zapomniałem go dodać w listowaniu odcinków. Jak znajdę chwilkę to wrzucę tu poprawkę :) |
|
@po50on, zajrzę wieczorem i sprawdzę. |
|
@rysson podejrzewam, że chodzi o oznaczenie czy odcinek z danego linku jest w języku polskim. Jest zrobiona zmienna lang, ale nie jest używana. |
|
OKi, zaczynam łapać, język jest w dwóch miejscach. Na liście odcinków i po wybraniu odcinka jest lista linków w różnymi językami (i tam jest Wcześniej nie zaszedłem tak daleko. Akurat to nie jest mój ulubiony gatunek, choć Pszczółkę Maję oglądałem na dobranockę :-) Była a niebo lepsza od Koralgola :-D Co do niedziałania, to złapał nagłówek listy a tam nie ma danych. Trzeba by dodać tuż po pobraniu strony i znalezieniu table, a przed pętlą: result = client.parseDOM(result, 'tbody')Może jeszcze spojrzę na język i wystawię zmiany. |
|
dieki a pomoc przyokazji ucze sie pythona :) |
|
@po50on, fajnie, ja też :-) Nawet książkę kupiłem „Zaawansowany Python (Fluent Python)”. Gdzieś od połowy (~350 str.) zaczęsło robić się ciekawie. Poprzerabiałem nieco te funkcję, wokół których się kręciłeś. Zerknij na #34 i zobacz czy tak może być. Jak masz pytania to już tam. Przy okazji mógłbyś sprawdzić czy działa, bo ja tylko przejrzałem ze 3..4 pozycje. |
zmiana od @po50on
#30