Buenas pitoloko: he buscado en la página directa de Mediafire y allí no aparece nada... no parece que haya ninguna API para hacerlo...
Es posible que se me haya pasado por alto, así que mira aquí:
http://support.mediafire.com/index.php?/Knowledgebase/List
Y, en concreto, he encontrado información sobre una API para descargar, pero no para subir...
http://support.mediafire.com/index.php?/Knowledgebase/Article/View/60/8/downloader-agent-api
Peero...
1.-Un script en bash: mírate el código
Lo he sacado de una página italiana. Dice que para usarlo, primero debes indicar el user y password de mediafire:
Y para usarlo, si el script es mfup.sh:
Otro bash que he encontrado (el plowshare):
Y he probado el Uniupload y es verdad, no funciona.
Ahora supongo que debes estar pensando:
Primero: he dicho que ya he visto el plowshare!!! y Segundo: quiero un binario!
Pues sí, tienes toda la razón:
He encontrado una herramienta llamada SHC Compiler, y parece que es la única forma de hacerlo:
http://www.rootninja.com/shc-compiler-to-compile-bash-shell-scripts-into-binary/
Según esto:
En un entorno *NIX...
y para compilar...
He buscado en foros ingleses, italianos e incluso alemanes... y en algunos pone que no funciona si no ofuscas el source, que necesitas gcc-compiler...
Siento que no pueda hacer más por ti, porque no tengo conocimientos suficientes y además no puedo probarlo porque mi laptop con Ubuntu está escacharrada...
Mírate lo del SHC, a ver si te sirve.
PD:Llevo desde las 23:15 buscando...
Saludos!
Waaya
EDIT: He estado buscando algún script en Python y he encontrado uno que puedes subir archivos en FTP. El problema es que desde la página oficial dicen que no se puede, por el momento, subir archivos a Mediafire desde FTP (lo que creo que podrías hacer incluso con un batch).
Parece que para subir por FTP a Mediafire deberás buscarte algo para pasar el rato , porque creo que va a tardar...
Es posible que se me haya pasado por alto, así que mira aquí:
http://support.mediafire.com/index.php?/Knowledgebase/List
Y, en concreto, he encontrado información sobre una API para descargar, pero no para subir...
http://support.mediafire.com/index.php?/Knowledgebase/Article/View/60/8/downloader-agent-api
Peero...
1.-Un script en bash: mírate el código
Código (bash) [Seleccionar]
#!/bin/bash
#
# Copyright (c) 2011 vittorio benintende
# (vittorio@lucullo.it - http://www.morzello.com).
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# 3. Neither the name of the Site nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE SITE AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE SITE OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
#
# --- PARAMS ---
#
# login and password must be url-encoded!
#
MF_LOGIN='mediafire%40morzello.com'
MF_PWD='mypass'
# --- PARAMS ---
#
# DO NOT MODIFY LINES BELOW
#
MF_FILES="$@"
if [ "z${MF_FILES}" = "z" ]; then
echo
echo "No file(s) specified."
echo
echo "USAGE: $0 : file1 file2 ..."
echo
exit 1
fi
OUTPUT_FILE=$(mktemp)
COOKIE_FILE=$(mktemp)
rdom () { local IFS=\> ; read -d \< E C ;}
wget -q --save-cookies ${COOKIE_FILE} --keep-session-cookies -O /dev/null "https://www.mediafire.com/"
wget -q --load-cookies ${COOKIE_FILE} --save-cookies ${COOKIE_FILE} --keep-session-cookies --referer="https://www.mediafire.com/" \
--post-data "login_email=${MF_LOGIN}&login_pass=${MF_PWD}&login_remember=on&submit_login.x=97&submit_login.y=18" \
-O /dev/null "https://www.mediafire.com/dynamic/login.php"
wget -q --load-cookies ${COOKIE_FILE} --save-cookies ${COOKIE_FILE} --keep-session-cookies --referer="https://www.mediafire.com/myfiles.php" \
-O ${OUTPUT_FILE} "https://www.mediafire.com//basicapi/uploaderconfiguration.php?45144"
UPLOAD_SESSION=$(while rdom; do
if [[ ${E} = "upload_session" ]]; then
echo ${C}
exit
fi
done < ${OUTPUT_FILE})
# echo "Upload Session = ${UPLOAD_SESSION}"
UKEY=$(while rdom; do
if [[ ${E} = "ukey" ]]; then
echo ${C}
exit
fi
done < ${OUTPUT_FILE})
# echo "UKey = ${UKEY}"
TRACKKEY=$(while rdom; do
if [[ ${E} = "trackkey" ]]; then
echo ${C}
exit
fi
done < ${OUTPUT_FILE})
# echo "Track Key = ${TRACKKEY}"
FOLDERKEY=$(while rdom; do
if [[ ${E} = "folderkey" ]]; then
echo ${C}
exit
fi
done < ${OUTPUT_FILE})
# echo "Folder Key = ${FOLDERKEY}"
MFULCONFIG=$(while rdom; do
if [[ ${E} = "MFULConfig" ]]; then
echo ${C}
exit
fi
done < ${OUTPUT_FILE})
# echo "MFUL Config = ${MFULCONFIG}"
MF_USER=$(while rdom; do
if [[ ${E} = "user" ]]; then
echo ${C}
exit
fi
done < ${OUTPUT_FILE})
# echo "User = ${MF_USER}"
for FILENAME in ${MF_FILES}; do
SHORT_FILENAME=$(basename "${FILENAME}")
FILESIZE=$(stat -c%s "${FILENAME}")
wget -q --load-cookies ${COOKIE_FILE} --save-cookies ${COOKIE_FILE} --keep-session-cookies --referer="https://www.mediafire.com/myfile.php" \
--header="Content-Type: application/octet-stream" \
--header="X-Filename: ${SHORT_FILENAME}" \
--header="X-Filesize: ${FILESIZE}" \
--post-file="${FILENAME}" \
-O ${OUTPUT_FILE} "https://www.mediafire.com/douploadtoapi/?type=basic&ukey=${UKEY}&user=${MF_USER}&uploadkey=${FOLDERKEY}&filenum=0&uploader=0&MFULConfig=${MFULCONFIG}"
RESKEY=$(while rdom; do
if [[ ${E} = "key" ]]; then
echo ${C}
exit
fi
done < ${OUTPUT_FILE})
# echo "${FILENAME} > ${RESKEY}"
# get result
RUN=1
while [ ${RUN} -eq 1 ]; do
wget -q --load-cookies ${COOKIE_FILE} --save-cookies ${COOKIE_FILE} --keep-session-cookies --referer="https://www.mediafire.com/myfile.php" \
-O ${OUTPUT_FILE} "https://www.mediafire.com/basicapi/pollupload.php?key=${RESKEY}&MFULConfig=${MFULCONFIG}"
QUICKKEY=$(while rdom; do
if [[ ${E} = "quickkey" ]]; then
echo ${C}
exit
fi
done < ${OUTPUT_FILE})
FILEERROR=$(while rdom; do
if [[ ${E} = "fileerror" ]]; then
echo ${C}
exit
fi
done < ${OUTPUT_FILE})
# echo "${QUICKKEY} ; ${FILEERROR}"
RUN=0
if [ "z${FILEERROR}" = "z" ] && [ "z${QUICKKEY}" = "z" ]; then
RUN=1
fi
#
#..
#...
#... File too large. 1 0
#... File too small. 2 0
#... Archive is bad. 3 0
#... Archive is bad or password protected. 4 0
#... Virus found. 5 0
#... File already uploaded. 13 0
#... Archive has an unknown problem. 9 0
#... Invalid image. 10 0
#... File lost. 6 1
#... Error scanning file. 7 1
#... Disk error. 8,11 1
#... Database error. 12 1
#..
#
case "${FILEERROR}" in
1) FILEERROR=" 1 : File too large."
;;
2) FILEERROR=" 2 : File too small."
;;
3) FILEERROR=" 3 : Archive is bad."
;;
4) FILEERROR=" 4 : Archive is bad or password protected."
;;
5) FILEERROR=" 5 : Virus found."
;;
13) FILEERROR="13 : File already uploaded."
;;
9) FILEERROR=" 9 : Archive has an unknown problem."
;;
10) FILEERROR="10 : Invalid image."
;;
6) FILEERROR=" 6 : File lost."
;;
7) FILEERROR=" 7 : Error scanning file."
;;
FILEERROR=" 8 : Disk error."
;;
11) FILEERROR="11 : Disk error."
;;
12) FILEERROR="12 : Database error."
;;
*) FILEERROR="0 : Success."
;;
esac
done
echo "${FILEERROR} | ${FILENAME} > ${QUICKKEY}"
done
rm ${OUTPUT_FILE}
rm ${COOKIE_FILE}
Lo he sacado de una página italiana. Dice que para usarlo, primero debes indicar el user y password de mediafire:
Código [Seleccionar]
mediafire@morzello.com -> mediafire%40morzello.com
Y para usarlo, si el script es mfup.sh:
Código (bash) [Seleccionar]
./mfup.sh myfile.txt all.* /root/repo/*
Otro bash que he encontrado (el plowshare):
Código (bash) [Seleccionar]
#!/bin/bash
#
# mediafire.com module
# Copyright (c) 2010 - 2011 Plowshare team
#
# This file is part of Plowshare.
#
# Plowshare is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Plowshare is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Plowshare. If not, see <http://www.gnu.org/licenses/>.
MODULE_MEDIAFIRE_REGEXP_URL="http://\(www\.\)\?mediafire\.com/"
MODULE_MEDIAFIRE_DOWNLOAD_OPTIONS=""
MODULE_MEDIAFIRE_UPLOAD_OPTIONS=""
MODULE_MEDIAFIRE_LIST_OPTIONS=""
MODULE_MEDIAFIRE_DOWNLOAD_CONTINUE=no
# Output a mediafire file download URL
# $1: MEDIAFIRE_URL
# stdout: real file download link
mediafire_download() {
set -e
eval "$(process_options mediafire "$MODULE_MEDIAFIRE_DOWNLOAD_OPTIONS" "$@")"
URL=$1
LOCATION=$(curl --head "$URL" | grep_http_header_location)
if match '^http://download' "$LOCATION"; then
log_notice "direct download"
echo "$LOCATION"
return 0
elif match 'errno=999$' "$LOCATION"; then
log_error "private link"
return 254
elif match 'errno=' "$LOCATION"; then
log_error "site redirected with an unknown error"
return 1
fi
COOKIESFILE=$(create_tempfile)
PAGE=$(curl -L -c $COOKIESFILE "$URL" | sed "s/>/>\n/g")
COOKIES=$(< $COOKIESFILE)
rm -f $COOKIESFILE
test "$PAGE" || return 1
if matchi 'Invalid or Deleted File' "$PAGE"; then
log_debug "invalid or deleted file"
return 254
fi
if test "$CHECK_LINK"; then
match 'class="download_file_title"' "$PAGE" && return 255 || return 1
fi
FILE_URL=$(get_ofuscated_link "$PAGE" "$COOKIES") ||
{ log_error "error running javascript code"; return 1; }
echo "$FILE_URL"
}
get_ofuscated_link() {
local PAGE=$1
local COOKIES=$2
BASE_URL="http://www.mediafire.com"
detect_javascript >/dev/null || return 1
# Carriage-return in eval is not accepted by Spidermonkey, that's what the sed fixes
PAGE_JS=$(echo "$PAGE" | sed -n '/<input id="pagename"/,/<\/script>/p' |
grep "var PageLoaded" | head -n1 | sed "s/var cb=Math.random().*$/}/") ||
{ log_error "cannot find main javascript code"; return 1; }
FUNCTION=$(echo "$PAGE" | parse 'DoShow("notloggedin_wrapper")' \
"cR();[[:space:]]*\([[:alnum:]]\+\)();") ||
{ log_error "cannot find start function"; return 1; }
log_debug "JS function: $FUNCTION"
{ read DIVID; read DYNAMIC_PATH; } < <(echo "
noop = function() { }
// Functions and variables used but defined elsewhere, fake them.
DoShow = Eo = aa = noop;
fu = StartDownloadTried = pk = 0;
// setTimeout() is being used to 'hide' function calls.
function setTimeout(func, time) {
func();
}
// Record accesses to the DOM
namespace = {};
var document = {
getElementById: function(id) {
if (!namespace[id])
namespace[id] = {style: ''}
return namespace[id];
},
};
$PAGE_JS
$FUNCTION();
// DIV id is string of hexadecimal values of length 32
for (key in namespace) {
if (key.length == 32)
print(key);
}
print(namespace.workframe2.src);
" | javascript) ||
{ log_error "error running javascript in main page"; return 1; }
log_debug "DIV id: $DIVID"
log_debug "Dynamic page: $DYNAMIC_PATH"
DYNAMIC=$(curl -b <(echo "$COOKIES") "$BASE_URL/$DYNAMIC_PATH")
DYNAMIC_JS=$(echo "$DYNAMIC" | sed -n "/<script/,/<\/script>/p" | sed -e '1d;$d')
FILE_URL=$(echo "
function alert(x) {print(x); }
var namespace = {};
var parent = {
document: {
getElementById: function(id) {
namespace[id] = {};
return namespace[id];
},
},
aa: function(x, y) { print (x,y);},
};
$DYNAMIC_JS
dz();
print(namespace['$DIVID'].innerHTML);
" | javascript | parse_attr "href") ||
{ log_error "error running javascript in download page"; return 1; }
echo $FILE_URL
}
# List a mediafire shared file folder URL
# $1: MEDIAFIRE_URL (http://www.mediafire.com/?sharekey=...)
# stdout: list of links
mediafire_list() {
set -e
eval "$(process_options mediafire "$MODULE_MEDIAFIRE_LIST_OPTIONS" "$@")"
URL=$1
PAGE=$(curl "$URL" | sed "s/>/>\n/g")
match '/js/myfiles.php/' "$PAGE" ||
{ log_error "not a shared folder"; return 1; }
local JS_URL=$(echo "$PAGE" | parse 'LoadJS(' '("\(\/js\/myfiles\.php\/[^"]*\)')
local DATA=$(curl "http://mediafire.com$JS_URL" | sed "s/\([)']\);/\1;\n/g")
# get number of files
NB=$(echo "$DATA" | parse '^var oO' "'\([[:digit:]]*\)'")
log_debug "There is $NB file(s) in the folder"
# First pass : print debug message & links (stdout)
# es[0]=Array('1','1',3,'te9rlz5ntf1','82de6544620807bf025c12bec1713a48','my_super_file.txt','14958589','14.27','MB','43','02/13/2010', ...
while [[ "$NB" -gt 0 ]]; do
((NB--))
LINE=$(echo "$DATA" | parse "es\[$NB\]=" "Array(\(.*\));")
FID=$(echo "$LINE" | cut -d, -f4 | tr -d "'")
FILENAME=$(echo "$LINE" | cut -d, -f6 | tr -d "'")
log_debug "$FILENAME"
echo "http://www.mediafire.com/?$FID"
done
return 0
}
# mediafire_upload FILE [DESTFILE]
#
# stdout: mediafire download link
mediafire_upload() {
eval "$(process_options mediafire "$MODULE_MEDIAFIRE_UPLOAD_OPTIONS" "$@")"
local FILE=$1
local DESTFILE=${2:-$FILE}
local BASE_URL="http://www.mediafire.com"
local COOKIESFILE=$(create_tempfile)
local PAGEFILE=$(create_tempfile)
log_debug "Get ukey cookie"
curl -c $COOKIESFILE "$BASE_URL" >/dev/null ||
{ log_error "Couldn't get homepage!"; rm -f $COOKIESFILE $PAGEFILE; return 1; }
log_debug "Get uploader configuration"
curl -b $COOKIESFILE "$BASE_URL/basicapi/uploaderconfiguration.php" > $PAGEFILE ||
{ log_error "Couldn't get uploader configuration!"; rm -f $COOKIESFILE $PAGEFILE; return 1; }
local UKEY=$(parse_quiet ukey '.*ukey[ \t]*\(.*\)' < $COOKIESFILE)
local TRACK_KEY=$(parse_quiet trackkey '.*<trackkey>\(.*\)<\/trackkey>.*' < $PAGEFILE)
local FOLDER_KEY=$(parse_quiet folderkey '.*<folderkey>\(.*\)<\/folderkey>.*' < $PAGEFILE)
local MFUL_CONFIG=$(parse_quiet MFULConfig '.*<MFULConfig>\(.*\)<\/MFULConfig>.*' < $PAGEFILE)
log_debug "trackkey: $TRACK_KEY"
log_debug "folderkey: $FOLDER_KEY"
log_debug "ukey: $UKEY"
log_debug "MFULConfig: $MFUL_CONFIG"
if [ -z "$UKEY" -o -z "$TRACK_KEY" -o -z "$FOLDER_KEY" -o -z "$MFUL_CONFIG" ]; then
log_error "Can't parse uploader configuration!"
rm -f $COOKIESFILE $PAGEFILE
return 1
fi
log_debug "Uploading file"
local UPLOAD_URL="$BASE_URL/basicapi/doupload.php?track=$TRACK_KEY&ukey=$UKEY&user=x&uploadkey=$FOLDER_KEY&upload=0"
curl_with_log -b $COOKIESFILE \
-F "Filename=$(basename_file "$DESTFILE")" \
-F "Upload=Submit Query" \
-F "Filedata=@$FILE;filename=$(basename_file "$DESTFILE")" \
$UPLOAD_URL > $PAGEFILE ||
{ log_error "Couldn't upload file!"; rm -f $COOKIESFILE $PAGEFILE; return 1; }
local UPLOAD_KEY=$(parse_quiet key '.*<key>\(.*\)<\/key>.*' < $PAGEFILE)
log_debug "key: $UPLOAD_KEY"
if [ -z "$UPLOAD_KEY" ]; then
log_error "Can't get upload key!"
rm -f $COOKIESFILE $PAGEFILE
return 1
fi
local COUNTER=0
while [ -z "$(grep 'No more requests for this key' $PAGEFILE)" ]; do
if [[ $COUNTER -gt 50 ]]; then
log_error "File verification timeout!"
rm -f $COOKIESFILE $PAGEFILE
return 1
fi
log_debug "Polling for status update"
curl -b $COOKIESFILE "$BASE_URL/basicapi/pollupload.php?key=$UPLOAD_KEY&MFULConfig=$MFUL_CONFIG" > $PAGEFILE
sleep 1
let COUNTER++
done
local QUICK_KEY=$(parse_quiet quickkey '.*<quickkey>\(.*\)<\/quickkey>.*' < $PAGEFILE)
log_debug "quickkey: $QUICK_KEY"
if [ -z "$QUICK_KEY" ]; then
log_error "Can't get quick key!"
rm -f $COOKIESFILE $PAGEFILE
return 1
fi
rm -f $COOKIESFILE $PAGEFILE
echo "$BASE_URL/?$QUICK_KEY"
}
Y he probado el Uniupload y es verdad, no funciona.
Ahora supongo que debes estar pensando:
Primero: he dicho que ya he visto el plowshare!!! y Segundo: quiero un binario!
Pues sí, tienes toda la razón:
He encontrado una herramienta llamada SHC Compiler, y parece que es la única forma de hacerlo:
http://www.rootninja.com/shc-compiler-to-compile-bash-shell-scripts-into-binary/
Según esto:
En un entorno *NIX...
Código (bash) [Seleccionar]
make
make install
install -c /usr/local/bin -s shc /usr/local/bin
install -c /usr/local/man/man1 -s shc.1 /usr/local/man/man1
y para compilar...
Código (bash) [Seleccionar]
shc -v -r -T -f filename.sh
He buscado en foros ingleses, italianos e incluso alemanes... y en algunos pone que no funciona si no ofuscas el source, que necesitas gcc-compiler...
Siento que no pueda hacer más por ti, porque no tengo conocimientos suficientes y además no puedo probarlo porque mi laptop con Ubuntu está escacharrada...
Mírate lo del SHC, a ver si te sirve.
PD:Llevo desde las 23:15 buscando...
Saludos!
Waaya
EDIT: He estado buscando algún script en Python y he encontrado uno que puedes subir archivos en FTP. El problema es que desde la página oficial dicen que no se puede, por el momento, subir archivos a Mediafire desde FTP (lo que creo que podrías hacer incluso con un batch).
Parece que para subir por FTP a Mediafire deberás buscarte algo para pasar el rato , porque creo que va a tardar...