import datetime as dt import functools import itertools import json import re import time import urllib.parse from .common import InfoExtractor, SearchInfoExtractor from ..networking import Request from ..networking.exceptions import HTTPError from ..utils import ( ExtractorError, OnDemandPagedList, clean_html, float_or_none, int_or_none, join_nonempty, parse_duration, parse_iso8601, parse_resolution, qualities, remove_start, str_or_none, traverse_obj, try_get, unescapeHTML, update_url_query, url_or_none, urlencode_postdata, urljoin, ) class NiconicoBaseIE(InfoExtractor): _NETRC_MACHINE = 'niconico' _GEO_COUNTRIES = ['JP'] _GEO_BYPASS = False def _perform_login(self, username, password): login_ok = True login_form_strs = { 'mail_tel': username, 'password': password, } self._request_webpage( 'https://account.nicovideo.jp/login', None, note='Acquiring Login session') page = self._download_webpage( 'https://account.nicovideo.jp/login/redirector?show_button_twitter=1&site=niconico&show_button_facebook=1', None, note='Logging in', errnote='Unable to log in', data=urlencode_postdata(login_form_strs), headers={ 'Referer': 'https://account.nicovideo.jp/login', 'Content-Type': 'application/x-www-form-urlencoded', }) if 'oneTimePw' in page: post_url = self._search_regex( r'