Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
reruin committed Sep 16, 2019
1 parent b92bac8 commit 166ec01
Show file tree
Hide file tree
Showing 16 changed files with 32 additions and 18 deletions.
1 change: 1 addition & 0 deletions example/google_drive.d.ln
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gd:1cEA4umECe_-7aqBvq44AiPYxQ95zP8jr
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions plugins/drive.gd.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ module.exports = ({ request, cache, getConfig, querystring, base64, saveDrive, g
ext: data.ext,
protocol: defaultProtocol,
proxy: true,
size:data.size,
// outputType: stream,
headers: {
'Authorization': `Bearer ${credentials.access_token}`,
Expand Down
2 changes: 1 addition & 1 deletion plugins/drive.gd.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ module.exports = ({ request , getConfig , datetime , cache }) => {
/**
* 获取文件实际路径
*/
const file = async(id , { data = {} }) =>{
const file = async(id , { data = {} } = {}) =>{
if(
data &&
data.$cached_at &&
Expand Down
3 changes: 1 addition & 2 deletions plugins/drive.github.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ module.exports = ({ request , getConfig, base64 , getRuntime}) => {
return resp
}

const file = async (id , data = {}) => {
console.log(data)
const file = async (id , { data = {} } = {}) => {
if( data && data.download_url ){
data.url = data.download_url
}else{
Expand Down
2 changes: 1 addition & 1 deletion plugins/drive.h5ai.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ module.exports = ({ request , getConfig, cache, base64 , retrieveSize }) => {
return resp
}

const file = async (id , data = {}) => {
const file = async (id , { data = {} } = {}) => {

data.url = id
// data.outputType = 'stream'
Expand Down
16 changes: 10 additions & 6 deletions plugins/drive.lanzou.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ module.exports = ({ request , getConfig , datetime , cache , retrieveSize }) =>
let children = []
res.body.text.forEach( i => {
let name = filterExt(i.name_all)//.replace(/\.ct$/,'')
console.log(i)

children.push(updateFile({
id:i.id,
Expand Down Expand Up @@ -144,22 +143,27 @@ module.exports = ({ request , getConfig , datetime , cache , retrieveSize }) =>
/**
* 获取文件实际路径
*/
const file = async(id , data = {}) =>{
const file = async(id , { data = {} } = {}) =>{

let { body } = await request.get(`${host}/tp/${id}` , {headers:{'User-Agent':'Mozilla/5.0 (Linux; Android 6.0; 1503-M02 Build/MRA58K) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/37.0.0.0 Mobile MQQBrowser/6.2 TBS/036558 Safari/537.36 MicroMessenger/6.3.25.861 NetType/WIFI Language/zh_CN'}})
let url , base

url = (body.match(/(?<=link[^\=]*=\s*')[^']+/) || [false])[0]
base = (body.match(/(?<=urlp[^\=]*=\s*')[^']+/)|| [false])[0]
let url = (body.match(/(?<=dpost\s*\+\s*["']\?)[^"']+/) || [false])[0]
let base = (body.match(/(?<=urlp[^\=]*=\s*')[^']+/)|| [false])[0]

if(url == false){
url = (body.match(/(?<=urlp[^\"\']*[\"\']\s*)\?[^'"]+/)|| [false])[0]
if( url == false){
return false
}
}
url = base + url
let name = (body.match(/(?<="md">)[^<]+/) || [''])[0].replace(/\s*$/,'')

url = base + '?' + url
data.url = url
data.name = filterExt(name)
data.$cached_at = Date.now()

// console.log(data)
// cache.save()
return data
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/drive.od.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ module.exports = ({ request, cache, getConfig, querystring, base64 , saveDrive ,

}

const file = async (id , data = {}) => {
const file = async (id , { data = {} } = {}) => {
//data.url = data.downloadUrl
// console.log(id , data)
if(
Expand Down
2 changes: 1 addition & 1 deletion plugins/drive.od.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ module.exports = ({ request , cache , getConfig , querystring}) => {
return resp
}

const file = async (id, data) => {
const file = async (id, { data = {} } = {}) => {
if (
data &&
data.$cached_at &&
Expand Down
21 changes: 15 additions & 6 deletions plugins/drive.odb.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,19 @@ module.exports = ({ request, cache, getConfig }) => {
return [cookies[rootId]]
} else {
let res = await request.get(rootId, { followRedirect: false })
// let cookie = resp.headers['set-cookie'].join('; ')
let accessUrl = res.headers.location
let cookie = ''
if(res.headers && res.headers['set-cookie']){
cookie = res.headers['set-cookie'].join('; ')

res = await request.get(accessUrl, { followRedirect: false })
cookies[rootId] = cookie

let cookie = res.headers['set-cookie'].join('; ')
return [cookie, res.headers.location]
}
let accessUrl = res.headers.location

res = await request.get(accessUrl, { headers:{cookie}, followRedirect: false })
console.log( res.headers )
cookie = res.headers['set-cookie'].join('; ')

cookies[rootId] = cookie

Expand Down Expand Up @@ -70,9 +77,11 @@ module.exports = ({ request, cache, getConfig }) => {
let url = baseUrl + encodeURI(path)

if (directUrl) {
url = baseUrl + directUrl
url = baseUrl + directUrl.replace(baseUrl,'')
}

console.log('>>>url',url)

let res = await request.get(url, { headers: { 'Cookie': cookie } })
let code = (res.body.match(/g_listData\s*=\s*([\w\W]+)(?=;if)/) || ['', ''])[1]
let data = code.toString(16)
Expand Down Expand Up @@ -112,7 +121,7 @@ module.exports = ({ request, cache, getConfig }) => {
/**
* 必须使用cookie才能下载,故此只能使用中转模式
*/
const file = async (id, data) => {
const file = async (id, { data = {} } = {}) => {

const [rootId, path] = parse(id)
const [cookie, _] = await getCookie(rootId)
Expand Down

0 comments on commit 166ec01

Please sign in to comment.