add/update some sites (#154)

* add some sites
---------

Co-authored-by: hxsf <i@hxsf.me>
Co-authored-by: CzBiX <CzBiX@users.noreply.github.com>
This commit is contained in:
IITII
2023-04-16 21:46:46 +08:00
committed by GitHub
parent 083b896056
commit a28c31ef1f
21 changed files with 186 additions and 9 deletions

View File

@@ -0,0 +1,74 @@
/* eslint-disable no-console */
import path from 'path'
import fs from 'fs/promises'
import { execSync } from 'child_process'
const ICON_DIR = 'src/assets/site_icons'
const ICON_SIZE = 48
function execShell(command) {
const output = execSync(command)
return output.toString().trim()
}
function isIconFile(iconPath) {
const output = execShell(`file -b --mime-type ${iconPath}`)
return output.includes('image/vnd.microsoft.icon')
}
function getIconIndex(iconPath) {
const output = execShell(`magick identify -format "%s:%w\\n" ${iconPath}`)
let lastIndex = 0
for (const line of output.split('\n')) {
const [index, width] = line.split(':')
const size = parseInt(width)
if (size >= ICON_SIZE) {
return index
}
lastIndex = index
}
return lastIndex
}
function convertIcon(iconPath, outputPath) {
const iconIndex = getIconIndex(iconPath)
execShell(`magick convert -thumbnail "${ICON_SIZE}x${ICON_SIZE}>" ${iconPath}[${iconIndex}] ${outputPath}`)
}
async function fixSiteIcon(name) {
const iconPath = path.join(ICON_DIR, name)
if (!isIconFile(iconPath)) {
return
}
const tmpPath = path.join(ICON_DIR, '_tmp.ico')
await fs.copyFile(iconPath, tmpPath)
try {
convertIcon(tmpPath, iconPath)
} finally {
await fs.unlink(tmpPath)
}
console.log(`Converted ${name}`)
}
async function main() {
let files = []
if (process.argv.length > 2) {
files = process.argv.slice(2)
} else {
files = await fs.readdir(ICON_DIR)
}
files = files.filter(name => {
return name.endsWith('.png')
})
for (const name of files) {
await fixSiteIcon(name)
}
}
main()

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 138 B

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 818 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1010 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 742 B

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@@ -60,7 +60,7 @@
</template>
<script lang="ts">
import { sortBy, sumBy, defaultTo, isUndefined } from 'lodash';
import { sortBy, sumBy, isUndefined } from 'lodash';
import Vue from 'vue';
import { mapGetters } from 'vuex';
@@ -132,6 +132,14 @@ interface MenuChildrenItem extends MenuItem {
append?: string;
}
function getTopDomain(host: string) {
const parts = host.split('.');
if (parts.length > 2) {
return parts.slice(-2).join('.');
}
return host;
}
@Component({
components: {
FilterGroup,
@@ -239,9 +247,10 @@ export default class Drawer extends Vue {
buildSiteGroup(): MenuChildrenItem[] {
return sortBy(Object.entries(this.torrentGroupBySite).map(([key, value]) => {
const size = formatSize(sumBy(value, 'size'));
const site = SiteMap[key];
const domain = getTopDomain(key);
const site = SiteMap[domain];
const title = `${site ? site.name : (key || tr('others'))} (${value.length})`;
const icon = defaultTo(site ? site.icon : null, 'mdi-server');
const icon = site?.icon ?? 'mdi-server';
const append = `[${size}]`;
return {
icon, title, key, append,

View File

@@ -4,16 +4,16 @@ function getSiteIcon(name: string): string {
export interface SiteInfo {
name: string;
icon: string;
icon?: string;
}
const sites: {[key: string]: SiteInfo} = {
'tracker.m-team.cc': {
'm-team.cc': {
name: 'M-Team',
icon: getSiteIcon('m-team'),
},
'tracker.keepfrds.com': {
name: 'FRDS',
'keepfrds.com': {
name: 'PT@KEEPFRDS',
icon: getSiteIcon('keepfrds'),
},
'springsunday.net': {
@@ -30,12 +30,106 @@ const sites: {[key: string]: SiteInfo} = {
},
'hdhome.org': {
name: 'HDHome',
icon: getSiteIcon('hdhome'),
icon: getSiteIcon('nexusphp'),
},
'u2.dmhy.org': {
'dmhy.org': {
name: 'U2',
icon: getSiteIcon('u2'),
},
'dmhy.best': {
name: 'U2',
icon: getSiteIcon('u2'),
},
'totheglory.im': {
name: 'TTG',
icon: getSiteIcon('totheglory'),
},
'oshen.win': {
name: 'OshenPT',
icon: getSiteIcon('nexusphp'),
},
'soulvoice.club': {
name: '铃音Club',
icon: getSiteIcon('soulvoice'),
},
'ourbits.club': {
name: 'OurBits',
icon: getSiteIcon('ourbits'),
},
'btschool.club': {
name: 'BTSCHOOL',
},
'ptsbao.club': {
name: '烧包',
icon: getSiteIcon('ptsbao'),
},
'pterclub.com': {
name: 'PTer',
icon: getSiteIcon('pterclub'),
},
'hdtime.org': {
name: 'HDTime',
icon: getSiteIcon('hdtime'),
},
'hddolby.com': {
name: 'HD Dolby',
},
'lemonhd.org': {
name: 'LemonHD',
icon: getSiteIcon('lemonhd'),
},
'hares.top': {
name: 'HaresClub',
icon: getSiteIcon('hares'),
},
'pthome.net': {
name: 'PTHOME',
icon: getSiteIcon('pthome'),
},
'hdsky.me': {
name: 'HDSky',
icon: getSiteIcon('hdsky'),
},
'hdfans.org': {
name: 'HDFans',
icon: getSiteIcon('nexusphp'),
},
'hdatmos.club': {
name: 'HDAtmos',
icon: getSiteIcon('nexusphp'),
},
'hdzone.me': {
name: 'HDZone',
icon: getSiteIcon('nexusphp'),
},
'open.cd': {
name: 'OpenCD',
icon: getSiteIcon('opencd'),
},
'1ptba.com': {
name: '1PTBar',
icon: getSiteIcon('nexusphp'),
},
'pttime.org': {
name: 'PTTime',
icon: getSiteIcon('pttime'),
},
'beitai.pt': {
name: '备胎',
icon: getSiteIcon('nexusphp'),
},
'kamept.com': {
name: 'kamept',
icon: getSiteIcon('kamept'),
},
'nicept.net': {
name: 'NicePT',
icon: getSiteIcon('nexusphp'),
},
'2xfree.org': {
name: '2xfree',
icon: getSiteIcon('2xfree'),
},
};
export default sites;