mirror of
				https://github.com/RicterZ/nhentai.git
				synced 2025-11-04 02:50:55 +01:00 
			
		
		
		
	Merge branch 'master' into dev
This commit is contained in:
		@@ -64,6 +64,8 @@ def cmd_parser():
 | 
				
			|||||||
                      help='page number of search results')
 | 
					                      help='page number of search results')
 | 
				
			||||||
    parser.add_option('--max-page', type='int', dest='max_page', action='store', default=1,
 | 
					    parser.add_option('--max-page', type='int', dest='max_page', action='store', default=1,
 | 
				
			||||||
                      help='The max page when recursive download tagged doujinshi')
 | 
					                      help='The max page when recursive download tagged doujinshi')
 | 
				
			||||||
 | 
					    parser.add_option('--page-range', type='string', dest='page_range', action='store',
 | 
				
			||||||
 | 
					                      help='page range of favorites.  e.g. 1,2-5,14')
 | 
				
			||||||
    parser.add_option('--sorting', dest='sorting', action='store', default='date',
 | 
					    parser.add_option('--sorting', dest='sorting', action='store', default='date',
 | 
				
			||||||
                      help='sorting of doujinshi (date / popular)', choices=['date', 'popular'])
 | 
					                      help='sorting of doujinshi (date / popular)', choices=['date', 'popular'])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -35,7 +35,7 @@ def main():
 | 
				
			|||||||
        if not options.is_download:
 | 
					        if not options.is_download:
 | 
				
			||||||
            logger.warning('You do not specify --download option')
 | 
					            logger.warning('You do not specify --download option')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        doujinshis = favorites_parser()
 | 
					        doujinshis = favorites_parser(options.page_range)
 | 
				
			||||||
        print_doujinshi(doujinshis)
 | 
					        print_doujinshi(doujinshis)
 | 
				
			||||||
        if options.is_download and doujinshis:
 | 
					        if options.is_download and doujinshis:
 | 
				
			||||||
            doujinshi_ids = [i['id'] for i in doujinshis]
 | 
					            doujinshi_ids = [i['id'] for i in doujinshis]
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -65,7 +65,7 @@ def _get_title_and_id(response):
 | 
				
			|||||||
    return result
 | 
					    return result
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def favorites_parser():
 | 
					def favorites_parser(page_range=''):
 | 
				
			||||||
    result = []
 | 
					    result = []
 | 
				
			||||||
    html = BeautifulSoup(request('get', constant.FAV_URL).content, 'html.parser')
 | 
					    html = BeautifulSoup(request('get', constant.FAV_URL).content, 'html.parser')
 | 
				
			||||||
    count = html.find('span', attrs={'class': 'count'})
 | 
					    count = html.find('span', attrs={'class': 'count'})
 | 
				
			||||||
@@ -89,7 +89,12 @@ def favorites_parser():
 | 
				
			|||||||
    if os.getenv('DEBUG'):
 | 
					    if os.getenv('DEBUG'):
 | 
				
			||||||
        pages = 1
 | 
					        pages = 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for page in range(1, pages + 1):
 | 
					    page_range_list = range(1, pages + 1)
 | 
				
			||||||
 | 
					    if page_range:
 | 
				
			||||||
 | 
					        logger.info('page range is {0}'.format(page_range))
 | 
				
			||||||
 | 
					        page_range_list = page_range_parser(page_range, pages)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for page in page_range_list:
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            logger.info('Getting doujinshi ids of page %d' % page)
 | 
					            logger.info('Getting doujinshi ids of page %d' % page)
 | 
				
			||||||
            resp = request('get', constant.FAV_URL + '?page=%d' % page).content
 | 
					            resp = request('get', constant.FAV_URL + '?page=%d' % page).content
 | 
				
			||||||
@@ -100,6 +105,30 @@ def favorites_parser():
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    return result
 | 
					    return result
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def page_range_parser(page_range, max_page_num):
 | 
				
			||||||
 | 
					    pages = set()
 | 
				
			||||||
 | 
					    ranges = str.split(page_range, ',')
 | 
				
			||||||
 | 
					    for range_str in ranges:
 | 
				
			||||||
 | 
					        idx = range_str.find('-')
 | 
				
			||||||
 | 
					        if idx == -1:
 | 
				
			||||||
 | 
					            try:
 | 
				
			||||||
 | 
					                page = int(range_str)
 | 
				
			||||||
 | 
					                if page <= max_page_num:
 | 
				
			||||||
 | 
					                    pages.add(page)
 | 
				
			||||||
 | 
					            except ValueError:
 | 
				
			||||||
 | 
					                logger.error('page range({0}) is not valid'.format(page_range))
 | 
				
			||||||
 | 
					        else:
 | 
				
			||||||
 | 
					            try:
 | 
				
			||||||
 | 
					                left = int(range_str[:idx])
 | 
				
			||||||
 | 
					                right = int(range_str[idx+1:])
 | 
				
			||||||
 | 
					                if right > max_page_num:
 | 
				
			||||||
 | 
					                    right = max_page_num
 | 
				
			||||||
 | 
					                for page in range(left, right+1):
 | 
				
			||||||
 | 
					                    pages.add(page)
 | 
				
			||||||
 | 
					            except ValueError:
 | 
				
			||||||
 | 
					                logger.error('page range({0}) is not valid'.format(page_range))
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    return list(pages)    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def doujinshi_parser(id_):
 | 
					def doujinshi_parser(id_):
 | 
				
			||||||
    if not isinstance(id_, (int,)) and (isinstance(id_, (str,)) and not id_.isdigit()):
 | 
					    if not isinstance(id_, (int,)) and (isinstance(id_, (str,)) and not id_.isdigit()):
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,6 +17,8 @@ function changePage(pageNum) {
 | 
				
			|||||||
    const display = document.getElementById('dest');
 | 
					    const display = document.getElementById('dest');
 | 
				
			||||||
    display.style.backgroundImage = `url("${current.src}")`;
 | 
					    display.style.backgroundImage = `url("${current.src}")`;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    scroll(0,0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    document.getElementById('page-num')
 | 
					    document.getElementById('page-num')
 | 
				
			||||||
        .innerText = [
 | 
					        .innerText = [
 | 
				
			||||||
                (pageNum + 1).toLocaleString(),
 | 
					                (pageNum + 1).toLocaleString(),
 | 
				
			||||||
@@ -47,9 +49,8 @@ document.onkeypress = event => {
 | 
				
			|||||||
    switch (event.key.toLowerCase()) {
 | 
					    switch (event.key.toLowerCase()) {
 | 
				
			||||||
        // Previous Image
 | 
					        // Previous Image
 | 
				
			||||||
        case 'w':
 | 
					        case 'w':
 | 
				
			||||||
			document.getElementById("dest").style.height = "200%";
 | 
						   scrollBy(0, -40);
 | 
				
			||||||
			document.getElementById("list").style.height = "200%";
 | 
						   break;
 | 
				
			||||||
            break;
 | 
					 | 
				
			||||||
        case 'a':
 | 
					        case 'a':
 | 
				
			||||||
            changePage(currentPage - 1);
 | 
					            changePage(currentPage - 1);
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
@@ -60,8 +61,7 @@ document.onkeypress = event => {
 | 
				
			|||||||
        // Next Image
 | 
					        // Next Image
 | 
				
			||||||
        case ' ':
 | 
					        case ' ':
 | 
				
			||||||
        case 's':
 | 
					        case 's':
 | 
				
			||||||
			document.getElementById("dest").style.height = "100%";
 | 
						    scrollBy(0, 40);
 | 
				
			||||||
			document.getElementById("list").style.height = "100%";
 | 
					 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        case 'd':
 | 
					        case 'd':
 | 
				
			||||||
            changePage(currentPage + 1);
 | 
					            changePage(currentPage + 1);
 | 
				
			||||||
@@ -74,8 +74,12 @@ document.onkeydown = event =>{
 | 
				
			|||||||
        case 37: //left
 | 
					        case 37: //left
 | 
				
			||||||
            changePage(currentPage - 1);
 | 
					            changePage(currentPage - 1);
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
 | 
					        case 38: //up
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
        case 39: //right
 | 
					        case 39: //right
 | 
				
			||||||
            changePage(currentPage + 1);
 | 
					            changePage(currentPage + 1);
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
 | 
					        case 40: //down
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
@@ -1,3 +1,4 @@
 | 
				
			|||||||
 | 
					  
 | 
				
			||||||
*, *::after, *::before {
 | 
					*, *::after, *::before {
 | 
				
			||||||
    box-sizing: border-box;
 | 
					    box-sizing: border-box;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -17,8 +18,8 @@ html, body {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#list {
 | 
					#list {
 | 
				
			||||||
    height: 100%;
 | 
					    height: 2000px;
 | 
				
			||||||
    overflow: auto;
 | 
					    overflow: scroll;
 | 
				
			||||||
    width: 260px;
 | 
					    width: 260px;
 | 
				
			||||||
    text-align: center;
 | 
					    text-align: center;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -37,8 +38,8 @@ html, body {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#image-container {
 | 
					#image-container {
 | 
				
			||||||
    flex: auto;
 | 
					    flex: auto;
 | 
				
			||||||
    height: 100vh;
 | 
					    height: 2000px;
 | 
				
			||||||
    background: #000;
 | 
					    background: #222;
 | 
				
			||||||
    color: #fff;
 | 
					    color: #fff;
 | 
				
			||||||
    text-align: center;
 | 
					    text-align: center;
 | 
				
			||||||
    cursor: pointer;
 | 
					    cursor: pointer;
 | 
				
			||||||
@@ -48,17 +49,16 @@ html, body {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#image-container #dest {
 | 
					#image-container #dest {
 | 
				
			||||||
    background: #000;
 | 
					    height: 2000px;
 | 
				
			||||||
    height: 100%;
 | 
					 | 
				
			||||||
    width: 100%;
 | 
					    width: 100%;
 | 
				
			||||||
    background-size: contain;
 | 
					    background-size: contain;
 | 
				
			||||||
    background-repeat: no-repeat;
 | 
					    background-repeat: no-repeat;
 | 
				
			||||||
    background-position: center;
 | 
					    background-position: top;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#image-container #page-num {
 | 
					#image-container #page-num {
 | 
				
			||||||
    position: absolute;
 | 
					    position: static;
 | 
				
			||||||
    font-size: 18pt;
 | 
					    font-size: 14pt;
 | 
				
			||||||
    left: 10px;
 | 
					    left: 10px;
 | 
				
			||||||
    bottom: 5px;
 | 
					    bottom: 5px;
 | 
				
			||||||
    font-weight: bold;
 | 
					    font-weight: bold;
 | 
				
			||||||
@@ -68,25 +68,3 @@ html, body {
 | 
				
			|||||||
        0 0 2px #222,
 | 
					        0 0 2px #222,
 | 
				
			||||||
        0 0 2px #222;
 | 
					        0 0 2px #222;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
@media only screen and (max-width: 855px) {
 | 
					 | 
				
			||||||
    nav {
 | 
					 | 
				
			||||||
        display: none;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@media only screen and (max-device-width: 855px) {
 | 
					 | 
				
			||||||
    nav {
 | 
					 | 
				
			||||||
        display: none;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
div {
 | 
					 | 
				
			||||||
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
:focus {
 | 
					 | 
				
			||||||
    outline: 0;
 | 
					 | 
				
			||||||
    border:none;
 | 
					 | 
				
			||||||
    color: rgba(0, 0, 0, 0);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
		Reference in New Issue
	
	Block a user