@@ -4,6 +4,11 @@ const { parseDate } = require('@/utils/parse-date');
44const { art } = require ( '@/utils/render' ) ;
55const path = require ( 'path' ) ;
66
7+ const toSize = ( raw ) => {
8+ const matches = raw . match ( / ( \d + ( \. \d + ) ? ) ( \w + ) / ) ;
9+ return matches [ 3 ] === 'GB' ? matches [ 1 ] * 1024 : matches [ 1 ] ;
10+ } ;
11+
712module . exports = async ( ctx ) => {
813 const isWestern = / ^ \/ w e s t e r n / . test ( ctx . path ) ;
914
@@ -19,7 +24,7 @@ module.exports = async (ctx) => {
1924 const $ = cheerio . load ( response . data ) ;
2025
2126 let items = $ ( '.movie-box' )
22- . slice ( 0 , ctx . query . limit ? parseInt ( ctx . query . limit ) : 30 )
27+ . slice ( 0 , ctx . query . limit ? parseInt ( ctx . query . limit ) : 50 )
2328 . toArray ( )
2429 . map ( ( item ) => {
2530 item = $ ( item ) ;
@@ -98,11 +103,12 @@ module.exports = async (ctx) => {
98103 link : td . first ( ) . attr ( 'href' ) ,
99104 size : td . eq ( 1 ) . text ( ) . trim ( ) ,
100105 date : td . last ( ) . text ( ) . trim ( ) ,
106+ score : content ( tr ) . find ( 'a' ) . length ** 8 * toSize ( td . eq ( 1 ) . text ( ) . trim ( ) ) ,
101107 } ;
102108 } ) ;
103109
104110 if ( magnets ) {
105- item . enclosure_url = magnets [ 0 ] . link ;
111+ item . enclosure_url = magnets . sort ( ( a , b ) => b . score - a . score ) [ 0 ] . link ;
106112 item . enclosure_type = 'application/x-bittorrent' ;
107113 }
108114 } catch ( e ) {
0 commit comments