Skip to content

Commit

Permalink
Added support for animeunity
Browse files Browse the repository at this point in the history
  • Loading branch information
luca-martinelli-09 committed Jan 19, 2021
1 parent df58a53 commit e7729ca
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ See [example.csv](example.csv) for an example of CSV file.
- [x] guardaserie
- [x] seriehd
- [x] vvvvid
- [x] animeunity

## Arguments avaiable

Expand Down
3 changes: 3 additions & 0 deletions serie_dl/content_parser.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from serie_dl.parsers.animeunity_parser import AnimeUnityParser
from urllib import parse
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from urllib.parse import urlparse
from serie_dl.parsers.genio_parser import GenioParser
from serie_dl.parsers.vvvvid_parser import VVVVIDParser
from serie_dl.parsers.seriehd_parser import SerieHDParser
from serie_dl.parsers.animeunity_parser import AnimeUnityParser


class ContentParser:
Expand All @@ -27,6 +29,7 @@ def __init__(self, options, custom_parser=None):
"ilgeniodellostreaming": GenioParser(self.__options),
"vvvvid": VVVVIDParser(self.__options),
"guardaserie": GenioParser(self.__options),
"animeunity": AnimeUnityParser(self.__options),
"seriehd": SerieHDParser(self.__options)}
if custom_parser is not None:
self.__site_parsers.update(custom_parser)
Expand Down
49 changes: 49 additions & 0 deletions serie_dl/parsers/animeunity_parser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import requests
import json
import re

class AnimeUnityParser:
__options = {}
__content = {}
# ["movie"] for movie only, ["serie"] for serie only,
support = ["serie"]

def __init__(self, options=None, content=None):
# update options with one given by the user (if there's)
if options is not None:
self.__options.update(options)
if content is not None:
self.__content.update(content)

# called to set content (eg. you can get page url)
def set_content(self, content):
self.__content.update(content)

# driver is selenium webdriver
def parse_title(self, driver):
return driver.find_element_by_css_selector("h1.title").get_attribute("textContent").strip()

def parse_seasons(self, driver):
response = requests.get(
"https://lucamartinelli.hopto.org/interface.php?function=serie-dl-animeunity&url=" + self.__content["url"]).text
data = json.loads(response)
return [{"episodes": data["episodes"]}]

# element is season element got by parse_seasons
def parse_episodes(self, driver, element):
return element["episodes"]

# element is episode element got by parse_episodes
def parse_episode_title(self, driver, element):
return "Episodio " + element["number"]

# element is episode element got by parse_episodes
def parse_episode_link(self, driver, element):
return element["link"]

# element is episode element got by parse_episodes
def parse_ep_ss_num(self, driver, element):
return [1, int(element["number"])]

def parse_dwn_url(self, driver):
return driver.current_url
1 change: 0 additions & 1 deletion serie_dl/parsers/vvvvid_parser.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import re
import requests
import json


Expand Down

0 comments on commit e7729ca

Please sign in to comment.