From acc46fc3497a66a427b795b4a22c6e71d69185a1 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 13 Dec 2014 15:56:57 +0100 Subject: Update --- .gitignore | 1 - docs/build_docs.py | 18 +- docs/docs.conf | 2 +- docs/module_overview.rst | 12 +- docs/setup.cfg | 7 + docs/write_addons.rst | 32 +- docs/write_plugins.rst | 18 +- locale/core.pot | 228 +++--- locale/pavement.py | 415 +++++++++++ pavement.py | 415 ----------- pyload/Core.py | 16 +- pyload/__init__.py | 31 +- pyload/api/__init__.py | 2 +- pyload/database/File.py | 875 +++++++++++++++++++++++ pyload/database/FileDatabase.py | 875 ----------------------- pyload/database/Storage.py | 34 + pyload/database/StorageDatabase.py | 34 - pyload/database/User.py | 93 +++ pyload/database/UserDatabase.py | 93 --- pyload/database/__init__.py | 6 +- pyload/datatype/File.py | 270 +++++++ pyload/datatype/Package.py | 64 ++ pyload/datatype/PyFile.py | 270 ------- pyload/datatype/PyPackage.py | 64 -- pyload/manager/Account.py | 191 +++++ pyload/manager/AccountManager.py | 191 ----- pyload/manager/Addon.py | 304 ++++++++ pyload/manager/AddonManager.py | 304 -------- pyload/manager/Captcha.py | 138 ++++ pyload/manager/CaptchaManager.py | 138 ---- pyload/manager/Event.py | 104 +++ pyload/manager/Plugin.py | 404 +++++++++++ pyload/manager/PluginManager.py | 404 ----------- pyload/manager/Remote.py | 76 ++ pyload/manager/RemoteManager.py | 76 -- pyload/manager/Thread.py | 302 ++++++++ pyload/manager/ThreadManager.py | 302 -------- pyload/manager/event/PullEvents.py | 104 --- pyload/manager/thread/Addon.py | 69 ++ pyload/manager/thread/AddonThread.py | 69 -- pyload/manager/thread/Decrypter.py | 101 +++ pyload/manager/thread/DecrypterThread.py | 101 --- pyload/manager/thread/Download.py | 213 ++++++ pyload/manager/thread/DownloadThread.py | 213 ------ pyload/manager/thread/Info.py | 225 ++++++ pyload/manager/thread/InfoThread.py | 225 ------ pyload/manager/thread/Plugin.py | 130 ++++ pyload/manager/thread/PluginThread.py | 130 ---- pyload/manager/thread/Server.py | 111 +++ pyload/manager/thread/ServerThread.py | 111 --- pyload/network/HTTPDownload.py | 3 +- pyload/network/HTTPRequest.py | 2 +- pyload/network/XDCCRequest.py | 2 +- pyload/plugin/Account.py | 307 ++++++++ pyload/plugin/Addon.py | 185 +++++ pyload/plugin/Captcha.py | 51 ++ pyload/plugin/Container.py | 66 ++ pyload/plugin/Crypter.py | 107 +++ pyload/plugin/Hoster.py | 21 + pyload/plugin/OCR.py | 315 ++++++++ pyload/plugin/Plugin.py | 753 +++++++++++++++++++ pyload/plugin/__init__.py | 1 + pyload/plugin/account/AlldebridCom.py | 59 ++ pyload/plugin/account/BayfilesCom.py | 37 + pyload/plugin/account/BillionuploadsCom.py | 16 + pyload/plugin/account/BitshareCom.py | 32 + pyload/plugin/account/CatShareNet.py | 56 ++ pyload/plugin/account/CramitIn.py | 16 + pyload/plugin/account/CzshareCom.py | 44 ++ pyload/plugin/account/DebridItaliaCom.py | 44 ++ pyload/plugin/account/DepositfilesCom.py | 35 + pyload/plugin/account/DropboxCom.py | 42 ++ pyload/plugin/account/EasybytezCom.py | 19 + pyload/plugin/account/EuroshareEu.py | 41 ++ pyload/plugin/account/FastixRu.py | 38 + pyload/plugin/account/FastshareCz.py | 53 ++ pyload/plugin/account/File4safeCom.py | 18 + pyload/plugin/account/FileParadoxIn.py | 16 + pyload/plugin/account/FilecloudIo.py | 59 ++ pyload/plugin/account/FilefactoryCom.py | 49 ++ pyload/plugin/account/FilejungleCom.py | 49 ++ pyload/plugin/account/FileomCom.py | 16 + pyload/plugin/account/FilerNet.py | 50 ++ pyload/plugin/account/FilerioCom.py | 16 + pyload/plugin/account/FilesMailRu.py | 28 + pyload/plugin/account/FileserveCom.py | 44 ++ pyload/plugin/account/FourSharedCom.py | 33 + pyload/plugin/account/FreakshareCom.py | 43 ++ pyload/plugin/account/FreeWayMe.py | 55 ++ pyload/plugin/account/FshareVn.py | 63 ++ pyload/plugin/account/Ftp.py | 17 + pyload/plugin/account/HellshareCz.py | 76 ++ pyload/plugin/account/Http.py | 17 + pyload/plugin/account/HugefilesNet.py | 16 + pyload/plugin/account/HundredEightyUploadCom.py | 16 + pyload/plugin/account/JunocloudMe.py | 16 + pyload/plugin/account/Keep2shareCc.py | 69 ++ pyload/plugin/account/LetitbitNet.py | 34 + pyload/plugin/account/LinestorageCom.py | 16 + pyload/plugin/account/LinksnappyCom.py | 50 ++ pyload/plugin/account/LomafileCom.py | 16 + pyload/plugin/account/MegaDebridEu.py | 39 + pyload/plugin/account/MegaRapidCz.py | 59 ++ pyload/plugin/account/MegasharesCom.py | 48 ++ pyload/plugin/account/MovReelCom.py | 19 + pyload/plugin/account/MultishareCz.py | 44 ++ pyload/plugin/account/MyfastfileCom.py | 35 + pyload/plugin/account/NetloadIn.py | 40 ++ pyload/plugin/account/NosuploadCom.py | 16 + pyload/plugin/account/NovafileCom.py | 16 + pyload/plugin/account/NowVideoAt.py | 56 ++ pyload/plugin/account/OboomCom.py | 62 ++ pyload/plugin/account/OneFichierCom.py | 55 ++ pyload/plugin/account/OverLoadMe.py | 36 + pyload/plugin/account/PremiumTo.py | 34 + pyload/plugin/account/PremiumizeMe.py | 49 ++ pyload/plugin/account/QuickshareCz.py | 43 ++ pyload/plugin/account/RPNetBiz.py | 51 ++ pyload/plugin/account/RapidfileshareNet.py | 18 + pyload/plugin/account/RapidgatorNet.py | 58 ++ pyload/plugin/account/RapiduNet.py | 48 ++ pyload/plugin/account/RarefileNet.py | 16 + pyload/plugin/account/RealdebridCom.py | 36 + pyload/plugin/account/RehostTo.py | 41 ++ pyload/plugin/account/RyushareCom.py | 25 + pyload/plugin/account/SafesharingEu.py | 16 + pyload/plugin/account/SecureUploadEu.py | 16 + pyload/plugin/account/SendmywayCom.py | 16 + pyload/plugin/account/ShareonlineBiz.py | 45 ++ pyload/plugin/account/SimplyPremiumCom.py | 46 ++ pyload/plugin/account/SimplydebridCom.py | 34 + pyload/plugin/account/StahnuTo.py | 34 + pyload/plugin/account/StreamcloudEu.py | 16 + pyload/plugin/account/TurbobitNet.py | 42 ++ pyload/plugin/account/TusfilesNet.py | 23 + pyload/plugin/account/UlozTo.py | 52 ++ pyload/plugin/account/UnrestrictLi.py | 44 ++ pyload/plugin/account/UploadcCom.py | 16 + pyload/plugin/account/UploadedTo.py | 60 ++ pyload/plugin/account/UploadheroCom.py | 41 ++ pyload/plugin/account/UploadingCom.py | 63 ++ pyload/plugin/account/UptoboxCom.py | 17 + pyload/plugin/account/VidPlayNet.py | 16 + pyload/plugin/account/XFileSharingPro.py | 30 + pyload/plugin/account/YibaishiwuCom.py | 40 ++ pyload/plugin/account/ZeveraCom.py | 56 ++ pyload/plugin/account/__init__.py | 1 + pyload/plugin/addon/Checksum.py | 186 +++++ pyload/plugin/addon/ClickAndLoad.py | 74 ++ pyload/plugin/addon/DeleteFinished.py | 79 ++ pyload/plugin/addon/DownloadScheduler.py | 77 ++ pyload/plugin/addon/ExternalScripts.py | 145 ++++ pyload/plugin/addon/ExtractArchive.py | 363 ++++++++++ pyload/plugin/addon/HotFolder.py | 70 ++ pyload/plugin/addon/IRCInterface.py | 431 +++++++++++ pyload/plugin/addon/MergeFiles.py | 85 +++ pyload/plugin/addon/MultiHome.py | 81 +++ pyload/plugin/addon/RestartFailed.py | 45 ++ pyload/plugin/addon/RestartSlow.py | 57 ++ pyload/plugin/addon/SkipRev.py | 77 ++ pyload/plugin/addon/UnSkipOnFail.py | 87 +++ pyload/plugin/addon/UpdateManager.py | 305 ++++++++ pyload/plugin/addon/WindowsPhoneToastNotify.py | 57 ++ pyload/plugin/addon/XMPPInterface.py | 252 +++++++ pyload/plugin/addon/__init__.py | 1 + pyload/plugin/captcha/AdYouLike.py | 107 +++ pyload/plugin/captcha/AdsCaptcha.py | 77 ++ pyload/plugin/captcha/ReCaptcha.py | 73 ++ pyload/plugin/captcha/SolveMedia.py | 50 ++ pyload/plugin/captcha/__init__.py | 1 + pyload/plugin/container/CCF.py | 43 ++ pyload/plugin/container/LinkList.py | 71 ++ pyload/plugin/container/RSDF.py | 56 ++ pyload/plugin/container/__init__.py | 1 + pyload/plugin/crypter/BitshareCom.py | 21 + pyload/plugin/crypter/C1neonCom.py | 19 + pyload/plugin/crypter/ChipDe.py | 29 + pyload/plugin/crypter/CrockoCom.py | 20 + pyload/plugin/crypter/CryptItCom.py | 19 + pyload/plugin/crypter/CzshareCom.py | 32 + pyload/plugin/crypter/DDLMusicOrg.py | 51 ++ pyload/plugin/crypter/DailymotionBatch.py | 106 +++ pyload/plugin/crypter/DataHu.py | 40 ++ pyload/plugin/crypter/DdlstorageCom.py | 20 + pyload/plugin/crypter/DepositfilesCom.py | 20 + pyload/plugin/crypter/Dereferer.py | 26 + pyload/plugin/crypter/DevhostStFolder.py | 58 ++ pyload/plugin/crypter/DlProtectCom.py | 65 ++ pyload/plugin/crypter/DontKnowMe.py | 29 + pyload/plugin/crypter/DuckCryptInfo.py | 59 ++ pyload/plugin/crypter/DuploadOrg.py | 19 + pyload/plugin/crypter/EasybytezCom.py | 22 + pyload/plugin/crypter/EmbeduploadCom.py | 60 ++ pyload/plugin/crypter/FilebeerInfo.py | 19 + pyload/plugin/crypter/FilecloudIo.py | 21 + pyload/plugin/crypter/FilecryptCc.py | 148 ++++ pyload/plugin/crypter/FilefactoryCom.py | 28 + pyload/plugin/crypter/FilerNet.py | 26 + pyload/plugin/crypter/FileserveCom.py | 38 + pyload/plugin/crypter/FilesonicCom.py | 18 + pyload/plugin/crypter/FilestubeCom.py | 21 + pyload/plugin/crypter/FiletramCom.py | 22 + pyload/plugin/crypter/FiredriveCom.py | 19 + pyload/plugin/crypter/FourChanOrg.py | 27 + pyload/plugin/crypter/FreakhareCom.py | 38 + pyload/plugin/crypter/FreetexthostCom.py | 27 + pyload/plugin/crypter/FshareVn.py | 20 + pyload/plugin/crypter/Go4UpCom.py | 49 ++ pyload/plugin/crypter/GooGl.py | 32 + pyload/plugin/crypter/HoerbuchIn.py | 62 ++ pyload/plugin/crypter/HotfileCom.py | 19 + pyload/plugin/crypter/ILoadTo.py | 19 + pyload/plugin/crypter/ImgurComAlbum.py | 27 + pyload/plugin/crypter/JunocloudMe.py | 20 + pyload/plugin/crypter/LetitbitNet.py | 33 + pyload/plugin/crypter/LinkCryptWs.py | 327 +++++++++ pyload/plugin/crypter/LinkSaveIn.py | 246 +++++++ pyload/plugin/crypter/LinkdecrypterCom.py | 92 +++ pyload/plugin/crypter/LixIn.py | 62 ++ pyload/plugin/crypter/LofCc.py | 19 + pyload/plugin/crypter/MBLinkInfo.py | 20 + pyload/plugin/crypter/MediafireCom.py | 58 ++ pyload/plugin/crypter/MegaRapidCz.py | 20 + pyload/plugin/crypter/MegauploadCom.py | 18 + pyload/plugin/crypter/Movie2kTo.py | 19 + pyload/plugin/crypter/MultiUpOrg.py | 38 + pyload/plugin/crypter/MultiloadCz.py | 42 ++ pyload/plugin/crypter/MultiuploadCom.py | 18 + pyload/plugin/crypter/NCryptIn.py | 315 ++++++++ pyload/plugin/crypter/NetfolderIn.py | 70 ++ pyload/plugin/crypter/NosvideoCom.py | 21 + pyload/plugin/crypter/OneKhDe.py | 40 ++ pyload/plugin/crypter/OronCom.py | 19 + pyload/plugin/crypter/PastebinCom.py | 21 + pyload/plugin/crypter/QuickshareCz.py | 31 + pyload/plugin/crypter/RSLayerCom.py | 19 + pyload/plugin/crypter/RapidfileshareNet.py | 20 + pyload/plugin/crypter/RelinkUs.py | 293 ++++++++ pyload/plugin/crypter/SafelinkingNet.py | 79 ++ pyload/plugin/crypter/SecuredIn.py | 19 + pyload/plugin/crypter/SexuriaCom.py | 94 +++ pyload/plugin/crypter/ShareLinksBiz.py | 286 ++++++++ pyload/plugin/crypter/SharingmatrixCom.py | 18 + pyload/plugin/crypter/SpeedLoadOrg.py | 19 + pyload/plugin/crypter/StealthTo.py | 19 + pyload/plugin/crypter/TnyCz.py | 27 + pyload/plugin/crypter/TrailerzoneInfo.py | 19 + pyload/plugin/crypter/TurbobitNet.py | 44 ++ pyload/plugin/crypter/TusfilesNet.py | 45 ++ pyload/plugin/crypter/UlozTo.py | 46 ++ pyload/plugin/crypter/UploadableCh.py | 24 + pyload/plugin/crypter/UploadedTo.py | 34 + pyload/plugin/crypter/WiiReloadedOrg.py | 19 + pyload/plugin/crypter/WuploadCom.py | 18 + pyload/plugin/crypter/XFileSharingPro.py | 47 ++ pyload/plugin/crypter/XupPl.py | 25 + pyload/plugin/crypter/YoutubeBatch.py | 148 ++++ pyload/plugin/crypter/__init__.py | 1 + pyload/plugin/hook/AlldebridCom.py | 27 + pyload/plugin/hook/BypassCaptcha.py | 133 ++++ pyload/plugin/hook/Captcha9kw.py | 253 +++++++ pyload/plugin/hook/CaptchaBrotherhood.py | 166 +++++ pyload/plugin/hook/DeathByCaptcha.py | 213 ++++++ pyload/plugin/hook/DebridItaliaCom.py | 27 + pyload/plugin/hook/EasybytezCom.py | 39 + pyload/plugin/hook/ExpertDecoders.py | 92 +++ pyload/plugin/hook/FastixRu.py | 28 + pyload/plugin/hook/FreeWayMe.py | 25 + pyload/plugin/hook/ImageTyperz.py | 151 ++++ pyload/plugin/hook/LinkdecrypterCom.py | 60 ++ pyload/plugin/hook/LinksnappyCom.py | 27 + pyload/plugin/hook/MegaDebridEu.py | 30 + pyload/plugin/hook/MultishareCz.py | 27 + pyload/plugin/hook/MyfastfileCom.py | 30 + pyload/plugin/hook/OverLoadMe.py | 29 + pyload/plugin/hook/PremiumTo.py | 38 + pyload/plugin/hook/PremiumizeMe.py | 54 ++ pyload/plugin/hook/RPNetBiz.py | 52 ++ pyload/plugin/hook/RealdebridCom.py | 27 + pyload/plugin/hook/RehostTo.py | 41 ++ pyload/plugin/hook/SimplyPremiumCom.py | 29 + pyload/plugin/hook/SimplydebridCom.py | 22 + pyload/plugin/hook/UnrestrictLi.py | 30 + pyload/plugin/hook/XFileSharingPro.py | 96 +++ pyload/plugin/hook/ZeveraCom.py | 22 + pyload/plugin/hook/__init__.py | 1 + pyload/plugin/hoster/AlldebridCom.py | 87 +++ pyload/plugin/hoster/BayfilesCom.py | 87 +++ pyload/plugin/hoster/BezvadataCz.py | 94 +++ pyload/plugin/hoster/BillionuploadsCom.py | 24 + pyload/plugin/hoster/BitshareCom.py | 157 ++++ pyload/plugin/hoster/BoltsharingCom.py | 18 + pyload/plugin/hoster/CatShareNet.py | 67 ++ pyload/plugin/hoster/CloudzerNet.py | 20 + pyload/plugin/hoster/CramitIn.py | 24 + pyload/plugin/hoster/CrockoCom.py | 70 ++ pyload/plugin/hoster/CyberlockerCh.py | 18 + pyload/plugin/hoster/CzshareCom.py | 152 ++++ pyload/plugin/hoster/DailymotionCom.py | 125 ++++ pyload/plugin/hoster/DataHu.py | 42 ++ pyload/plugin/hoster/DataportCz.py | 55 ++ pyload/plugin/hoster/DateiTo.py | 82 +++ pyload/plugin/hoster/DdlstorageCom.py | 19 + pyload/plugin/hoster/DebridItaliaCom.py | 53 ++ pyload/plugin/hoster/DepositfilesCom.py | 123 ++++ pyload/plugin/hoster/DevhostSt.py | 48 ++ pyload/plugin/hoster/DlFreeFr.py | 136 ++++ pyload/plugin/hoster/DodanePl.py | 18 + pyload/plugin/hoster/DuploadOrg.py | 18 + pyload/plugin/hoster/EasybytezCom.py | 26 + pyload/plugin/hoster/EdiskCz.py | 56 ++ pyload/plugin/hoster/EgoFilesCom.py | 18 + pyload/plugin/hoster/EnteruploadCom.py | 18 + pyload/plugin/hoster/EpicShareNet.py | 18 + pyload/plugin/hoster/EuroshareEu.py | 67 ++ pyload/plugin/hoster/ExtabitCom.py | 79 ++ pyload/plugin/hoster/FastixRu.py | 76 ++ pyload/plugin/hoster/FastshareCz.py | 77 ++ pyload/plugin/hoster/FileApeCom.py | 18 + pyload/plugin/hoster/FileParadoxIn.py | 25 + pyload/plugin/hoster/FileSharkPl.py | 138 ++++ pyload/plugin/hoster/FileStoreTo.py | 37 + pyload/plugin/hoster/FilebeerInfo.py | 18 + pyload/plugin/hoster/FilecloudIo.py | 125 ++++ pyload/plugin/hoster/FilefactoryCom.py | 90 +++ pyload/plugin/hoster/FilejungleCom.py | 29 + pyload/plugin/hoster/FileomCom.py | 35 + pyload/plugin/hoster/FilepostCom.py | 130 ++++ pyload/plugin/hoster/FilepupNet.py | 51 ++ pyload/plugin/hoster/FilerNet.py | 80 +++ pyload/plugin/hoster/FilerioCom.py | 25 + pyload/plugin/hoster/FilesMailRu.py | 106 +++ pyload/plugin/hoster/FileserveCom.py | 217 ++++++ pyload/plugin/hoster/FileshareInUa.py | 18 + pyload/plugin/hoster/FilesonicCom.py | 19 + pyload/plugin/hoster/FilezyNet.py | 18 + pyload/plugin/hoster/FiredriveCom.py | 18 + pyload/plugin/hoster/FlyFilesNet.py | 45 ++ pyload/plugin/hoster/FourSharedCom.py | 61 ++ pyload/plugin/hoster/FreakshareCom.py | 176 +++++ pyload/plugin/hoster/FreeWayMe.py | 36 + pyload/plugin/hoster/FreevideoCz.py | 18 + pyload/plugin/hoster/FshareVn.py | 125 ++++ pyload/plugin/hoster/Ftp.py | 79 ++ pyload/plugin/hoster/GamefrontCom.py | 90 +++ pyload/plugin/hoster/GigapetaCom.py | 64 ++ pyload/plugin/hoster/GooIm.py | 39 + pyload/plugin/hoster/HellshareCz.py | 48 ++ pyload/plugin/hoster/HellspyCz.py | 18 + pyload/plugin/hoster/HotfileCom.py | 21 + pyload/plugin/hoster/HugefilesNet.py | 27 + pyload/plugin/hoster/HundredEightyUploadCom.py | 27 + pyload/plugin/hoster/IFileWs.py | 18 + pyload/plugin/hoster/IcyFilesCom.py | 18 + pyload/plugin/hoster/IfileIt.py | 67 ++ pyload/plugin/hoster/IfolderRu.py | 76 ++ pyload/plugin/hoster/JumbofilesCom.py | 38 + pyload/plugin/hoster/JunocloudMe.py | 28 + pyload/plugin/hoster/Keep2shareCc.py | 132 ++++ pyload/plugin/hoster/KickloadCom.py | 18 + pyload/plugin/hoster/KingfilesNet.py | 82 +++ pyload/plugin/hoster/LemUploadsCom.py | 18 + pyload/plugin/hoster/LetitbitNet.py | 142 ++++ pyload/plugin/hoster/LinksnappyCom.py | 76 ++ pyload/plugin/hoster/LoadTo.py | 75 ++ pyload/plugin/hoster/LomafileCom.py | 30 + pyload/plugin/hoster/LuckyShareNet.py | 73 ++ pyload/plugin/hoster/MediafireCom.py | 124 ++++ pyload/plugin/hoster/MegaCoNz.py | 171 +++++ pyload/plugin/hoster/MegaDebridEu.py | 94 +++ pyload/plugin/hoster/MegaFilesSe.py | 18 + pyload/plugin/hoster/MegaRapidCz.py | 71 ++ pyload/plugin/hoster/MegacrypterCom.py | 56 ++ pyload/plugin/hoster/MegareleaseOrg.py | 19 + pyload/plugin/hoster/MegasharesCom.py | 113 +++ pyload/plugin/hoster/MegauploadCom.py | 18 + pyload/plugin/hoster/MegavideoCom.py | 19 + pyload/plugin/hoster/MovReelCom.py | 26 + pyload/plugin/hoster/MultishareCz.py | 80 +++ pyload/plugin/hoster/MyfastfileCom.py | 47 ++ pyload/plugin/hoster/MyvideoDe.py | 49 ++ pyload/plugin/hoster/NahrajCz.py | 18 + pyload/plugin/hoster/NarodRu.py | 60 ++ pyload/plugin/hoster/NetloadIn.py | 294 ++++++++ pyload/plugin/hoster/NosuploadCom.py | 43 ++ pyload/plugin/hoster/NovafileCom.py | 31 + pyload/plugin/hoster/NowDownloadSx.py | 64 ++ pyload/plugin/hoster/NowVideoSx.py | 44 ++ pyload/plugin/hoster/OboomCom.py | 145 ++++ pyload/plugin/hoster/OneFichierCom.py | 71 ++ pyload/plugin/hoster/OronCom.py | 19 + pyload/plugin/hoster/OverLoadMe.py | 84 +++ pyload/plugin/hoster/PandaplaNet.py | 18 + pyload/plugin/hoster/PornhostCom.py | 80 +++ pyload/plugin/hoster/PornhubCom.py | 89 +++ pyload/plugin/hoster/PotloadCom.py | 18 + pyload/plugin/hoster/PremiumTo.py | 81 +++ pyload/plugin/hoster/PremiumizeMe.py | 56 ++ pyload/plugin/hoster/PromptfileCom.py | 45 ++ pyload/plugin/hoster/PrzeklejPl.py | 18 + pyload/plugin/hoster/QuickshareCz.py | 90 +++ pyload/plugin/hoster/RPNetBiz.py | 85 +++ pyload/plugin/hoster/RapidfileshareNet.py | 31 + pyload/plugin/hoster/RapidgatorNet.py | 199 ++++++ pyload/plugin/hoster/RapiduNet.py | 82 +++ pyload/plugin/hoster/RarefileNet.py | 28 + pyload/plugin/hoster/RealdebridCom.py | 94 +++ pyload/plugin/hoster/RedtubeCom.py | 62 ++ pyload/plugin/hoster/RehostTo.py | 44 ++ pyload/plugin/hoster/RemixshareCom.py | 61 ++ pyload/plugin/hoster/RgHostNet.py | 26 + pyload/plugin/hoster/RyushareCom.py | 81 +++ pyload/plugin/hoster/SafesharingEu.py | 25 + pyload/plugin/hoster/SecureUploadEu.py | 23 + pyload/plugin/hoster/SendmywayCom.py | 24 + pyload/plugin/hoster/SendspaceCom.py | 60 ++ pyload/plugin/hoster/Share4webCom.py | 22 + pyload/plugin/hoster/Share76Com.py | 18 + pyload/plugin/hoster/ShareFilesCo.py | 18 + pyload/plugin/hoster/SharebeesCom.py | 18 + pyload/plugin/hoster/ShareonlineBiz.py | 191 +++++ pyload/plugin/hoster/ShareplaceCom.py | 89 +++ pyload/plugin/hoster/SharingmatrixCom.py | 19 + pyload/plugin/hoster/ShragleCom.py | 19 + pyload/plugin/hoster/SimplyPremiumCom.py | 82 +++ pyload/plugin/hoster/SimplydebridCom.py | 64 ++ pyload/plugin/hoster/SockshareCom.py | 20 + pyload/plugin/hoster/SoundcloudCom.py | 57 ++ pyload/plugin/hoster/SpeedLoadOrg.py | 18 + pyload/plugin/hoster/SpeedfileCz.py | 18 + pyload/plugin/hoster/SpeedyshareCom.py | 51 ++ pyload/plugin/hoster/StorageTo.py | 18 + pyload/plugin/hoster/StreamCz.py | 71 ++ pyload/plugin/hoster/StreamcloudEu.py | 31 + pyload/plugin/hoster/TurbobitNet.py | 173 +++++ pyload/plugin/hoster/TurbouploadCom.py | 18 + pyload/plugin/hoster/TusfilesNet.py | 35 + pyload/plugin/hoster/TwoSharedCom.py | 41 ++ pyload/plugin/hoster/UlozTo.py | 164 +++++ pyload/plugin/hoster/UloziskoSk.py | 72 ++ pyload/plugin/hoster/UnibytesCom.py | 70 ++ pyload/plugin/hoster/UnrestrictLi.py | 91 +++ pyload/plugin/hoster/UpleaCom.py | 60 ++ pyload/plugin/hoster/UploadStationCom.py | 19 + pyload/plugin/hoster/UploadableCh.py | 90 +++ pyload/plugin/hoster/UploadboxCom.py | 18 + pyload/plugin/hoster/UploadedTo.py | 245 +++++++ pyload/plugin/hoster/UploadhereCom.py | 18 + pyload/plugin/hoster/UploadheroCom.py | 81 +++ pyload/plugin/hoster/UploadingCom.py | 104 +++ pyload/plugin/hoster/UploadkingCom.py | 18 + pyload/plugin/hoster/UpstoreNet.py | 73 ++ pyload/plugin/hoster/UptoboxCom.py | 34 + pyload/plugin/hoster/VeehdCom.py | 81 +++ pyload/plugin/hoster/VeohCom.py | 53 ++ pyload/plugin/hoster/VidPlayNet.py | 26 + pyload/plugin/hoster/VimeoCom.py | 75 ++ pyload/plugin/hoster/Vipleech4uCom.py | 18 + pyload/plugin/hoster/WarserverCz.py | 18 + pyload/plugin/hoster/WebshareCz.py | 62 ++ pyload/plugin/hoster/WrzucTo.py | 52 ++ pyload/plugin/hoster/WuploadCom.py | 19 + pyload/plugin/hoster/X7To.py | 18 + pyload/plugin/hoster/XFileSharingPro.py | 57 ++ pyload/plugin/hoster/XHamsterCom.py | 129 ++++ pyload/plugin/hoster/XVideosCom.py | 28 + pyload/plugin/hoster/Xdcc.py | 207 ++++++ pyload/plugin/hoster/YibaishiwuCom.py | 55 ++ pyload/plugin/hoster/YoupornCom.py | 60 ++ pyload/plugin/hoster/YourfilesTo.py | 87 +++ pyload/plugin/hoster/YoutubeCom.py | 185 +++++ pyload/plugin/hoster/ZDF.py | 59 ++ pyload/plugin/hoster/ZShareNet.py | 19 + pyload/plugin/hoster/ZeveraCom.py | 42 ++ pyload/plugin/hoster/ZippyshareCom.py | 65 ++ pyload/plugin/hoster/__init__.py | 1 + pyload/plugin/internal/AbstractExtractor.py | 109 +++ pyload/plugin/internal/BasePlugin.py | 106 +++ pyload/plugin/internal/DeadCrypter.py | 32 + pyload/plugin/internal/DeadHoster.py | 32 + pyload/plugin/internal/MultiHoster.py | 202 ++++++ pyload/plugin/internal/SimpleCrypter.py | 152 ++++ pyload/plugin/internal/SimpleHoster.py | 530 ++++++++++++++ pyload/plugin/internal/UnRar.py | 221 ++++++ pyload/plugin/internal/UnZip.py | 41 ++ pyload/plugin/internal/UpdateManager.py | 300 ++++++++ pyload/plugin/internal/XFSAccount.py | 155 ++++ pyload/plugin/internal/XFSCrypter.py | 29 + pyload/plugin/internal/XFSHoster.py | 339 +++++++++ pyload/plugin/internal/__init__.py | 1 + pyload/plugin/ocr/GigasizeCom.py | 24 + pyload/plugin/ocr/LinksaveIn.py | 158 ++++ pyload/plugin/ocr/NetloadIn.py | 29 + pyload/plugin/ocr/ShareonlineBiz.py | 39 + pyload/plugin/ocr/__init__.py | 1 + pyload/plugins/Account.py | 307 -------- pyload/plugins/Addon.py | 185 ----- pyload/plugins/Captcha.py | 51 -- pyload/plugins/Container.py | 66 -- pyload/plugins/Crypter.py | 107 --- pyload/plugins/Hoster.py | 21 - pyload/plugins/OCR.py | 315 -------- pyload/plugins/Plugin.py | 753 ------------------- pyload/plugins/__init__.py | 1 - pyload/plugins/account/AlldebridCom.py | 59 -- pyload/plugins/account/BayfilesCom.py | 37 - pyload/plugins/account/BillionuploadsCom.py | 16 - pyload/plugins/account/BitshareCom.py | 32 - pyload/plugins/account/CatShareNet.py | 56 -- pyload/plugins/account/CramitIn.py | 16 - pyload/plugins/account/CzshareCom.py | 44 -- pyload/plugins/account/DebridItaliaCom.py | 44 -- pyload/plugins/account/DepositfilesCom.py | 35 - pyload/plugins/account/DropboxCom.py | 42 -- pyload/plugins/account/EasybytezCom.py | 19 - pyload/plugins/account/EuroshareEu.py | 41 -- pyload/plugins/account/FastixRu.py | 38 - pyload/plugins/account/FastshareCz.py | 53 -- pyload/plugins/account/File4safeCom.py | 18 - pyload/plugins/account/FileParadoxIn.py | 16 - pyload/plugins/account/FilecloudIo.py | 59 -- pyload/plugins/account/FilefactoryCom.py | 49 -- pyload/plugins/account/FilejungleCom.py | 49 -- pyload/plugins/account/FileomCom.py | 16 - pyload/plugins/account/FilerNet.py | 50 -- pyload/plugins/account/FilerioCom.py | 16 - pyload/plugins/account/FilesMailRu.py | 28 - pyload/plugins/account/FileserveCom.py | 44 -- pyload/plugins/account/FourSharedCom.py | 33 - pyload/plugins/account/FreakshareCom.py | 43 -- pyload/plugins/account/FreeWayMe.py | 55 -- pyload/plugins/account/FshareVn.py | 63 -- pyload/plugins/account/Ftp.py | 17 - pyload/plugins/account/HellshareCz.py | 76 -- pyload/plugins/account/Http.py | 17 - pyload/plugins/account/HugefilesNet.py | 16 - pyload/plugins/account/HundredEightyUploadCom.py | 16 - pyload/plugins/account/JunocloudMe.py | 16 - pyload/plugins/account/Keep2shareCc.py | 69 -- pyload/plugins/account/LetitbitNet.py | 34 - pyload/plugins/account/LinestorageCom.py | 16 - pyload/plugins/account/LinksnappyCom.py | 50 -- pyload/plugins/account/LomafileCom.py | 16 - pyload/plugins/account/MegaDebridEu.py | 39 - pyload/plugins/account/MegaRapidCz.py | 59 -- pyload/plugins/account/MegasharesCom.py | 48 -- pyload/plugins/account/MovReelCom.py | 19 - pyload/plugins/account/MultishareCz.py | 44 -- pyload/plugins/account/MyfastfileCom.py | 35 - pyload/plugins/account/NetloadIn.py | 40 -- pyload/plugins/account/NosuploadCom.py | 16 - pyload/plugins/account/NovafileCom.py | 16 - pyload/plugins/account/NowVideoAt.py | 56 -- pyload/plugins/account/OboomCom.py | 62 -- pyload/plugins/account/OneFichierCom.py | 55 -- pyload/plugins/account/OverLoadMe.py | 36 - pyload/plugins/account/PremiumTo.py | 34 - pyload/plugins/account/PremiumizeMe.py | 49 -- pyload/plugins/account/QuickshareCz.py | 43 -- pyload/plugins/account/RPNetBiz.py | 51 -- pyload/plugins/account/RapidfileshareNet.py | 18 - pyload/plugins/account/RapidgatorNet.py | 58 -- pyload/plugins/account/RapiduNet.py | 48 -- pyload/plugins/account/RarefileNet.py | 16 - pyload/plugins/account/RealdebridCom.py | 36 - pyload/plugins/account/RehostTo.py | 41 -- pyload/plugins/account/RyushareCom.py | 25 - pyload/plugins/account/SafesharingEu.py | 16 - pyload/plugins/account/SecureUploadEu.py | 16 - pyload/plugins/account/SendmywayCom.py | 16 - pyload/plugins/account/ShareonlineBiz.py | 45 -- pyload/plugins/account/SimplyPremiumCom.py | 46 -- pyload/plugins/account/SimplydebridCom.py | 34 - pyload/plugins/account/StahnuTo.py | 34 - pyload/plugins/account/StreamcloudEu.py | 16 - pyload/plugins/account/TurbobitNet.py | 42 -- pyload/plugins/account/TusfilesNet.py | 23 - pyload/plugins/account/UlozTo.py | 52 -- pyload/plugins/account/UnrestrictLi.py | 44 -- pyload/plugins/account/UploadcCom.py | 16 - pyload/plugins/account/UploadedTo.py | 60 -- pyload/plugins/account/UploadheroCom.py | 41 -- pyload/plugins/account/UploadingCom.py | 63 -- pyload/plugins/account/UptoboxCom.py | 17 - pyload/plugins/account/VidPlayNet.py | 16 - pyload/plugins/account/XFileSharingPro.py | 30 - pyload/plugins/account/YibaishiwuCom.py | 40 -- pyload/plugins/account/ZeveraCom.py | 56 -- pyload/plugins/account/__init__.py | 1 - pyload/plugins/addon/Checksum.py | 186 ----- pyload/plugins/addon/ClickAndLoad.py | 74 -- pyload/plugins/addon/DeleteFinished.py | 79 -- pyload/plugins/addon/DownloadScheduler.py | 77 -- pyload/plugins/addon/ExternalScripts.py | 145 ---- pyload/plugins/addon/ExtractArchive.py | 363 ---------- pyload/plugins/addon/HotFolder.py | 70 -- pyload/plugins/addon/IRCInterface.py | 431 ----------- pyload/plugins/addon/MergeFiles.py | 85 --- pyload/plugins/addon/MultiHome.py | 81 --- pyload/plugins/addon/RestartFailed.py | 45 -- pyload/plugins/addon/RestartSlow.py | 57 -- pyload/plugins/addon/SkipRev.py | 77 -- pyload/plugins/addon/UnSkipOnFail.py | 87 --- pyload/plugins/addon/UpdateManager.py | 305 -------- pyload/plugins/addon/WindowsPhoneToastNotify.py | 57 -- pyload/plugins/addon/XMPPInterface.py | 252 ------- pyload/plugins/addon/__init__.py | 1 - pyload/plugins/captcha/AdYouLike.py | 107 --- pyload/plugins/captcha/AdsCaptcha.py | 77 -- pyload/plugins/captcha/ReCaptcha.py | 73 -- pyload/plugins/captcha/SolveMedia.py | 50 -- pyload/plugins/captcha/__init__.py | 1 - pyload/plugins/container/CCF.py | 43 -- pyload/plugins/container/LinkList.py | 71 -- pyload/plugins/container/RSDF.py | 56 -- pyload/plugins/container/__init__.py | 1 - pyload/plugins/crypter/BitshareCom.py | 21 - pyload/plugins/crypter/C1neonCom.py | 19 - pyload/plugins/crypter/ChipDe.py | 29 - pyload/plugins/crypter/CrockoCom.py | 20 - pyload/plugins/crypter/CryptItCom.py | 19 - pyload/plugins/crypter/CzshareCom.py | 32 - pyload/plugins/crypter/DDLMusicOrg.py | 51 -- pyload/plugins/crypter/DailymotionBatch.py | 106 --- pyload/plugins/crypter/DataHu.py | 40 -- pyload/plugins/crypter/DdlstorageCom.py | 20 - pyload/plugins/crypter/DepositfilesCom.py | 20 - pyload/plugins/crypter/Dereferer.py | 26 - pyload/plugins/crypter/DevhostStFolder.py | 58 -- pyload/plugins/crypter/DlProtectCom.py | 65 -- pyload/plugins/crypter/DontKnowMe.py | 29 - pyload/plugins/crypter/DuckCryptInfo.py | 59 -- pyload/plugins/crypter/DuploadOrg.py | 19 - pyload/plugins/crypter/EasybytezCom.py | 22 - pyload/plugins/crypter/EmbeduploadCom.py | 60 -- pyload/plugins/crypter/FilebeerInfo.py | 19 - pyload/plugins/crypter/FilecloudIo.py | 21 - pyload/plugins/crypter/FilecryptCc.py | 148 ---- pyload/plugins/crypter/FilefactoryCom.py | 28 - pyload/plugins/crypter/FilerNet.py | 26 - pyload/plugins/crypter/FileserveCom.py | 38 - pyload/plugins/crypter/FilesonicCom.py | 18 - pyload/plugins/crypter/FilestubeCom.py | 21 - pyload/plugins/crypter/FiletramCom.py | 22 - pyload/plugins/crypter/FiredriveCom.py | 19 - pyload/plugins/crypter/FourChanOrg.py | 27 - pyload/plugins/crypter/FreakhareCom.py | 38 - pyload/plugins/crypter/FreetexthostCom.py | 27 - pyload/plugins/crypter/FshareVn.py | 20 - pyload/plugins/crypter/Go4UpCom.py | 49 -- pyload/plugins/crypter/GooGl.py | 32 - pyload/plugins/crypter/HoerbuchIn.py | 62 -- pyload/plugins/crypter/HotfileCom.py | 19 - pyload/plugins/crypter/ILoadTo.py | 19 - pyload/plugins/crypter/ImgurComAlbum.py | 27 - pyload/plugins/crypter/JunocloudMe.py | 20 - pyload/plugins/crypter/LetitbitNet.py | 33 - pyload/plugins/crypter/LinkCryptWs.py | 327 --------- pyload/plugins/crypter/LinkSaveIn.py | 246 ------- pyload/plugins/crypter/LinkdecrypterCom.py | 92 --- pyload/plugins/crypter/LixIn.py | 62 -- pyload/plugins/crypter/LofCc.py | 19 - pyload/plugins/crypter/MBLinkInfo.py | 20 - pyload/plugins/crypter/MediafireCom.py | 58 -- pyload/plugins/crypter/MegaRapidCz.py | 20 - pyload/plugins/crypter/MegauploadCom.py | 18 - pyload/plugins/crypter/Movie2kTo.py | 19 - pyload/plugins/crypter/MultiUpOrg.py | 38 - pyload/plugins/crypter/MultiloadCz.py | 42 -- pyload/plugins/crypter/MultiuploadCom.py | 18 - pyload/plugins/crypter/NCryptIn.py | 315 -------- pyload/plugins/crypter/NetfolderIn.py | 70 -- pyload/plugins/crypter/NosvideoCom.py | 21 - pyload/plugins/crypter/OneKhDe.py | 40 -- pyload/plugins/crypter/OronCom.py | 19 - pyload/plugins/crypter/PastebinCom.py | 21 - pyload/plugins/crypter/QuickshareCz.py | 31 - pyload/plugins/crypter/RSLayerCom.py | 19 - pyload/plugins/crypter/RapidfileshareNet.py | 20 - pyload/plugins/crypter/RelinkUs.py | 293 -------- pyload/plugins/crypter/SafelinkingNet.py | 79 -- pyload/plugins/crypter/SecuredIn.py | 19 - pyload/plugins/crypter/SexuriaCom.py | 94 --- pyload/plugins/crypter/ShareLinksBiz.py | 286 -------- pyload/plugins/crypter/SharingmatrixCom.py | 18 - pyload/plugins/crypter/SpeedLoadOrg.py | 19 - pyload/plugins/crypter/StealthTo.py | 19 - pyload/plugins/crypter/TnyCz.py | 27 - pyload/plugins/crypter/TrailerzoneInfo.py | 19 - pyload/plugins/crypter/TurbobitNet.py | 44 -- pyload/plugins/crypter/TusfilesNet.py | 45 -- pyload/plugins/crypter/UlozTo.py | 46 -- pyload/plugins/crypter/UploadableCh.py | 24 - pyload/plugins/crypter/UploadedTo.py | 34 - pyload/plugins/crypter/WiiReloadedOrg.py | 19 - pyload/plugins/crypter/WuploadCom.py | 18 - pyload/plugins/crypter/XFileSharingPro.py | 47 -- pyload/plugins/crypter/XupPl.py | 25 - pyload/plugins/crypter/YoutubeBatch.py | 148 ---- pyload/plugins/crypter/__init__.py | 1 - pyload/plugins/hook/AlldebridCom.py | 27 - pyload/plugins/hook/BypassCaptcha.py | 133 ---- pyload/plugins/hook/Captcha9kw.py | 253 ------- pyload/plugins/hook/CaptchaBrotherhood.py | 166 ----- pyload/plugins/hook/DeathByCaptcha.py | 213 ------ pyload/plugins/hook/DebridItaliaCom.py | 27 - pyload/plugins/hook/EasybytezCom.py | 39 - pyload/plugins/hook/ExpertDecoders.py | 92 --- pyload/plugins/hook/FastixRu.py | 28 - pyload/plugins/hook/FreeWayMe.py | 25 - pyload/plugins/hook/ImageTyperz.py | 151 ---- pyload/plugins/hook/LinkdecrypterCom.py | 60 -- pyload/plugins/hook/LinksnappyCom.py | 27 - pyload/plugins/hook/MegaDebridEu.py | 30 - pyload/plugins/hook/MultishareCz.py | 27 - pyload/plugins/hook/MyfastfileCom.py | 30 - pyload/plugins/hook/OverLoadMe.py | 29 - pyload/plugins/hook/PremiumTo.py | 38 - pyload/plugins/hook/PremiumizeMe.py | 54 -- pyload/plugins/hook/RPNetBiz.py | 52 -- pyload/plugins/hook/RealdebridCom.py | 27 - pyload/plugins/hook/RehostTo.py | 41 -- pyload/plugins/hook/SimplyPremiumCom.py | 29 - pyload/plugins/hook/SimplydebridCom.py | 22 - pyload/plugins/hook/UnrestrictLi.py | 30 - pyload/plugins/hook/XFileSharingPro.py | 96 --- pyload/plugins/hook/ZeveraCom.py | 22 - pyload/plugins/hook/__init__.py | 1 - pyload/plugins/hoster/AlldebridCom.py | 87 --- pyload/plugins/hoster/BayfilesCom.py | 87 --- pyload/plugins/hoster/BezvadataCz.py | 94 --- pyload/plugins/hoster/BillionuploadsCom.py | 24 - pyload/plugins/hoster/BitshareCom.py | 157 ---- pyload/plugins/hoster/BoltsharingCom.py | 18 - pyload/plugins/hoster/CatShareNet.py | 67 -- pyload/plugins/hoster/CloudzerNet.py | 20 - pyload/plugins/hoster/CramitIn.py | 24 - pyload/plugins/hoster/CrockoCom.py | 70 -- pyload/plugins/hoster/CyberlockerCh.py | 18 - pyload/plugins/hoster/CzshareCom.py | 152 ---- pyload/plugins/hoster/DailymotionCom.py | 125 ---- pyload/plugins/hoster/DataHu.py | 42 -- pyload/plugins/hoster/DataportCz.py | 55 -- pyload/plugins/hoster/DateiTo.py | 82 --- pyload/plugins/hoster/DdlstorageCom.py | 19 - pyload/plugins/hoster/DebridItaliaCom.py | 53 -- pyload/plugins/hoster/DepositfilesCom.py | 123 ---- pyload/plugins/hoster/DevhostSt.py | 48 -- pyload/plugins/hoster/DlFreeFr.py | 136 ---- pyload/plugins/hoster/DodanePl.py | 18 - pyload/plugins/hoster/DuploadOrg.py | 18 - pyload/plugins/hoster/EasybytezCom.py | 26 - pyload/plugins/hoster/EdiskCz.py | 56 -- pyload/plugins/hoster/EgoFilesCom.py | 18 - pyload/plugins/hoster/EnteruploadCom.py | 18 - pyload/plugins/hoster/EpicShareNet.py | 18 - pyload/plugins/hoster/EuroshareEu.py | 67 -- pyload/plugins/hoster/ExtabitCom.py | 79 -- pyload/plugins/hoster/FastixRu.py | 76 -- pyload/plugins/hoster/FastshareCz.py | 77 -- pyload/plugins/hoster/FileApeCom.py | 18 - pyload/plugins/hoster/FileParadoxIn.py | 25 - pyload/plugins/hoster/FileSharkPl.py | 138 ---- pyload/plugins/hoster/FileStoreTo.py | 37 - pyload/plugins/hoster/FilebeerInfo.py | 18 - pyload/plugins/hoster/FilecloudIo.py | 125 ---- pyload/plugins/hoster/FilefactoryCom.py | 90 --- pyload/plugins/hoster/FilejungleCom.py | 29 - pyload/plugins/hoster/FileomCom.py | 35 - pyload/plugins/hoster/FilepostCom.py | 130 ---- pyload/plugins/hoster/FilepupNet.py | 51 -- pyload/plugins/hoster/FilerNet.py | 80 --- pyload/plugins/hoster/FilerioCom.py | 25 - pyload/plugins/hoster/FilesMailRu.py | 106 --- pyload/plugins/hoster/FileserveCom.py | 217 ------ pyload/plugins/hoster/FileshareInUa.py | 18 - pyload/plugins/hoster/FilesonicCom.py | 19 - pyload/plugins/hoster/FilezyNet.py | 18 - pyload/plugins/hoster/FiredriveCom.py | 18 - pyload/plugins/hoster/FlyFilesNet.py | 45 -- pyload/plugins/hoster/FourSharedCom.py | 61 -- pyload/plugins/hoster/FreakshareCom.py | 176 ----- pyload/plugins/hoster/FreeWayMe.py | 36 - pyload/plugins/hoster/FreevideoCz.py | 18 - pyload/plugins/hoster/FshareVn.py | 125 ---- pyload/plugins/hoster/Ftp.py | 79 -- pyload/plugins/hoster/GamefrontCom.py | 90 --- pyload/plugins/hoster/GigapetaCom.py | 64 -- pyload/plugins/hoster/GooIm.py | 39 - pyload/plugins/hoster/HellshareCz.py | 48 -- pyload/plugins/hoster/HellspyCz.py | 18 - pyload/plugins/hoster/HotfileCom.py | 21 - pyload/plugins/hoster/HugefilesNet.py | 27 - pyload/plugins/hoster/HundredEightyUploadCom.py | 27 - pyload/plugins/hoster/IFileWs.py | 18 - pyload/plugins/hoster/IcyFilesCom.py | 18 - pyload/plugins/hoster/IfileIt.py | 67 -- pyload/plugins/hoster/IfolderRu.py | 76 -- pyload/plugins/hoster/JumbofilesCom.py | 38 - pyload/plugins/hoster/JunocloudMe.py | 28 - pyload/plugins/hoster/Keep2shareCc.py | 132 ---- pyload/plugins/hoster/KickloadCom.py | 18 - pyload/plugins/hoster/KingfilesNet.py | 82 --- pyload/plugins/hoster/LemUploadsCom.py | 18 - pyload/plugins/hoster/LetitbitNet.py | 142 ---- pyload/plugins/hoster/LinksnappyCom.py | 76 -- pyload/plugins/hoster/LoadTo.py | 75 -- pyload/plugins/hoster/LomafileCom.py | 30 - pyload/plugins/hoster/LuckyShareNet.py | 73 -- pyload/plugins/hoster/MediafireCom.py | 124 ---- pyload/plugins/hoster/MegaCoNz.py | 171 ----- pyload/plugins/hoster/MegaDebridEu.py | 94 --- pyload/plugins/hoster/MegaFilesSe.py | 18 - pyload/plugins/hoster/MegaRapidCz.py | 71 -- pyload/plugins/hoster/MegacrypterCom.py | 56 -- pyload/plugins/hoster/MegareleaseOrg.py | 19 - pyload/plugins/hoster/MegasharesCom.py | 113 --- pyload/plugins/hoster/MegauploadCom.py | 18 - pyload/plugins/hoster/MegavideoCom.py | 19 - pyload/plugins/hoster/MovReelCom.py | 26 - pyload/plugins/hoster/MultishareCz.py | 80 --- pyload/plugins/hoster/MyfastfileCom.py | 47 -- pyload/plugins/hoster/MyvideoDe.py | 49 -- pyload/plugins/hoster/NahrajCz.py | 18 - pyload/plugins/hoster/NarodRu.py | 60 -- pyload/plugins/hoster/NetloadIn.py | 294 -------- pyload/plugins/hoster/NosuploadCom.py | 43 -- pyload/plugins/hoster/NovafileCom.py | 31 - pyload/plugins/hoster/NowDownloadSx.py | 64 -- pyload/plugins/hoster/NowVideoSx.py | 44 -- pyload/plugins/hoster/OboomCom.py | 145 ---- pyload/plugins/hoster/OneFichierCom.py | 71 -- pyload/plugins/hoster/OronCom.py | 19 - pyload/plugins/hoster/OverLoadMe.py | 84 --- pyload/plugins/hoster/PandaplaNet.py | 18 - pyload/plugins/hoster/PornhostCom.py | 80 --- pyload/plugins/hoster/PornhubCom.py | 89 --- pyload/plugins/hoster/PotloadCom.py | 18 - pyload/plugins/hoster/PremiumTo.py | 81 --- pyload/plugins/hoster/PremiumizeMe.py | 56 -- pyload/plugins/hoster/PromptfileCom.py | 45 -- pyload/plugins/hoster/PrzeklejPl.py | 18 - pyload/plugins/hoster/QuickshareCz.py | 90 --- pyload/plugins/hoster/RPNetBiz.py | 85 --- pyload/plugins/hoster/RapidfileshareNet.py | 31 - pyload/plugins/hoster/RapidgatorNet.py | 199 ------ pyload/plugins/hoster/RapiduNet.py | 82 --- pyload/plugins/hoster/RarefileNet.py | 28 - pyload/plugins/hoster/RealdebridCom.py | 94 --- pyload/plugins/hoster/RedtubeCom.py | 62 -- pyload/plugins/hoster/RehostTo.py | 44 -- pyload/plugins/hoster/RemixshareCom.py | 61 -- pyload/plugins/hoster/RgHostNet.py | 26 - pyload/plugins/hoster/RyushareCom.py | 81 --- pyload/plugins/hoster/SafesharingEu.py | 25 - pyload/plugins/hoster/SecureUploadEu.py | 23 - pyload/plugins/hoster/SendmywayCom.py | 24 - pyload/plugins/hoster/SendspaceCom.py | 60 -- pyload/plugins/hoster/Share4webCom.py | 22 - pyload/plugins/hoster/Share76Com.py | 18 - pyload/plugins/hoster/ShareFilesCo.py | 18 - pyload/plugins/hoster/SharebeesCom.py | 18 - pyload/plugins/hoster/ShareonlineBiz.py | 191 ----- pyload/plugins/hoster/ShareplaceCom.py | 89 --- pyload/plugins/hoster/SharingmatrixCom.py | 19 - pyload/plugins/hoster/ShragleCom.py | 19 - pyload/plugins/hoster/SimplyPremiumCom.py | 82 --- pyload/plugins/hoster/SimplydebridCom.py | 64 -- pyload/plugins/hoster/SockshareCom.py | 20 - pyload/plugins/hoster/SoundcloudCom.py | 57 -- pyload/plugins/hoster/SpeedLoadOrg.py | 18 - pyload/plugins/hoster/SpeedfileCz.py | 18 - pyload/plugins/hoster/SpeedyshareCom.py | 51 -- pyload/plugins/hoster/StorageTo.py | 18 - pyload/plugins/hoster/StreamCz.py | 71 -- pyload/plugins/hoster/StreamcloudEu.py | 31 - pyload/plugins/hoster/TurbobitNet.py | 173 ----- pyload/plugins/hoster/TurbouploadCom.py | 18 - pyload/plugins/hoster/TusfilesNet.py | 35 - pyload/plugins/hoster/TwoSharedCom.py | 41 -- pyload/plugins/hoster/UlozTo.py | 164 ----- pyload/plugins/hoster/UloziskoSk.py | 72 -- pyload/plugins/hoster/UnibytesCom.py | 70 -- pyload/plugins/hoster/UnrestrictLi.py | 91 --- pyload/plugins/hoster/UpleaCom.py | 60 -- pyload/plugins/hoster/UploadStationCom.py | 19 - pyload/plugins/hoster/UploadableCh.py | 90 --- pyload/plugins/hoster/UploadboxCom.py | 18 - pyload/plugins/hoster/UploadedTo.py | 245 ------- pyload/plugins/hoster/UploadhereCom.py | 18 - pyload/plugins/hoster/UploadheroCom.py | 81 --- pyload/plugins/hoster/UploadingCom.py | 104 --- pyload/plugins/hoster/UploadkingCom.py | 18 - pyload/plugins/hoster/UpstoreNet.py | 73 -- pyload/plugins/hoster/UptoboxCom.py | 34 - pyload/plugins/hoster/VeehdCom.py | 81 --- pyload/plugins/hoster/VeohCom.py | 53 -- pyload/plugins/hoster/VidPlayNet.py | 26 - pyload/plugins/hoster/VimeoCom.py | 75 -- pyload/plugins/hoster/Vipleech4uCom.py | 18 - pyload/plugins/hoster/WarserverCz.py | 18 - pyload/plugins/hoster/WebshareCz.py | 62 -- pyload/plugins/hoster/WrzucTo.py | 52 -- pyload/plugins/hoster/WuploadCom.py | 19 - pyload/plugins/hoster/X7To.py | 18 - pyload/plugins/hoster/XFileSharingPro.py | 57 -- pyload/plugins/hoster/XHamsterCom.py | 129 ---- pyload/plugins/hoster/XVideosCom.py | 28 - pyload/plugins/hoster/Xdcc.py | 207 ------ pyload/plugins/hoster/YibaishiwuCom.py | 55 -- pyload/plugins/hoster/YoupornCom.py | 60 -- pyload/plugins/hoster/YourfilesTo.py | 87 --- pyload/plugins/hoster/YoutubeCom.py | 185 ----- pyload/plugins/hoster/ZDF.py | 59 -- pyload/plugins/hoster/ZShareNet.py | 19 - pyload/plugins/hoster/ZeveraCom.py | 42 -- pyload/plugins/hoster/ZippyshareCom.py | 65 -- pyload/plugins/hoster/__init__.py | 1 - pyload/plugins/internal/AbstractExtractor.py | 109 --- pyload/plugins/internal/BasePlugin.py | 106 --- pyload/plugins/internal/DeadCrypter.py | 32 - pyload/plugins/internal/DeadHoster.py | 32 - pyload/plugins/internal/MultiHoster.py | 202 ------ pyload/plugins/internal/SimpleCrypter.py | 152 ---- pyload/plugins/internal/SimpleHoster.py | 530 -------------- pyload/plugins/internal/UnRar.py | 221 ------ pyload/plugins/internal/UnZip.py | 41 -- pyload/plugins/internal/UpdateManager.py | 300 -------- pyload/plugins/internal/XFSAccount.py | 155 ---- pyload/plugins/internal/XFSCrypter.py | 29 - pyload/plugins/internal/XFSHoster.py | 339 --------- pyload/plugins/internal/__init__.py | 1 - pyload/plugins/ocr/GigasizeCom.py | 24 - pyload/plugins/ocr/LinksaveIn.py | 158 ---- pyload/plugins/ocr/NetloadIn.py | 29 - pyload/plugins/ocr/ShareonlineBiz.py | 39 - pyload/plugins/ocr/__init__.py | 1 - pyload/remote/ClickAndLoadBackend.py | 2 +- pyload/remote/SocketBackend.py | 2 +- pyload/remote/ThriftBackend.py | 2 +- pyload/remote/socketbackend/create_ttypes.py | 13 +- pyload/remote/thriftbackend/ThriftClient.py | 8 +- pyload/remote/thriftbackend/ThriftTest.py | 9 +- pyload/webui/app/pyload.py | 10 +- setup.cfg | 7 - tests/clonedigger.sh | 2 +- 946 files changed, 32558 insertions(+), 32537 deletions(-) create mode 100644 docs/setup.cfg create mode 100644 locale/pavement.py delete mode 100644 pavement.py create mode 100644 pyload/database/File.py delete mode 100644 pyload/database/FileDatabase.py create mode 100644 pyload/database/Storage.py delete mode 100644 pyload/database/StorageDatabase.py create mode 100644 pyload/database/User.py delete mode 100644 pyload/database/UserDatabase.py create mode 100644 pyload/datatype/File.py create mode 100644 pyload/datatype/Package.py delete mode 100644 pyload/datatype/PyFile.py delete mode 100644 pyload/datatype/PyPackage.py create mode 100644 pyload/manager/Account.py delete mode 100644 pyload/manager/AccountManager.py create mode 100644 pyload/manager/Addon.py delete mode 100644 pyload/manager/AddonManager.py create mode 100644 pyload/manager/Captcha.py delete mode 100644 pyload/manager/CaptchaManager.py create mode 100644 pyload/manager/Event.py create mode 100644 pyload/manager/Plugin.py delete mode 100644 pyload/manager/PluginManager.py create mode 100644 pyload/manager/Remote.py delete mode 100644 pyload/manager/RemoteManager.py create mode 100644 pyload/manager/Thread.py delete mode 100644 pyload/manager/ThreadManager.py delete mode 100644 pyload/manager/event/PullEvents.py create mode 100644 pyload/manager/thread/Addon.py delete mode 100644 pyload/manager/thread/AddonThread.py create mode 100644 pyload/manager/thread/Decrypter.py delete mode 100644 pyload/manager/thread/DecrypterThread.py create mode 100644 pyload/manager/thread/Download.py delete mode 100644 pyload/manager/thread/DownloadThread.py create mode 100644 pyload/manager/thread/Info.py delete mode 100644 pyload/manager/thread/InfoThread.py create mode 100644 pyload/manager/thread/Plugin.py delete mode 100644 pyload/manager/thread/PluginThread.py create mode 100644 pyload/manager/thread/Server.py delete mode 100644 pyload/manager/thread/ServerThread.py create mode 100644 pyload/plugin/Account.py create mode 100644 pyload/plugin/Addon.py create mode 100644 pyload/plugin/Captcha.py create mode 100644 pyload/plugin/Container.py create mode 100644 pyload/plugin/Crypter.py create mode 100644 pyload/plugin/Hoster.py create mode 100644 pyload/plugin/OCR.py create mode 100644 pyload/plugin/Plugin.py create mode 100644 pyload/plugin/__init__.py create mode 100644 pyload/plugin/account/AlldebridCom.py create mode 100644 pyload/plugin/account/BayfilesCom.py create mode 100644 pyload/plugin/account/BillionuploadsCom.py create mode 100644 pyload/plugin/account/BitshareCom.py create mode 100644 pyload/plugin/account/CatShareNet.py create mode 100644 pyload/plugin/account/CramitIn.py create mode 100644 pyload/plugin/account/CzshareCom.py create mode 100644 pyload/plugin/account/DebridItaliaCom.py create mode 100644 pyload/plugin/account/DepositfilesCom.py create mode 100644 pyload/plugin/account/DropboxCom.py create mode 100644 pyload/plugin/account/EasybytezCom.py create mode 100644 pyload/plugin/account/EuroshareEu.py create mode 100644 pyload/plugin/account/FastixRu.py create mode 100644 pyload/plugin/account/FastshareCz.py create mode 100644 pyload/plugin/account/File4safeCom.py create mode 100644 pyload/plugin/account/FileParadoxIn.py create mode 100644 pyload/plugin/account/FilecloudIo.py create mode 100644 pyload/plugin/account/FilefactoryCom.py create mode 100644 pyload/plugin/account/FilejungleCom.py create mode 100644 pyload/plugin/account/FileomCom.py create mode 100644 pyload/plugin/account/FilerNet.py create mode 100644 pyload/plugin/account/FilerioCom.py create mode 100644 pyload/plugin/account/FilesMailRu.py create mode 100644 pyload/plugin/account/FileserveCom.py create mode 100644 pyload/plugin/account/FourSharedCom.py create mode 100644 pyload/plugin/account/FreakshareCom.py create mode 100644 pyload/plugin/account/FreeWayMe.py create mode 100644 pyload/plugin/account/FshareVn.py create mode 100644 pyload/plugin/account/Ftp.py create mode 100644 pyload/plugin/account/HellshareCz.py create mode 100644 pyload/plugin/account/Http.py create mode 100644 pyload/plugin/account/HugefilesNet.py create mode 100644 pyload/plugin/account/HundredEightyUploadCom.py create mode 100644 pyload/plugin/account/JunocloudMe.py create mode 100644 pyload/plugin/account/Keep2shareCc.py create mode 100644 pyload/plugin/account/LetitbitNet.py create mode 100644 pyload/plugin/account/LinestorageCom.py create mode 100644 pyload/plugin/account/LinksnappyCom.py create mode 100644 pyload/plugin/account/LomafileCom.py create mode 100644 pyload/plugin/account/MegaDebridEu.py create mode 100644 pyload/plugin/account/MegaRapidCz.py create mode 100644 pyload/plugin/account/MegasharesCom.py create mode 100644 pyload/plugin/account/MovReelCom.py create mode 100644 pyload/plugin/account/MultishareCz.py create mode 100644 pyload/plugin/account/MyfastfileCom.py create mode 100644 pyload/plugin/account/NetloadIn.py create mode 100644 pyload/plugin/account/NosuploadCom.py create mode 100644 pyload/plugin/account/NovafileCom.py create mode 100644 pyload/plugin/account/NowVideoAt.py create mode 100644 pyload/plugin/account/OboomCom.py create mode 100644 pyload/plugin/account/OneFichierCom.py create mode 100644 pyload/plugin/account/OverLoadMe.py create mode 100644 pyload/plugin/account/PremiumTo.py create mode 100644 pyload/plugin/account/PremiumizeMe.py create mode 100644 pyload/plugin/account/QuickshareCz.py create mode 100644 pyload/plugin/account/RPNetBiz.py create mode 100644 pyload/plugin/account/RapidfileshareNet.py create mode 100644 pyload/plugin/account/RapidgatorNet.py create mode 100644 pyload/plugin/account/RapiduNet.py create mode 100644 pyload/plugin/account/RarefileNet.py create mode 100644 pyload/plugin/account/RealdebridCom.py create mode 100644 pyload/plugin/account/RehostTo.py create mode 100644 pyload/plugin/account/RyushareCom.py create mode 100644 pyload/plugin/account/SafesharingEu.py create mode 100644 pyload/plugin/account/SecureUploadEu.py create mode 100644 pyload/plugin/account/SendmywayCom.py create mode 100644 pyload/plugin/account/ShareonlineBiz.py create mode 100644 pyload/plugin/account/SimplyPremiumCom.py create mode 100644 pyload/plugin/account/SimplydebridCom.py create mode 100644 pyload/plugin/account/StahnuTo.py create mode 100644 pyload/plugin/account/StreamcloudEu.py create mode 100644 pyload/plugin/account/TurbobitNet.py create mode 100644 pyload/plugin/account/TusfilesNet.py create mode 100644 pyload/plugin/account/UlozTo.py create mode 100644 pyload/plugin/account/UnrestrictLi.py create mode 100644 pyload/plugin/account/UploadcCom.py create mode 100644 pyload/plugin/account/UploadedTo.py create mode 100644 pyload/plugin/account/UploadheroCom.py create mode 100644 pyload/plugin/account/UploadingCom.py create mode 100644 pyload/plugin/account/UptoboxCom.py create mode 100644 pyload/plugin/account/VidPlayNet.py create mode 100644 pyload/plugin/account/XFileSharingPro.py create mode 100644 pyload/plugin/account/YibaishiwuCom.py create mode 100644 pyload/plugin/account/ZeveraCom.py create mode 100644 pyload/plugin/account/__init__.py create mode 100644 pyload/plugin/addon/Checksum.py create mode 100644 pyload/plugin/addon/ClickAndLoad.py create mode 100644 pyload/plugin/addon/DeleteFinished.py create mode 100644 pyload/plugin/addon/DownloadScheduler.py create mode 100644 pyload/plugin/addon/ExternalScripts.py create mode 100644 pyload/plugin/addon/ExtractArchive.py create mode 100644 pyload/plugin/addon/HotFolder.py create mode 100644 pyload/plugin/addon/IRCInterface.py create mode 100644 pyload/plugin/addon/MergeFiles.py create mode 100644 pyload/plugin/addon/MultiHome.py create mode 100644 pyload/plugin/addon/RestartFailed.py create mode 100644 pyload/plugin/addon/RestartSlow.py create mode 100644 pyload/plugin/addon/SkipRev.py create mode 100644 pyload/plugin/addon/UnSkipOnFail.py create mode 100644 pyload/plugin/addon/UpdateManager.py create mode 100644 pyload/plugin/addon/WindowsPhoneToastNotify.py create mode 100644 pyload/plugin/addon/XMPPInterface.py create mode 100644 pyload/plugin/addon/__init__.py create mode 100644 pyload/plugin/captcha/AdYouLike.py create mode 100644 pyload/plugin/captcha/AdsCaptcha.py create mode 100644 pyload/plugin/captcha/ReCaptcha.py create mode 100644 pyload/plugin/captcha/SolveMedia.py create mode 100644 pyload/plugin/captcha/__init__.py create mode 100644 pyload/plugin/container/CCF.py create mode 100644 pyload/plugin/container/LinkList.py create mode 100644 pyload/plugin/container/RSDF.py create mode 100644 pyload/plugin/container/__init__.py create mode 100644 pyload/plugin/crypter/BitshareCom.py create mode 100644 pyload/plugin/crypter/C1neonCom.py create mode 100644 pyload/plugin/crypter/ChipDe.py create mode 100644 pyload/plugin/crypter/CrockoCom.py create mode 100644 pyload/plugin/crypter/CryptItCom.py create mode 100644 pyload/plugin/crypter/CzshareCom.py create mode 100644 pyload/plugin/crypter/DDLMusicOrg.py create mode 100644 pyload/plugin/crypter/DailymotionBatch.py create mode 100644 pyload/plugin/crypter/DataHu.py create mode 100644 pyload/plugin/crypter/DdlstorageCom.py create mode 100644 pyload/plugin/crypter/DepositfilesCom.py create mode 100644 pyload/plugin/crypter/Dereferer.py create mode 100644 pyload/plugin/crypter/DevhostStFolder.py create mode 100644 pyload/plugin/crypter/DlProtectCom.py create mode 100644 pyload/plugin/crypter/DontKnowMe.py create mode 100644 pyload/plugin/crypter/DuckCryptInfo.py create mode 100644 pyload/plugin/crypter/DuploadOrg.py create mode 100644 pyload/plugin/crypter/EasybytezCom.py create mode 100644 pyload/plugin/crypter/EmbeduploadCom.py create mode 100644 pyload/plugin/crypter/FilebeerInfo.py create mode 100644 pyload/plugin/crypter/FilecloudIo.py create mode 100644 pyload/plugin/crypter/FilecryptCc.py create mode 100644 pyload/plugin/crypter/FilefactoryCom.py create mode 100644 pyload/plugin/crypter/FilerNet.py create mode 100644 pyload/plugin/crypter/FileserveCom.py create mode 100644 pyload/plugin/crypter/FilesonicCom.py create mode 100644 pyload/plugin/crypter/FilestubeCom.py create mode 100644 pyload/plugin/crypter/FiletramCom.py create mode 100644 pyload/plugin/crypter/FiredriveCom.py create mode 100644 pyload/plugin/crypter/FourChanOrg.py create mode 100644 pyload/plugin/crypter/FreakhareCom.py create mode 100644 pyload/plugin/crypter/FreetexthostCom.py create mode 100644 pyload/plugin/crypter/FshareVn.py create mode 100644 pyload/plugin/crypter/Go4UpCom.py create mode 100644 pyload/plugin/crypter/GooGl.py create mode 100644 pyload/plugin/crypter/HoerbuchIn.py create mode 100644 pyload/plugin/crypter/HotfileCom.py create mode 100644 pyload/plugin/crypter/ILoadTo.py create mode 100644 pyload/plugin/crypter/ImgurComAlbum.py create mode 100644 pyload/plugin/crypter/JunocloudMe.py create mode 100644 pyload/plugin/crypter/LetitbitNet.py create mode 100644 pyload/plugin/crypter/LinkCryptWs.py create mode 100644 pyload/plugin/crypter/LinkSaveIn.py create mode 100644 pyload/plugin/crypter/LinkdecrypterCom.py create mode 100644 pyload/plugin/crypter/LixIn.py create mode 100644 pyload/plugin/crypter/LofCc.py create mode 100644 pyload/plugin/crypter/MBLinkInfo.py create mode 100644 pyload/plugin/crypter/MediafireCom.py create mode 100644 pyload/plugin/crypter/MegaRapidCz.py create mode 100644 pyload/plugin/crypter/MegauploadCom.py create mode 100644 pyload/plugin/crypter/Movie2kTo.py create mode 100644 pyload/plugin/crypter/MultiUpOrg.py create mode 100644 pyload/plugin/crypter/MultiloadCz.py create mode 100644 pyload/plugin/crypter/MultiuploadCom.py create mode 100644 pyload/plugin/crypter/NCryptIn.py create mode 100644 pyload/plugin/crypter/NetfolderIn.py create mode 100644 pyload/plugin/crypter/NosvideoCom.py create mode 100644 pyload/plugin/crypter/OneKhDe.py create mode 100644 pyload/plugin/crypter/OronCom.py create mode 100644 pyload/plugin/crypter/PastebinCom.py create mode 100644 pyload/plugin/crypter/QuickshareCz.py create mode 100644 pyload/plugin/crypter/RSLayerCom.py create mode 100644 pyload/plugin/crypter/RapidfileshareNet.py create mode 100644 pyload/plugin/crypter/RelinkUs.py create mode 100644 pyload/plugin/crypter/SafelinkingNet.py create mode 100644 pyload/plugin/crypter/SecuredIn.py create mode 100644 pyload/plugin/crypter/SexuriaCom.py create mode 100644 pyload/plugin/crypter/ShareLinksBiz.py create mode 100644 pyload/plugin/crypter/SharingmatrixCom.py create mode 100644 pyload/plugin/crypter/SpeedLoadOrg.py create mode 100644 pyload/plugin/crypter/StealthTo.py create mode 100644 pyload/plugin/crypter/TnyCz.py create mode 100644 pyload/plugin/crypter/TrailerzoneInfo.py create mode 100644 pyload/plugin/crypter/TurbobitNet.py create mode 100644 pyload/plugin/crypter/TusfilesNet.py create mode 100644 pyload/plugin/crypter/UlozTo.py create mode 100644 pyload/plugin/crypter/UploadableCh.py create mode 100644 pyload/plugin/crypter/UploadedTo.py create mode 100644 pyload/plugin/crypter/WiiReloadedOrg.py create mode 100644 pyload/plugin/crypter/WuploadCom.py create mode 100644 pyload/plugin/crypter/XFileSharingPro.py create mode 100644 pyload/plugin/crypter/XupPl.py create mode 100644 pyload/plugin/crypter/YoutubeBatch.py create mode 100644 pyload/plugin/crypter/__init__.py create mode 100644 pyload/plugin/hook/AlldebridCom.py create mode 100644 pyload/plugin/hook/BypassCaptcha.py create mode 100644 pyload/plugin/hook/Captcha9kw.py create mode 100644 pyload/plugin/hook/CaptchaBrotherhood.py create mode 100644 pyload/plugin/hook/DeathByCaptcha.py create mode 100644 pyload/plugin/hook/DebridItaliaCom.py create mode 100644 pyload/plugin/hook/EasybytezCom.py create mode 100644 pyload/plugin/hook/ExpertDecoders.py create mode 100644 pyload/plugin/hook/FastixRu.py create mode 100644 pyload/plugin/hook/FreeWayMe.py create mode 100644 pyload/plugin/hook/ImageTyperz.py create mode 100644 pyload/plugin/hook/LinkdecrypterCom.py create mode 100644 pyload/plugin/hook/LinksnappyCom.py create mode 100644 pyload/plugin/hook/MegaDebridEu.py create mode 100644 pyload/plugin/hook/MultishareCz.py create mode 100644 pyload/plugin/hook/MyfastfileCom.py create mode 100644 pyload/plugin/hook/OverLoadMe.py create mode 100644 pyload/plugin/hook/PremiumTo.py create mode 100644 pyload/plugin/hook/PremiumizeMe.py create mode 100644 pyload/plugin/hook/RPNetBiz.py create mode 100644 pyload/plugin/hook/RealdebridCom.py create mode 100644 pyload/plugin/hook/RehostTo.py create mode 100644 pyload/plugin/hook/SimplyPremiumCom.py create mode 100644 pyload/plugin/hook/SimplydebridCom.py create mode 100644 pyload/plugin/hook/UnrestrictLi.py create mode 100644 pyload/plugin/hook/XFileSharingPro.py create mode 100644 pyload/plugin/hook/ZeveraCom.py create mode 100644 pyload/plugin/hook/__init__.py create mode 100644 pyload/plugin/hoster/AlldebridCom.py create mode 100644 pyload/plugin/hoster/BayfilesCom.py create mode 100644 pyload/plugin/hoster/BezvadataCz.py create mode 100644 pyload/plugin/hoster/BillionuploadsCom.py create mode 100644 pyload/plugin/hoster/BitshareCom.py create mode 100644 pyload/plugin/hoster/BoltsharingCom.py create mode 100644 pyload/plugin/hoster/CatShareNet.py create mode 100644 pyload/plugin/hoster/CloudzerNet.py create mode 100644 pyload/plugin/hoster/CramitIn.py create mode 100644 pyload/plugin/hoster/CrockoCom.py create mode 100644 pyload/plugin/hoster/CyberlockerCh.py create mode 100644 pyload/plugin/hoster/CzshareCom.py create mode 100644 pyload/plugin/hoster/DailymotionCom.py create mode 100644 pyload/plugin/hoster/DataHu.py create mode 100644 pyload/plugin/hoster/DataportCz.py create mode 100644 pyload/plugin/hoster/DateiTo.py create mode 100644 pyload/plugin/hoster/DdlstorageCom.py create mode 100644 pyload/plugin/hoster/DebridItaliaCom.py create mode 100644 pyload/plugin/hoster/DepositfilesCom.py create mode 100644 pyload/plugin/hoster/DevhostSt.py create mode 100644 pyload/plugin/hoster/DlFreeFr.py create mode 100644 pyload/plugin/hoster/DodanePl.py create mode 100644 pyload/plugin/hoster/DuploadOrg.py create mode 100644 pyload/plugin/hoster/EasybytezCom.py create mode 100644 pyload/plugin/hoster/EdiskCz.py create mode 100644 pyload/plugin/hoster/EgoFilesCom.py create mode 100644 pyload/plugin/hoster/EnteruploadCom.py create mode 100644 pyload/plugin/hoster/EpicShareNet.py create mode 100644 pyload/plugin/hoster/EuroshareEu.py create mode 100644 pyload/plugin/hoster/ExtabitCom.py create mode 100644 pyload/plugin/hoster/FastixRu.py create mode 100644 pyload/plugin/hoster/FastshareCz.py create mode 100644 pyload/plugin/hoster/FileApeCom.py create mode 100644 pyload/plugin/hoster/FileParadoxIn.py create mode 100644 pyload/plugin/hoster/FileSharkPl.py create mode 100644 pyload/plugin/hoster/FileStoreTo.py create mode 100644 pyload/plugin/hoster/FilebeerInfo.py create mode 100644 pyload/plugin/hoster/FilecloudIo.py create mode 100644 pyload/plugin/hoster/FilefactoryCom.py create mode 100644 pyload/plugin/hoster/FilejungleCom.py create mode 100644 pyload/plugin/hoster/FileomCom.py create mode 100644 pyload/plugin/hoster/FilepostCom.py create mode 100644 pyload/plugin/hoster/FilepupNet.py create mode 100644 pyload/plugin/hoster/FilerNet.py create mode 100644 pyload/plugin/hoster/FilerioCom.py create mode 100644 pyload/plugin/hoster/FilesMailRu.py create mode 100644 pyload/plugin/hoster/FileserveCom.py create mode 100644 pyload/plugin/hoster/FileshareInUa.py create mode 100644 pyload/plugin/hoster/FilesonicCom.py create mode 100644 pyload/plugin/hoster/FilezyNet.py create mode 100644 pyload/plugin/hoster/FiredriveCom.py create mode 100644 pyload/plugin/hoster/FlyFilesNet.py create mode 100644 pyload/plugin/hoster/FourSharedCom.py create mode 100644 pyload/plugin/hoster/FreakshareCom.py create mode 100644 pyload/plugin/hoster/FreeWayMe.py create mode 100644 pyload/plugin/hoster/FreevideoCz.py create mode 100644 pyload/plugin/hoster/FshareVn.py create mode 100644 pyload/plugin/hoster/Ftp.py create mode 100644 pyload/plugin/hoster/GamefrontCom.py create mode 100644 pyload/plugin/hoster/GigapetaCom.py create mode 100644 pyload/plugin/hoster/GooIm.py create mode 100644 pyload/plugin/hoster/HellshareCz.py create mode 100644 pyload/plugin/hoster/HellspyCz.py create mode 100644 pyload/plugin/hoster/HotfileCom.py create mode 100644 pyload/plugin/hoster/HugefilesNet.py create mode 100644 pyload/plugin/hoster/HundredEightyUploadCom.py create mode 100644 pyload/plugin/hoster/IFileWs.py create mode 100644 pyload/plugin/hoster/IcyFilesCom.py create mode 100644 pyload/plugin/hoster/IfileIt.py create mode 100644 pyload/plugin/hoster/IfolderRu.py create mode 100644 pyload/plugin/hoster/JumbofilesCom.py create mode 100644 pyload/plugin/hoster/JunocloudMe.py create mode 100644 pyload/plugin/hoster/Keep2shareCc.py create mode 100644 pyload/plugin/hoster/KickloadCom.py create mode 100644 pyload/plugin/hoster/KingfilesNet.py create mode 100644 pyload/plugin/hoster/LemUploadsCom.py create mode 100644 pyload/plugin/hoster/LetitbitNet.py create mode 100644 pyload/plugin/hoster/LinksnappyCom.py create mode 100644 pyload/plugin/hoster/LoadTo.py create mode 100644 pyload/plugin/hoster/LomafileCom.py create mode 100644 pyload/plugin/hoster/LuckyShareNet.py create mode 100644 pyload/plugin/hoster/MediafireCom.py create mode 100644 pyload/plugin/hoster/MegaCoNz.py create mode 100644 pyload/plugin/hoster/MegaDebridEu.py create mode 100644 pyload/plugin/hoster/MegaFilesSe.py create mode 100644 pyload/plugin/hoster/MegaRapidCz.py create mode 100644 pyload/plugin/hoster/MegacrypterCom.py create mode 100644 pyload/plugin/hoster/MegareleaseOrg.py create mode 100644 pyload/plugin/hoster/MegasharesCom.py create mode 100644 pyload/plugin/hoster/MegauploadCom.py create mode 100644 pyload/plugin/hoster/MegavideoCom.py create mode 100644 pyload/plugin/hoster/MovReelCom.py create mode 100644 pyload/plugin/hoster/MultishareCz.py create mode 100644 pyload/plugin/hoster/MyfastfileCom.py create mode 100644 pyload/plugin/hoster/MyvideoDe.py create mode 100644 pyload/plugin/hoster/NahrajCz.py create mode 100644 pyload/plugin/hoster/NarodRu.py create mode 100644 pyload/plugin/hoster/NetloadIn.py create mode 100644 pyload/plugin/hoster/NosuploadCom.py create mode 100644 pyload/plugin/hoster/NovafileCom.py create mode 100644 pyload/plugin/hoster/NowDownloadSx.py create mode 100644 pyload/plugin/hoster/NowVideoSx.py create mode 100644 pyload/plugin/hoster/OboomCom.py create mode 100644 pyload/plugin/hoster/OneFichierCom.py create mode 100644 pyload/plugin/hoster/OronCom.py create mode 100644 pyload/plugin/hoster/OverLoadMe.py create mode 100644 pyload/plugin/hoster/PandaplaNet.py create mode 100644 pyload/plugin/hoster/PornhostCom.py create mode 100644 pyload/plugin/hoster/PornhubCom.py create mode 100644 pyload/plugin/hoster/PotloadCom.py create mode 100644 pyload/plugin/hoster/PremiumTo.py create mode 100644 pyload/plugin/hoster/PremiumizeMe.py create mode 100644 pyload/plugin/hoster/PromptfileCom.py create mode 100644 pyload/plugin/hoster/PrzeklejPl.py create mode 100644 pyload/plugin/hoster/QuickshareCz.py create mode 100644 pyload/plugin/hoster/RPNetBiz.py create mode 100644 pyload/plugin/hoster/RapidfileshareNet.py create mode 100644 pyload/plugin/hoster/RapidgatorNet.py create mode 100644 pyload/plugin/hoster/RapiduNet.py create mode 100644 pyload/plugin/hoster/RarefileNet.py create mode 100644 pyload/plugin/hoster/RealdebridCom.py create mode 100644 pyload/plugin/hoster/RedtubeCom.py create mode 100644 pyload/plugin/hoster/RehostTo.py create mode 100644 pyload/plugin/hoster/RemixshareCom.py create mode 100644 pyload/plugin/hoster/RgHostNet.py create mode 100644 pyload/plugin/hoster/RyushareCom.py create mode 100644 pyload/plugin/hoster/SafesharingEu.py create mode 100644 pyload/plugin/hoster/SecureUploadEu.py create mode 100644 pyload/plugin/hoster/SendmywayCom.py create mode 100644 pyload/plugin/hoster/SendspaceCom.py create mode 100644 pyload/plugin/hoster/Share4webCom.py create mode 100644 pyload/plugin/hoster/Share76Com.py create mode 100644 pyload/plugin/hoster/ShareFilesCo.py create mode 100644 pyload/plugin/hoster/SharebeesCom.py create mode 100644 pyload/plugin/hoster/ShareonlineBiz.py create mode 100644 pyload/plugin/hoster/ShareplaceCom.py create mode 100644 pyload/plugin/hoster/SharingmatrixCom.py create mode 100644 pyload/plugin/hoster/ShragleCom.py create mode 100644 pyload/plugin/hoster/SimplyPremiumCom.py create mode 100644 pyload/plugin/hoster/SimplydebridCom.py create mode 100644 pyload/plugin/hoster/SockshareCom.py create mode 100644 pyload/plugin/hoster/SoundcloudCom.py create mode 100644 pyload/plugin/hoster/SpeedLoadOrg.py create mode 100644 pyload/plugin/hoster/SpeedfileCz.py create mode 100644 pyload/plugin/hoster/SpeedyshareCom.py create mode 100644 pyload/plugin/hoster/StorageTo.py create mode 100644 pyload/plugin/hoster/StreamCz.py create mode 100644 pyload/plugin/hoster/StreamcloudEu.py create mode 100644 pyload/plugin/hoster/TurbobitNet.py create mode 100644 pyload/plugin/hoster/TurbouploadCom.py create mode 100644 pyload/plugin/hoster/TusfilesNet.py create mode 100644 pyload/plugin/hoster/TwoSharedCom.py create mode 100644 pyload/plugin/hoster/UlozTo.py create mode 100644 pyload/plugin/hoster/UloziskoSk.py create mode 100644 pyload/plugin/hoster/UnibytesCom.py create mode 100644 pyload/plugin/hoster/UnrestrictLi.py create mode 100644 pyload/plugin/hoster/UpleaCom.py create mode 100644 pyload/plugin/hoster/UploadStationCom.py create mode 100644 pyload/plugin/hoster/UploadableCh.py create mode 100644 pyload/plugin/hoster/UploadboxCom.py create mode 100644 pyload/plugin/hoster/UploadedTo.py create mode 100644 pyload/plugin/hoster/UploadhereCom.py create mode 100644 pyload/plugin/hoster/UploadheroCom.py create mode 100644 pyload/plugin/hoster/UploadingCom.py create mode 100644 pyload/plugin/hoster/UploadkingCom.py create mode 100644 pyload/plugin/hoster/UpstoreNet.py create mode 100644 pyload/plugin/hoster/UptoboxCom.py create mode 100644 pyload/plugin/hoster/VeehdCom.py create mode 100644 pyload/plugin/hoster/VeohCom.py create mode 100644 pyload/plugin/hoster/VidPlayNet.py create mode 100644 pyload/plugin/hoster/VimeoCom.py create mode 100644 pyload/plugin/hoster/Vipleech4uCom.py create mode 100644 pyload/plugin/hoster/WarserverCz.py create mode 100644 pyload/plugin/hoster/WebshareCz.py create mode 100644 pyload/plugin/hoster/WrzucTo.py create mode 100644 pyload/plugin/hoster/WuploadCom.py create mode 100644 pyload/plugin/hoster/X7To.py create mode 100644 pyload/plugin/hoster/XFileSharingPro.py create mode 100644 pyload/plugin/hoster/XHamsterCom.py create mode 100644 pyload/plugin/hoster/XVideosCom.py create mode 100644 pyload/plugin/hoster/Xdcc.py create mode 100644 pyload/plugin/hoster/YibaishiwuCom.py create mode 100644 pyload/plugin/hoster/YoupornCom.py create mode 100644 pyload/plugin/hoster/YourfilesTo.py create mode 100644 pyload/plugin/hoster/YoutubeCom.py create mode 100644 pyload/plugin/hoster/ZDF.py create mode 100644 pyload/plugin/hoster/ZShareNet.py create mode 100644 pyload/plugin/hoster/ZeveraCom.py create mode 100644 pyload/plugin/hoster/ZippyshareCom.py create mode 100644 pyload/plugin/hoster/__init__.py create mode 100644 pyload/plugin/internal/AbstractExtractor.py create mode 100644 pyload/plugin/internal/BasePlugin.py create mode 100644 pyload/plugin/internal/DeadCrypter.py create mode 100644 pyload/plugin/internal/DeadHoster.py create mode 100644 pyload/plugin/internal/MultiHoster.py create mode 100644 pyload/plugin/internal/SimpleCrypter.py create mode 100644 pyload/plugin/internal/SimpleHoster.py create mode 100644 pyload/plugin/internal/UnRar.py create mode 100644 pyload/plugin/internal/UnZip.py create mode 100644 pyload/plugin/internal/UpdateManager.py create mode 100644 pyload/plugin/internal/XFSAccount.py create mode 100644 pyload/plugin/internal/XFSCrypter.py create mode 100644 pyload/plugin/internal/XFSHoster.py create mode 100644 pyload/plugin/internal/__init__.py create mode 100644 pyload/plugin/ocr/GigasizeCom.py create mode 100644 pyload/plugin/ocr/LinksaveIn.py create mode 100644 pyload/plugin/ocr/NetloadIn.py create mode 100644 pyload/plugin/ocr/ShareonlineBiz.py create mode 100644 pyload/plugin/ocr/__init__.py delete mode 100644 pyload/plugins/Account.py delete mode 100644 pyload/plugins/Addon.py delete mode 100644 pyload/plugins/Captcha.py delete mode 100644 pyload/plugins/Container.py delete mode 100644 pyload/plugins/Crypter.py delete mode 100644 pyload/plugins/Hoster.py delete mode 100644 pyload/plugins/OCR.py delete mode 100644 pyload/plugins/Plugin.py delete mode 100644 pyload/plugins/__init__.py delete mode 100644 pyload/plugins/account/AlldebridCom.py delete mode 100644 pyload/plugins/account/BayfilesCom.py delete mode 100644 pyload/plugins/account/BillionuploadsCom.py delete mode 100644 pyload/plugins/account/BitshareCom.py delete mode 100644 pyload/plugins/account/CatShareNet.py delete mode 100644 pyload/plugins/account/CramitIn.py delete mode 100644 pyload/plugins/account/CzshareCom.py delete mode 100644 pyload/plugins/account/DebridItaliaCom.py delete mode 100644 pyload/plugins/account/DepositfilesCom.py delete mode 100644 pyload/plugins/account/DropboxCom.py delete mode 100644 pyload/plugins/account/EasybytezCom.py delete mode 100644 pyload/plugins/account/EuroshareEu.py delete mode 100644 pyload/plugins/account/FastixRu.py delete mode 100644 pyload/plugins/account/FastshareCz.py delete mode 100644 pyload/plugins/account/File4safeCom.py delete mode 100644 pyload/plugins/account/FileParadoxIn.py delete mode 100644 pyload/plugins/account/FilecloudIo.py delete mode 100644 pyload/plugins/account/FilefactoryCom.py delete mode 100644 pyload/plugins/account/FilejungleCom.py delete mode 100644 pyload/plugins/account/FileomCom.py delete mode 100644 pyload/plugins/account/FilerNet.py delete mode 100644 pyload/plugins/account/FilerioCom.py delete mode 100644 pyload/plugins/account/FilesMailRu.py delete mode 100644 pyload/plugins/account/FileserveCom.py delete mode 100644 pyload/plugins/account/FourSharedCom.py delete mode 100644 pyload/plugins/account/FreakshareCom.py delete mode 100644 pyload/plugins/account/FreeWayMe.py delete mode 100644 pyload/plugins/account/FshareVn.py delete mode 100644 pyload/plugins/account/Ftp.py delete mode 100644 pyload/plugins/account/HellshareCz.py delete mode 100644 pyload/plugins/account/Http.py delete mode 100644 pyload/plugins/account/HugefilesNet.py delete mode 100644 pyload/plugins/account/HundredEightyUploadCom.py delete mode 100644 pyload/plugins/account/JunocloudMe.py delete mode 100644 pyload/plugins/account/Keep2shareCc.py delete mode 100644 pyload/plugins/account/LetitbitNet.py delete mode 100644 pyload/plugins/account/LinestorageCom.py delete mode 100644 pyload/plugins/account/LinksnappyCom.py delete mode 100644 pyload/plugins/account/LomafileCom.py delete mode 100644 pyload/plugins/account/MegaDebridEu.py delete mode 100644 pyload/plugins/account/MegaRapidCz.py delete mode 100644 pyload/plugins/account/MegasharesCom.py delete mode 100644 pyload/plugins/account/MovReelCom.py delete mode 100644 pyload/plugins/account/MultishareCz.py delete mode 100644 pyload/plugins/account/MyfastfileCom.py delete mode 100644 pyload/plugins/account/NetloadIn.py delete mode 100644 pyload/plugins/account/NosuploadCom.py delete mode 100644 pyload/plugins/account/NovafileCom.py delete mode 100644 pyload/plugins/account/NowVideoAt.py delete mode 100644 pyload/plugins/account/OboomCom.py delete mode 100644 pyload/plugins/account/OneFichierCom.py delete mode 100644 pyload/plugins/account/OverLoadMe.py delete mode 100644 pyload/plugins/account/PremiumTo.py delete mode 100644 pyload/plugins/account/PremiumizeMe.py delete mode 100644 pyload/plugins/account/QuickshareCz.py delete mode 100644 pyload/plugins/account/RPNetBiz.py delete mode 100644 pyload/plugins/account/RapidfileshareNet.py delete mode 100644 pyload/plugins/account/RapidgatorNet.py delete mode 100644 pyload/plugins/account/RapiduNet.py delete mode 100644 pyload/plugins/account/RarefileNet.py delete mode 100644 pyload/plugins/account/RealdebridCom.py delete mode 100644 pyload/plugins/account/RehostTo.py delete mode 100644 pyload/plugins/account/RyushareCom.py delete mode 100644 pyload/plugins/account/SafesharingEu.py delete mode 100644 pyload/plugins/account/SecureUploadEu.py delete mode 100644 pyload/plugins/account/SendmywayCom.py delete mode 100644 pyload/plugins/account/ShareonlineBiz.py delete mode 100644 pyload/plugins/account/SimplyPremiumCom.py delete mode 100644 pyload/plugins/account/SimplydebridCom.py delete mode 100644 pyload/plugins/account/StahnuTo.py delete mode 100644 pyload/plugins/account/StreamcloudEu.py delete mode 100644 pyload/plugins/account/TurbobitNet.py delete mode 100644 pyload/plugins/account/TusfilesNet.py delete mode 100644 pyload/plugins/account/UlozTo.py delete mode 100644 pyload/plugins/account/UnrestrictLi.py delete mode 100644 pyload/plugins/account/UploadcCom.py delete mode 100644 pyload/plugins/account/UploadedTo.py delete mode 100644 pyload/plugins/account/UploadheroCom.py delete mode 100644 pyload/plugins/account/UploadingCom.py delete mode 100644 pyload/plugins/account/UptoboxCom.py delete mode 100644 pyload/plugins/account/VidPlayNet.py delete mode 100644 pyload/plugins/account/XFileSharingPro.py delete mode 100644 pyload/plugins/account/YibaishiwuCom.py delete mode 100644 pyload/plugins/account/ZeveraCom.py delete mode 100644 pyload/plugins/account/__init__.py delete mode 100644 pyload/plugins/addon/Checksum.py delete mode 100644 pyload/plugins/addon/ClickAndLoad.py delete mode 100644 pyload/plugins/addon/DeleteFinished.py delete mode 100644 pyload/plugins/addon/DownloadScheduler.py delete mode 100644 pyload/plugins/addon/ExternalScripts.py delete mode 100644 pyload/plugins/addon/ExtractArchive.py delete mode 100644 pyload/plugins/addon/HotFolder.py delete mode 100644 pyload/plugins/addon/IRCInterface.py delete mode 100644 pyload/plugins/addon/MergeFiles.py delete mode 100644 pyload/plugins/addon/MultiHome.py delete mode 100644 pyload/plugins/addon/RestartFailed.py delete mode 100644 pyload/plugins/addon/RestartSlow.py delete mode 100644 pyload/plugins/addon/SkipRev.py delete mode 100644 pyload/plugins/addon/UnSkipOnFail.py delete mode 100644 pyload/plugins/addon/UpdateManager.py delete mode 100644 pyload/plugins/addon/WindowsPhoneToastNotify.py delete mode 100644 pyload/plugins/addon/XMPPInterface.py delete mode 100644 pyload/plugins/addon/__init__.py delete mode 100644 pyload/plugins/captcha/AdYouLike.py delete mode 100644 pyload/plugins/captcha/AdsCaptcha.py delete mode 100644 pyload/plugins/captcha/ReCaptcha.py delete mode 100644 pyload/plugins/captcha/SolveMedia.py delete mode 100644 pyload/plugins/captcha/__init__.py delete mode 100644 pyload/plugins/container/CCF.py delete mode 100644 pyload/plugins/container/LinkList.py delete mode 100644 pyload/plugins/container/RSDF.py delete mode 100644 pyload/plugins/container/__init__.py delete mode 100644 pyload/plugins/crypter/BitshareCom.py delete mode 100644 pyload/plugins/crypter/C1neonCom.py delete mode 100644 pyload/plugins/crypter/ChipDe.py delete mode 100644 pyload/plugins/crypter/CrockoCom.py delete mode 100644 pyload/plugins/crypter/CryptItCom.py delete mode 100644 pyload/plugins/crypter/CzshareCom.py delete mode 100644 pyload/plugins/crypter/DDLMusicOrg.py delete mode 100644 pyload/plugins/crypter/DailymotionBatch.py delete mode 100644 pyload/plugins/crypter/DataHu.py delete mode 100644 pyload/plugins/crypter/DdlstorageCom.py delete mode 100644 pyload/plugins/crypter/DepositfilesCom.py delete mode 100644 pyload/plugins/crypter/Dereferer.py delete mode 100644 pyload/plugins/crypter/DevhostStFolder.py delete mode 100644 pyload/plugins/crypter/DlProtectCom.py delete mode 100644 pyload/plugins/crypter/DontKnowMe.py delete mode 100644 pyload/plugins/crypter/DuckCryptInfo.py delete mode 100644 pyload/plugins/crypter/DuploadOrg.py delete mode 100644 pyload/plugins/crypter/EasybytezCom.py delete mode 100644 pyload/plugins/crypter/EmbeduploadCom.py delete mode 100644 pyload/plugins/crypter/FilebeerInfo.py delete mode 100644 pyload/plugins/crypter/FilecloudIo.py delete mode 100644 pyload/plugins/crypter/FilecryptCc.py delete mode 100644 pyload/plugins/crypter/FilefactoryCom.py delete mode 100644 pyload/plugins/crypter/FilerNet.py delete mode 100644 pyload/plugins/crypter/FileserveCom.py delete mode 100644 pyload/plugins/crypter/FilesonicCom.py delete mode 100644 pyload/plugins/crypter/FilestubeCom.py delete mode 100644 pyload/plugins/crypter/FiletramCom.py delete mode 100644 pyload/plugins/crypter/FiredriveCom.py delete mode 100644 pyload/plugins/crypter/FourChanOrg.py delete mode 100644 pyload/plugins/crypter/FreakhareCom.py delete mode 100644 pyload/plugins/crypter/FreetexthostCom.py delete mode 100644 pyload/plugins/crypter/FshareVn.py delete mode 100644 pyload/plugins/crypter/Go4UpCom.py delete mode 100644 pyload/plugins/crypter/GooGl.py delete mode 100644 pyload/plugins/crypter/HoerbuchIn.py delete mode 100644 pyload/plugins/crypter/HotfileCom.py delete mode 100644 pyload/plugins/crypter/ILoadTo.py delete mode 100644 pyload/plugins/crypter/ImgurComAlbum.py delete mode 100644 pyload/plugins/crypter/JunocloudMe.py delete mode 100644 pyload/plugins/crypter/LetitbitNet.py delete mode 100644 pyload/plugins/crypter/LinkCryptWs.py delete mode 100644 pyload/plugins/crypter/LinkSaveIn.py delete mode 100644 pyload/plugins/crypter/LinkdecrypterCom.py delete mode 100644 pyload/plugins/crypter/LixIn.py delete mode 100644 pyload/plugins/crypter/LofCc.py delete mode 100644 pyload/plugins/crypter/MBLinkInfo.py delete mode 100644 pyload/plugins/crypter/MediafireCom.py delete mode 100644 pyload/plugins/crypter/MegaRapidCz.py delete mode 100644 pyload/plugins/crypter/MegauploadCom.py delete mode 100644 pyload/plugins/crypter/Movie2kTo.py delete mode 100644 pyload/plugins/crypter/MultiUpOrg.py delete mode 100644 pyload/plugins/crypter/MultiloadCz.py delete mode 100644 pyload/plugins/crypter/MultiuploadCom.py delete mode 100644 pyload/plugins/crypter/NCryptIn.py delete mode 100644 pyload/plugins/crypter/NetfolderIn.py delete mode 100644 pyload/plugins/crypter/NosvideoCom.py delete mode 100644 pyload/plugins/crypter/OneKhDe.py delete mode 100644 pyload/plugins/crypter/OronCom.py delete mode 100644 pyload/plugins/crypter/PastebinCom.py delete mode 100644 pyload/plugins/crypter/QuickshareCz.py delete mode 100644 pyload/plugins/crypter/RSLayerCom.py delete mode 100644 pyload/plugins/crypter/RapidfileshareNet.py delete mode 100644 pyload/plugins/crypter/RelinkUs.py delete mode 100644 pyload/plugins/crypter/SafelinkingNet.py delete mode 100644 pyload/plugins/crypter/SecuredIn.py delete mode 100644 pyload/plugins/crypter/SexuriaCom.py delete mode 100644 pyload/plugins/crypter/ShareLinksBiz.py delete mode 100644 pyload/plugins/crypter/SharingmatrixCom.py delete mode 100644 pyload/plugins/crypter/SpeedLoadOrg.py delete mode 100644 pyload/plugins/crypter/StealthTo.py delete mode 100644 pyload/plugins/crypter/TnyCz.py delete mode 100644 pyload/plugins/crypter/TrailerzoneInfo.py delete mode 100644 pyload/plugins/crypter/TurbobitNet.py delete mode 100644 pyload/plugins/crypter/TusfilesNet.py delete mode 100644 pyload/plugins/crypter/UlozTo.py delete mode 100644 pyload/plugins/crypter/UploadableCh.py delete mode 100644 pyload/plugins/crypter/UploadedTo.py delete mode 100644 pyload/plugins/crypter/WiiReloadedOrg.py delete mode 100644 pyload/plugins/crypter/WuploadCom.py delete mode 100644 pyload/plugins/crypter/XFileSharingPro.py delete mode 100644 pyload/plugins/crypter/XupPl.py delete mode 100644 pyload/plugins/crypter/YoutubeBatch.py delete mode 100644 pyload/plugins/crypter/__init__.py delete mode 100644 pyload/plugins/hook/AlldebridCom.py delete mode 100644 pyload/plugins/hook/BypassCaptcha.py delete mode 100644 pyload/plugins/hook/Captcha9kw.py delete mode 100644 pyload/plugins/hook/CaptchaBrotherhood.py delete mode 100644 pyload/plugins/hook/DeathByCaptcha.py delete mode 100644 pyload/plugins/hook/DebridItaliaCom.py delete mode 100644 pyload/plugins/hook/EasybytezCom.py delete mode 100644 pyload/plugins/hook/ExpertDecoders.py delete mode 100644 pyload/plugins/hook/FastixRu.py delete mode 100644 pyload/plugins/hook/FreeWayMe.py delete mode 100644 pyload/plugins/hook/ImageTyperz.py delete mode 100644 pyload/plugins/hook/LinkdecrypterCom.py delete mode 100644 pyload/plugins/hook/LinksnappyCom.py delete mode 100644 pyload/plugins/hook/MegaDebridEu.py delete mode 100644 pyload/plugins/hook/MultishareCz.py delete mode 100644 pyload/plugins/hook/MyfastfileCom.py delete mode 100644 pyload/plugins/hook/OverLoadMe.py delete mode 100644 pyload/plugins/hook/PremiumTo.py delete mode 100644 pyload/plugins/hook/PremiumizeMe.py delete mode 100644 pyload/plugins/hook/RPNetBiz.py delete mode 100644 pyload/plugins/hook/RealdebridCom.py delete mode 100644 pyload/plugins/hook/RehostTo.py delete mode 100644 pyload/plugins/hook/SimplyPremiumCom.py delete mode 100644 pyload/plugins/hook/SimplydebridCom.py delete mode 100644 pyload/plugins/hook/UnrestrictLi.py delete mode 100644 pyload/plugins/hook/XFileSharingPro.py delete mode 100644 pyload/plugins/hook/ZeveraCom.py delete mode 100644 pyload/plugins/hook/__init__.py delete mode 100644 pyload/plugins/hoster/AlldebridCom.py delete mode 100644 pyload/plugins/hoster/BayfilesCom.py delete mode 100644 pyload/plugins/hoster/BezvadataCz.py delete mode 100644 pyload/plugins/hoster/BillionuploadsCom.py delete mode 100644 pyload/plugins/hoster/BitshareCom.py delete mode 100644 pyload/plugins/hoster/BoltsharingCom.py delete mode 100644 pyload/plugins/hoster/CatShareNet.py delete mode 100644 pyload/plugins/hoster/CloudzerNet.py delete mode 100644 pyload/plugins/hoster/CramitIn.py delete mode 100644 pyload/plugins/hoster/CrockoCom.py delete mode 100644 pyload/plugins/hoster/CyberlockerCh.py delete mode 100644 pyload/plugins/hoster/CzshareCom.py delete mode 100644 pyload/plugins/hoster/DailymotionCom.py delete mode 100644 pyload/plugins/hoster/DataHu.py delete mode 100644 pyload/plugins/hoster/DataportCz.py delete mode 100644 pyload/plugins/hoster/DateiTo.py delete mode 100644 pyload/plugins/hoster/DdlstorageCom.py delete mode 100644 pyload/plugins/hoster/DebridItaliaCom.py delete mode 100644 pyload/plugins/hoster/DepositfilesCom.py delete mode 100644 pyload/plugins/hoster/DevhostSt.py delete mode 100644 pyload/plugins/hoster/DlFreeFr.py delete mode 100644 pyload/plugins/hoster/DodanePl.py delete mode 100644 pyload/plugins/hoster/DuploadOrg.py delete mode 100644 pyload/plugins/hoster/EasybytezCom.py delete mode 100644 pyload/plugins/hoster/EdiskCz.py delete mode 100644 pyload/plugins/hoster/EgoFilesCom.py delete mode 100644 pyload/plugins/hoster/EnteruploadCom.py delete mode 100644 pyload/plugins/hoster/EpicShareNet.py delete mode 100644 pyload/plugins/hoster/EuroshareEu.py delete mode 100644 pyload/plugins/hoster/ExtabitCom.py delete mode 100644 pyload/plugins/hoster/FastixRu.py delete mode 100644 pyload/plugins/hoster/FastshareCz.py delete mode 100644 pyload/plugins/hoster/FileApeCom.py delete mode 100644 pyload/plugins/hoster/FileParadoxIn.py delete mode 100644 pyload/plugins/hoster/FileSharkPl.py delete mode 100644 pyload/plugins/hoster/FileStoreTo.py delete mode 100644 pyload/plugins/hoster/FilebeerInfo.py delete mode 100644 pyload/plugins/hoster/FilecloudIo.py delete mode 100644 pyload/plugins/hoster/FilefactoryCom.py delete mode 100644 pyload/plugins/hoster/FilejungleCom.py delete mode 100644 pyload/plugins/hoster/FileomCom.py delete mode 100644 pyload/plugins/hoster/FilepostCom.py delete mode 100644 pyload/plugins/hoster/FilepupNet.py delete mode 100644 pyload/plugins/hoster/FilerNet.py delete mode 100644 pyload/plugins/hoster/FilerioCom.py delete mode 100644 pyload/plugins/hoster/FilesMailRu.py delete mode 100644 pyload/plugins/hoster/FileserveCom.py delete mode 100644 pyload/plugins/hoster/FileshareInUa.py delete mode 100644 pyload/plugins/hoster/FilesonicCom.py delete mode 100644 pyload/plugins/hoster/FilezyNet.py delete mode 100644 pyload/plugins/hoster/FiredriveCom.py delete mode 100644 pyload/plugins/hoster/FlyFilesNet.py delete mode 100644 pyload/plugins/hoster/FourSharedCom.py delete mode 100644 pyload/plugins/hoster/FreakshareCom.py delete mode 100644 pyload/plugins/hoster/FreeWayMe.py delete mode 100644 pyload/plugins/hoster/FreevideoCz.py delete mode 100644 pyload/plugins/hoster/FshareVn.py delete mode 100644 pyload/plugins/hoster/Ftp.py delete mode 100644 pyload/plugins/hoster/GamefrontCom.py delete mode 100644 pyload/plugins/hoster/GigapetaCom.py delete mode 100644 pyload/plugins/hoster/GooIm.py delete mode 100644 pyload/plugins/hoster/HellshareCz.py delete mode 100644 pyload/plugins/hoster/HellspyCz.py delete mode 100644 pyload/plugins/hoster/HotfileCom.py delete mode 100644 pyload/plugins/hoster/HugefilesNet.py delete mode 100644 pyload/plugins/hoster/HundredEightyUploadCom.py delete mode 100644 pyload/plugins/hoster/IFileWs.py delete mode 100644 pyload/plugins/hoster/IcyFilesCom.py delete mode 100644 pyload/plugins/hoster/IfileIt.py delete mode 100644 pyload/plugins/hoster/IfolderRu.py delete mode 100644 pyload/plugins/hoster/JumbofilesCom.py delete mode 100644 pyload/plugins/hoster/JunocloudMe.py delete mode 100644 pyload/plugins/hoster/Keep2shareCc.py delete mode 100644 pyload/plugins/hoster/KickloadCom.py delete mode 100644 pyload/plugins/hoster/KingfilesNet.py delete mode 100644 pyload/plugins/hoster/LemUploadsCom.py delete mode 100644 pyload/plugins/hoster/LetitbitNet.py delete mode 100644 pyload/plugins/hoster/LinksnappyCom.py delete mode 100644 pyload/plugins/hoster/LoadTo.py delete mode 100644 pyload/plugins/hoster/LomafileCom.py delete mode 100644 pyload/plugins/hoster/LuckyShareNet.py delete mode 100644 pyload/plugins/hoster/MediafireCom.py delete mode 100644 pyload/plugins/hoster/MegaCoNz.py delete mode 100644 pyload/plugins/hoster/MegaDebridEu.py delete mode 100644 pyload/plugins/hoster/MegaFilesSe.py delete mode 100644 pyload/plugins/hoster/MegaRapidCz.py delete mode 100644 pyload/plugins/hoster/MegacrypterCom.py delete mode 100644 pyload/plugins/hoster/MegareleaseOrg.py delete mode 100644 pyload/plugins/hoster/MegasharesCom.py delete mode 100644 pyload/plugins/hoster/MegauploadCom.py delete mode 100644 pyload/plugins/hoster/MegavideoCom.py delete mode 100644 pyload/plugins/hoster/MovReelCom.py delete mode 100644 pyload/plugins/hoster/MultishareCz.py delete mode 100644 pyload/plugins/hoster/MyfastfileCom.py delete mode 100644 pyload/plugins/hoster/MyvideoDe.py delete mode 100644 pyload/plugins/hoster/NahrajCz.py delete mode 100644 pyload/plugins/hoster/NarodRu.py delete mode 100644 pyload/plugins/hoster/NetloadIn.py delete mode 100644 pyload/plugins/hoster/NosuploadCom.py delete mode 100644 pyload/plugins/hoster/NovafileCom.py delete mode 100644 pyload/plugins/hoster/NowDownloadSx.py delete mode 100644 pyload/plugins/hoster/NowVideoSx.py delete mode 100644 pyload/plugins/hoster/OboomCom.py delete mode 100644 pyload/plugins/hoster/OneFichierCom.py delete mode 100644 pyload/plugins/hoster/OronCom.py delete mode 100644 pyload/plugins/hoster/OverLoadMe.py delete mode 100644 pyload/plugins/hoster/PandaplaNet.py delete mode 100644 pyload/plugins/hoster/PornhostCom.py delete mode 100644 pyload/plugins/hoster/PornhubCom.py delete mode 100644 pyload/plugins/hoster/PotloadCom.py delete mode 100644 pyload/plugins/hoster/PremiumTo.py delete mode 100644 pyload/plugins/hoster/PremiumizeMe.py delete mode 100644 pyload/plugins/hoster/PromptfileCom.py delete mode 100644 pyload/plugins/hoster/PrzeklejPl.py delete mode 100644 pyload/plugins/hoster/QuickshareCz.py delete mode 100644 pyload/plugins/hoster/RPNetBiz.py delete mode 100644 pyload/plugins/hoster/RapidfileshareNet.py delete mode 100644 pyload/plugins/hoster/RapidgatorNet.py delete mode 100644 pyload/plugins/hoster/RapiduNet.py delete mode 100644 pyload/plugins/hoster/RarefileNet.py delete mode 100644 pyload/plugins/hoster/RealdebridCom.py delete mode 100644 pyload/plugins/hoster/RedtubeCom.py delete mode 100644 pyload/plugins/hoster/RehostTo.py delete mode 100644 pyload/plugins/hoster/RemixshareCom.py delete mode 100644 pyload/plugins/hoster/RgHostNet.py delete mode 100644 pyload/plugins/hoster/RyushareCom.py delete mode 100644 pyload/plugins/hoster/SafesharingEu.py delete mode 100644 pyload/plugins/hoster/SecureUploadEu.py delete mode 100644 pyload/plugins/hoster/SendmywayCom.py delete mode 100644 pyload/plugins/hoster/SendspaceCom.py delete mode 100644 pyload/plugins/hoster/Share4webCom.py delete mode 100644 pyload/plugins/hoster/Share76Com.py delete mode 100644 pyload/plugins/hoster/ShareFilesCo.py delete mode 100644 pyload/plugins/hoster/SharebeesCom.py delete mode 100644 pyload/plugins/hoster/ShareonlineBiz.py delete mode 100644 pyload/plugins/hoster/ShareplaceCom.py delete mode 100644 pyload/plugins/hoster/SharingmatrixCom.py delete mode 100644 pyload/plugins/hoster/ShragleCom.py delete mode 100644 pyload/plugins/hoster/SimplyPremiumCom.py delete mode 100644 pyload/plugins/hoster/SimplydebridCom.py delete mode 100644 pyload/plugins/hoster/SockshareCom.py delete mode 100644 pyload/plugins/hoster/SoundcloudCom.py delete mode 100644 pyload/plugins/hoster/SpeedLoadOrg.py delete mode 100644 pyload/plugins/hoster/SpeedfileCz.py delete mode 100644 pyload/plugins/hoster/SpeedyshareCom.py delete mode 100644 pyload/plugins/hoster/StorageTo.py delete mode 100644 pyload/plugins/hoster/StreamCz.py delete mode 100644 pyload/plugins/hoster/StreamcloudEu.py delete mode 100644 pyload/plugins/hoster/TurbobitNet.py delete mode 100644 pyload/plugins/hoster/TurbouploadCom.py delete mode 100644 pyload/plugins/hoster/TusfilesNet.py delete mode 100644 pyload/plugins/hoster/TwoSharedCom.py delete mode 100644 pyload/plugins/hoster/UlozTo.py delete mode 100644 pyload/plugins/hoster/UloziskoSk.py delete mode 100644 pyload/plugins/hoster/UnibytesCom.py delete mode 100644 pyload/plugins/hoster/UnrestrictLi.py delete mode 100644 pyload/plugins/hoster/UpleaCom.py delete mode 100644 pyload/plugins/hoster/UploadStationCom.py delete mode 100644 pyload/plugins/hoster/UploadableCh.py delete mode 100644 pyload/plugins/hoster/UploadboxCom.py delete mode 100644 pyload/plugins/hoster/UploadedTo.py delete mode 100644 pyload/plugins/hoster/UploadhereCom.py delete mode 100644 pyload/plugins/hoster/UploadheroCom.py delete mode 100644 pyload/plugins/hoster/UploadingCom.py delete mode 100644 pyload/plugins/hoster/UploadkingCom.py delete mode 100644 pyload/plugins/hoster/UpstoreNet.py delete mode 100644 pyload/plugins/hoster/UptoboxCom.py delete mode 100644 pyload/plugins/hoster/VeehdCom.py delete mode 100644 pyload/plugins/hoster/VeohCom.py delete mode 100644 pyload/plugins/hoster/VidPlayNet.py delete mode 100644 pyload/plugins/hoster/VimeoCom.py delete mode 100644 pyload/plugins/hoster/Vipleech4uCom.py delete mode 100644 pyload/plugins/hoster/WarserverCz.py delete mode 100644 pyload/plugins/hoster/WebshareCz.py delete mode 100644 pyload/plugins/hoster/WrzucTo.py delete mode 100644 pyload/plugins/hoster/WuploadCom.py delete mode 100644 pyload/plugins/hoster/X7To.py delete mode 100644 pyload/plugins/hoster/XFileSharingPro.py delete mode 100644 pyload/plugins/hoster/XHamsterCom.py delete mode 100644 pyload/plugins/hoster/XVideosCom.py delete mode 100644 pyload/plugins/hoster/Xdcc.py delete mode 100644 pyload/plugins/hoster/YibaishiwuCom.py delete mode 100644 pyload/plugins/hoster/YoupornCom.py delete mode 100644 pyload/plugins/hoster/YourfilesTo.py delete mode 100644 pyload/plugins/hoster/YoutubeCom.py delete mode 100644 pyload/plugins/hoster/ZDF.py delete mode 100644 pyload/plugins/hoster/ZShareNet.py delete mode 100644 pyload/plugins/hoster/ZeveraCom.py delete mode 100644 pyload/plugins/hoster/ZippyshareCom.py delete mode 100644 pyload/plugins/hoster/__init__.py delete mode 100644 pyload/plugins/internal/AbstractExtractor.py delete mode 100644 pyload/plugins/internal/BasePlugin.py delete mode 100644 pyload/plugins/internal/DeadCrypter.py delete mode 100644 pyload/plugins/internal/DeadHoster.py delete mode 100644 pyload/plugins/internal/MultiHoster.py delete mode 100644 pyload/plugins/internal/SimpleCrypter.py delete mode 100644 pyload/plugins/internal/SimpleHoster.py delete mode 100644 pyload/plugins/internal/UnRar.py delete mode 100644 pyload/plugins/internal/UnZip.py delete mode 100644 pyload/plugins/internal/UpdateManager.py delete mode 100644 pyload/plugins/internal/XFSAccount.py delete mode 100644 pyload/plugins/internal/XFSCrypter.py delete mode 100644 pyload/plugins/internal/XFSHoster.py delete mode 100644 pyload/plugins/internal/__init__.py delete mode 100644 pyload/plugins/ocr/GigasizeCom.py delete mode 100644 pyload/plugins/ocr/LinksaveIn.py delete mode 100644 pyload/plugins/ocr/NetloadIn.py delete mode 100644 pyload/plugins/ocr/ShareonlineBiz.py delete mode 100644 pyload/plugins/ocr/__init__.py delete mode 100644 setup.cfg diff --git a/.gitignore b/.gitignore index c390d413f..ebd084ced 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,6 @@ parts/ sdist/ var/ temp/ -!/pyload/lib/ # Common directories .*/ diff --git a/docs/build_docs.py b/docs/build_docs.py index 3287fce8d..d4822ef94 100644 --- a/docs/build_docs.py +++ b/docs/build_docs.py @@ -12,12 +12,18 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import sys, os -from os.path import dirname, join, abspath +import os +import platform +import sys + + +dir_name = os.path.join(os.path.dirname(os.path.abspath(""))) -dir_name = join(dirname(abspath(""))) sys.path.append(dir_name) -sys.path.append(join(dir_name, "pyload", "lib")) + +if "64" in platform.machine(): + sys.path.append(os.path.join(os.path.dirname, "lib64")) +sys.path.append(os.path.join(os.path.dirname, "lib")) # If extensions (or modules to document with autodoc) are in another directory, @@ -131,12 +137,12 @@ html_theme = 'default' # The name of an image file (relative to this directory) to place at the top # of the sidebar. -html_logo = join(dir_name, "pyload", "web", "media", "default", "img", "pyload-logo-edited3.5-new-font-small.png") +html_logo = os.path.join(dir_name, "pyload", "web", "media", "default", "img", "pyload-logo-edited3.5-new-font-small.png") # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. -html_favicon = join(dir_name, "docs", "resources", "icon.ico") +html_favicon = os.path.join(dir_name, "docs", "resources", "icon.ico") # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, diff --git a/docs/docs.conf b/docs/docs.conf index 749e09212..51bab49fb 100644 --- a/docs/docs.conf +++ b/docs/docs.conf @@ -8,7 +8,7 @@ output: html target: docs docformat: restructuredtext -exclude: pyload\.lib|pyload\.remote\.thriftbackend\.thriftgen|\.pyc|\.pyo|pyload\.plugins\.(account|addon|base|container|crypter|hook|hoster|internal|ocr) +exclude: remote\thriftbackend\thriftgen|plugin\(account|addon|container|crypter|hook|hoster|internal|ocr)|.pyc|.pyo name: pyLoad Documentation url: http://docs.pyload.org diff --git a/docs/module_overview.rst b/docs/module_overview.rst index fce9ecfca..9a2d445b6 100644 --- a/docs/module_overview.rst +++ b/docs/module_overview.rst @@ -9,11 +9,11 @@ You can find an overview of some important classes here: :toctree: pyload pyload.api.Api - pyload.plugins.Plugin.Base - pyload.plugins.Plugin.Plugin - pyload.plugins.Crypter.Crypter - pyload.plugins.Account.Account - pyload.plugins.Addon.Addon - pyload.manager.AddonManager.AddonManager + pyload.plugin.Plugin.Base + pyload.plugin.Plugin.Plugin + pyload.plugin.Crypter.Crypter + pyload.plugin.Account.Account + pyload.plugin.Addon.Addon + pyload.manager.Addon.AddonManager pyload.datatypes.PyFile.PyFile pyload.datatypes.PyPackage.PyPackage diff --git a/docs/setup.cfg b/docs/setup.cfg new file mode 100644 index 000000000..51c054a75 --- /dev/null +++ b/docs/setup.cfg @@ -0,0 +1,7 @@ +[build_sphinx] +source-dir = doc +build-dir = doc/_build +all_files = 1 + +[upload_sphinx] +upload-dir = doc/_build/html diff --git a/docs/write_addons.rst b/docs/write_addons.rst index c9f050ebc..7607560ff 100644 --- a/docs/write_addons.rst +++ b/docs/write_addons.rst @@ -3,20 +3,20 @@ Addons ====== -A Addon is a python file which is located at :file:`pyload/plugins/addon`. -The :class:`AddonManager ` will load it automatically on startup. Only one instance exists -over the complete lifetime of pyload. Your addon can interact on various events called by the :class:`AddonManager `, +A Addon is a python file which is located at :file:`pyload/plugin/addon`. +The :class:`AddonManager ` will load it automatically on startup. Only one instance exists +over the complete lifetime of pyload. Your addon can interact on various events called by the :class:`AddonManager `, do something complete autonomic and has full access to the :class:`Api ` and every detail of pyLoad. The UpdateManager, CaptchaTrader, UnRar and many more are realised as addon. Addon header ----------- -Your addon needs to subclass :class:`Addon ` and will inherit all of its method, make sure to check its documentation! +Your addon needs to subclass :class:`Addon ` and will inherit all of its method, make sure to check its documentation! All addons should start with something like this: :: - from pyload.plugins.Addon import Addon + from pyload.plugin.Addon import Addon class YourAddon(Addon): __name__ = "YourAddon" @@ -42,16 +42,16 @@ Interacting on Events The next step is to think about where your Addon action takes places. -The easiest way is to overwrite specific methods defined by the :class:`Addon ` base class. +The easiest way is to overwrite specific methods defined by the :class:`Addon ` base class. The name is indicating when the function gets called. -See :class:`Addon ` page for a complete listing. +See :class:`Addon ` page for a complete listing. -You should be aware of the arguments the Addon is called with, whether its a :class:`PyFile ` -or :class:`PyPackage ` you should read its related documentation to know how to access her great power and manipulate them. +You should be aware of the arguments the Addon is called with, whether its a :class:`PyFile ` +or :class:`PyPackage ` you should read its related documentation to know how to access her great power and manipulate them. A basic excerpt would look like: :: - from pyload.plugins.Addon import Addon + from pyload.plugin.Addon import Addon class YourAddon(Addon): """ @@ -66,12 +66,12 @@ A basic excerpt would look like: :: Another and more flexible and powerful way is to use event listener. All addon methods exists as event and very useful additional events are dispatched by the core. For a little overview look -at :class:`AddonManager `. Keep in mind that you can define own events and other people may listen on them. +at :class:`AddonManager `. Keep in mind that you can define own events and other people may listen on them. For your convenience it's possible to register listeners automatical via the ``event_map`` attribute. It requires a `dict` that maps event names to function names or a `list` of function names. It's important that all names are strings :: - from pyload.plugins.Addon import Addon + from pyload.plugin.Addon import Addon class YourAddon(Addon): """ @@ -92,7 +92,7 @@ It requires a `dict` that maps event names to function names or a `list` of func An advantage of the event listener is that you are able to register and remove the listeners at runtime. Use `self.manager.addEvent("name", function)`, `self.manager.removeEvent("name", function)` and see doc for -:class:`AddonManager `. Contrary to ``event_map``, ``function`` has to be a reference +:class:`AddonManager `. Contrary to ``event_map``, ``function`` has to be a reference and **not** a `string`. We introduced events because it scales better if there a a huge amount of events and addons. So all future interaction will be exclusive @@ -107,7 +107,7 @@ So probably clients want to be able to interact with your addon to request it's Sounds complicated but is very easy to do. Just use the ``Expose`` decorator: :: - from pyload.plugins.Addon import Addon, Expose + from pyload.plugin.Addon import Addon, Expose class YourAddon(Addon): """ @@ -132,7 +132,7 @@ Your addon can store information in a ``dict`` that can easily be retrievied via Just store everything in ``self.info``. :: - from pyload.plugins.Addon import Addon + from pyload.plugin.Addon import Addon class YourAddon(Addon): """ @@ -155,4 +155,4 @@ Example ------- Sorry but you won't find an example here ;-) - Look at :file:`pyload/plugins/addon` and you will find plenty examples there. + Look at :file:`pyload/plugin/addon` and you will find plenty examples there. diff --git a/docs/write_plugins.rst b/docs/write_plugins.rst index f624b2fb5..7820e5ce6 100644 --- a/docs/write_plugins.rst +++ b/docs/write_plugins.rst @@ -3,11 +3,11 @@ Plugins ======= -A Plugin is a python file located at one of the subfolders in :file:`pyload/plugins/`. Either :file:`hoster`, :file:`crypter` +A Plugin is a python file located at one of the subfolders in :file:`pyload/plugin/`. Either :file:`hoster`, :file:`crypter` or :file:`container`, depending of it's type. There are three kinds of different plugins: **Hoster**, **Crypter**, **Container**. -All kind of plugins inherit from the base :class:`Plugin `. You should know its +All kind of plugins inherit from the base :class:`Plugin `. You should know its convenient methods, they make your work easier ;-) Every plugin defines a ``__pattern__`` and when the user adds urls, every url is matched against the pattern defined in @@ -19,7 +19,7 @@ Plugin header How basic hoster plugin header could look like: :: - from pyload.plugins.Hoster import Hoster + from pyload.plugin.Hoster import Hoster class MyFileHoster(Hoster): __name__ = "MyFileHoster" @@ -41,7 +41,7 @@ We head to the next important section, the ``process`` method of your plugin. In fact the ``process`` method is the only functionality your plugin has to provide, but its always a good idea to split up tasks to not produce spaghetti code. An example ``process`` function could look like this :: - from pyload.plugins.Hoster import Hoster + from pyload.plugin.Hoster import Hoster class MyFileHoster(Hoster): """ @@ -58,7 +58,7 @@ An example ``process`` function could look like this :: # download the file, destination is determined by pyLoad self.download(parsed_url) -You need to know about the :class:`PyFile ` class, since an instance of it is given as parameter to every pyfile. +You need to know about the :class:`PyFile ` class, since an instance of it is given as parameter to every pyfile. Some tasks your plugin should handle: proof if file is online, get filename, wait if needed, download the file, etc.. Wait times @@ -71,7 +71,7 @@ Captcha decrypting __________________ To handle captcha input just use ``self.decryptCaptcha(url, ...)``, it will be send to clients -or handled by :class:`Addon ` plugins +or handled by :class:`Addon ` plugins Crypter ------- @@ -81,7 +81,7 @@ Well, they work nearly the same, only that the function they have to provide is Example: :: - from pyload.plugins.Crypter import Crypter + from pyload.plugin.Crypter import Crypter class MyFileCrypter(Crypter): """ @@ -93,11 +93,11 @@ Example: :: self.packages.append(("pyLoad packages", urls, "pyLoad packages")) # urls list of urls -They can access all the methods from :class:`Plugin `, but the important thing is they +They can access all the methods from :class:`Plugin `, but the important thing is they have to append all packages they parsed to the `self.packages` list. Simply append tuples with `(name, urls, folder)`, where urls is the list of urls contained in the packages. Thats all of your work, pyLoad will know what to do with them. Examples -------- -Best examples are already existing plugins in :file:`pyload/plugins/`. +Best examples are already existing plugins in :file:`pyload/plugin/`. diff --git a/locale/core.pot b/locale/core.pot index 47550a6aa..028c0c14e 100644 --- a/locale/core.pot +++ b/locale/core.pot @@ -214,8 +214,8 @@ msgstr "" msgid "unknown" msgstr "" -#: pyload/database/FileDatabase.py:531 pyload/plugins/hooks/IRCInterface.py:74 -#: pyload/plugins/hooks/XMPPInterface.py:83 +#: pyload/database/FileDatabase.py:531 pyload/plugin/hooks/IRCInterface.py:74 +#: pyload/plugin/hooks/XMPPInterface.py:83 #, python-format msgid "Package finished: %s" msgstr "" @@ -283,7 +283,7 @@ msgid "" msgstr "" #: pyload/threads/ServerThread.py:60 -msgid "Copy the boern.so to pyload/lib folder or use setup.py install" +msgid "Copy the boern.so to the lib folder or use setup.py install" msgstr "" #: pyload/threads/ServerThread.py:61 @@ -420,7 +420,7 @@ msgstr "" msgid "Info Fetching for %(name)s failed | %(err)s" msgstr "" -#: pyload/HookManager.py:90 pyload/plugins/Hook.py:103 +#: pyload/HookManager.py:90 pyload/plugin/Hook.py:103 #, python-format msgid "Error executing hooks: %s" msgstr "" @@ -466,414 +466,414 @@ msgstr "" msgid "Not enough space left on device" msgstr "" -#: pyload/plugins/Account.py:85 pyload/plugins/Account.py:90 +#: pyload/plugin/Account.py:85 pyload/plugin/Account.py:90 #, python-format msgid "Could not login with account %(user)s | %(msg)s" msgstr "" -#: pyload/plugins/Account.py:86 +#: pyload/plugin/Account.py:86 msgid "Wrong Password" msgstr "" -#: pyload/plugins/Account.py:243 +#: pyload/plugin/Account.py:243 #, python-format msgid "Your Time %s has wrong format, use: 1:22-3:44" msgstr "" -#: pyload/plugins/Account.py:269 +#: pyload/plugin/Account.py:269 #, python-format msgid "Account %s has not enough traffic, checking again in 30min" msgstr "" -#: pyload/plugins/Account.py:276 +#: pyload/plugin/Account.py:276 #, python-format msgid "Account %s is expired, checking again in 1h" msgstr "" -#: pyload/plugins/crypter/SerienjunkiesOrg.py:126 +#: pyload/plugin/crypter/SerienjunkiesOrg.py:126 msgid "Downloadlimit reached" msgstr "" -#: pyload/plugins/PluginManager.py:153 +#: pyload/plugin/PluginManager.py:153 #, python-format msgid "%s has a invalid pattern." msgstr "" -#: pyload/plugins/PluginManager.py:272 +#: pyload/plugin/PluginManager.py:272 #, python-format msgid "Error importing %(name)s: %(msg)s" msgstr "" -#: pyload/plugins/internal/MultiHoster.py:132 +#: pyload/plugin/internal/MultiHoster.py:132 msgid "No Hoster loaded" msgstr "" -#: pyload/plugins/accounts/BitshareCom.py:38 +#: pyload/plugin/accounts/BitshareCom.py:38 msgid "Activate direct Download in your Bitshare Account" msgstr "" -#: pyload/plugins/container/LinkList.py:64 +#: pyload/plugin/container/LinkList.py:64 msgid "LinkList could not be cleared." msgstr "" -#: pyload/plugins/AccountManager.py:88 +#: pyload/plugin/AccountManager.py:88 msgid "Account settings deleted, due to new config format." msgstr "" -#: pyload/plugins/hoster/BasePlugin.py:65 +#: pyload/plugin/hoster/BasePlugin.py:65 msgid "Authorization required (username:password)" msgstr "" -#: pyload/plugins/hoster/SimplydebridCom.py:23 -#: pyload/plugins/hoster/RealdebridCom.py:40 -#: pyload/plugins/hoster/FreeWayMe.py:39 pyload/plugins/hoster/ZeveraCom.py:21 -#: pyload/plugins/hoster/UnrestrictLi.py:52 -#: pyload/plugins/hoster/Vipleech4uCom.py:30 -#: pyload/plugins/hoster/Premium4Me.py:27 pyload/plugins/hoster/FastixRu.py:36 -#: pyload/plugins/hoster/SimplyPremiumCom.py:52 -#: pyload/plugins/hoster/MegaDebridEu.py:46 -#: pyload/plugins/hoster/AlldebridCom.py:38 -#: pyload/plugins/hoster/LinksnappyCom.py:29 -#: pyload/plugins/hoster/DebridItaliaCom.py:39 -#: pyload/plugins/hoster/RPNetBiz.py:28 -#: pyload/plugins/hoster/MultiDebridCom.py:40 -#: pyload/plugins/hoster/ReloadCc.py:26 pyload/plugins/hoster/OverLoadMe.py:38 -#: pyload/plugins/hoster/RehostTo.py:25 -#: pyload/plugins/hoster/PremiumizeMe.py:24 -#: pyload/plugins/hooks/RPNetBiz.py:45 +#: pyload/plugin/hoster/SimplydebridCom.py:23 +#: pyload/plugin/hoster/RealdebridCom.py:40 +#: pyload/plugin/hoster/FreeWayMe.py:39 pyload/plugin/hoster/ZeveraCom.py:21 +#: pyload/plugin/hoster/UnrestrictLi.py:52 +#: pyload/plugin/hoster/Vipleech4uCom.py:30 +#: pyload/plugin/hoster/Premium4Me.py:27 pyload/plugin/hoster/FastixRu.py:36 +#: pyload/plugin/hoster/SimplyPremiumCom.py:52 +#: pyload/plugin/hoster/MegaDebridEu.py:46 +#: pyload/plugin/hoster/AlldebridCom.py:38 +#: pyload/plugin/hoster/LinksnappyCom.py:29 +#: pyload/plugin/hoster/DebridItaliaCom.py:39 +#: pyload/plugin/hoster/RPNetBiz.py:28 +#: pyload/plugin/hoster/MultiDebridCom.py:40 +#: pyload/plugin/hoster/ReloadCc.py:26 pyload/plugin/hoster/OverLoadMe.py:38 +#: pyload/plugin/hoster/RehostTo.py:25 +#: pyload/plugin/hoster/PremiumizeMe.py:24 +#: pyload/plugin/hooks/RPNetBiz.py:45 #, python-format msgid "Please enter your %s account or deactivate this plugin" msgstr "" -#: pyload/plugins/hoster/FilesMailRu.py:98 +#: pyload/plugin/hoster/FilesMailRu.py:98 #, python-format msgid "" "There was HTML Code in the Downloaded File (%s)...redirect error? The " "Download will be restarted." msgstr "" -#: pyload/plugins/hoster/NetloadIn.py:145 -#: pyload/plugins/hoster/NetloadIn.py:169 +#: pyload/plugin/hoster/NetloadIn.py:145 +#: pyload/plugin/hoster/NetloadIn.py:169 msgid "File temporarily not available" msgstr "" -#: pyload/plugins/hoster/NetloadIn.py:182 +#: pyload/plugin/hoster/NetloadIn.py:182 #, python-format msgid "Netload: waiting between downloads %d s." msgstr "" -#: pyload/plugins/hoster/NetloadIn.py:213 +#: pyload/plugin/hoster/NetloadIn.py:213 #, python-format msgid "Netload: waiting for captcha %d s." msgstr "" -#: pyload/plugins/hoster/NetloadIn.py:251 +#: pyload/plugin/hoster/NetloadIn.py:251 msgid "Downloaded File was empty" msgstr "" -#: pyload/plugins/hoster/MegaDebridEu.py:49 +#: pyload/plugin/hoster/MegaDebridEu.py:49 #, python-format msgid "Impossible to connect to %s" msgstr "" -#: pyload/plugins/hoster/MegaDebridEu.py:89 +#: pyload/plugin/hoster/MegaDebridEu.py:89 #, python-format msgid "Impossible to debrid %s" msgstr "" -#: pyload/plugins/hoster/UploadedTo.py:129 +#: pyload/plugin/hoster/UploadedTo.py:129 msgid "API key invalid" msgstr "" -#: pyload/plugins/hoster/UploadedTo.py:153 +#: pyload/plugin/hoster/UploadedTo.py:153 #, python-format msgid "%s: Not enough traffic left" msgstr "" -#: pyload/plugins/hoster/UploadedTo.py:156 +#: pyload/plugin/hoster/UploadedTo.py:156 msgid "Traffic exceeded" msgstr "" -#: pyload/plugins/hoster/RapidshareCom.py:99 +#: pyload/plugin/hoster/RapidshareCom.py:99 msgid "Rapidshare: Traffic Share (direct download)" msgstr "" -#: pyload/plugins/hoster/RapidshareCom.py:126 -#: pyload/plugins/hoster/RapidshareCom.py:193 +#: pyload/plugin/hoster/RapidshareCom.py:126 +#: pyload/plugin/hoster/RapidshareCom.py:193 msgid "Already downloading from this ip address, waiting 60 seconds" msgstr "" -#: pyload/plugins/hoster/RapidshareCom.py:130 +#: pyload/plugin/hoster/RapidshareCom.py:130 msgid "Invalid Auth Code, download will be restarted" msgstr "" -#: pyload/plugins/hoster/RapidshareCom.py:198 +#: pyload/plugin/hoster/RapidshareCom.py:198 msgid "RapidShareCom: No free slots" msgstr "" -#: pyload/plugins/hoster/RapidshareCom.py:201 +#: pyload/plugin/hoster/RapidshareCom.py:201 msgid "You need a premium account for this file" msgstr "" -#: pyload/plugins/hoster/RapidshareCom.py:203 +#: pyload/plugin/hoster/RapidshareCom.py:203 msgid "Filename reported invalid" msgstr "" -#: pyload/plugins/hoster/FileserveCom.py:100 +#: pyload/plugin/hoster/FileserveCom.py:100 msgid "Parallel download error, now waiting 60s." msgstr "" -#: pyload/plugins/hoster/FileserveCom.py:216 +#: pyload/plugin/hoster/FileserveCom.py:216 msgid "Not logged in." msgstr "" -#: pyload/plugins/hoster/MegaNz.py:56 +#: pyload/plugin/hoster/MegaNz.py:56 msgid "Decryption failed" msgstr "" -#: pyload/plugins/hoster/MegaNz.py:106 +#: pyload/plugin/hoster/MegaNz.py:106 msgid "No file key provided in the URL" msgstr "" -#: pyload/plugins/hoster/MegaNz.py:118 +#: pyload/plugin/hoster/MegaNz.py:118 msgid "Error code:" msgstr "" -#: pyload/plugins/Container.py:68 +#: pyload/plugin/Container.py:68 msgid "File not exists." msgstr "" -#: pyload/plugins/hooks/UpdateManager.py:97 +#: pyload/plugin/hooks/UpdateManager.py:97 msgid "Not able to connect server to get updates" msgstr "" -#: pyload/plugins/hooks/UpdateManager.py:111 +#: pyload/plugin/hooks/UpdateManager.py:111 msgid "No pyLoad version available" msgstr "" -#: pyload/plugins/hooks/UpdateManager.py:118 +#: pyload/plugin/hooks/UpdateManager.py:118 #, python-format msgid "*** New pyLoad Version %s available ***" msgstr "" -#: pyload/plugins/hooks/UpdateManager.py:119 +#: pyload/plugin/hooks/UpdateManager.py:119 msgid "*** Get it here: https://github.com/pyload/pyload/releases ***" msgstr "" -#: pyload/plugins/hooks/UpdateManager.py:170 +#: pyload/plugin/hooks/UpdateManager.py:170 #, python-format msgid "New version of [%(type)s] %(name)s (v%(oldver)s -> v%(newver)s)" msgstr "" -#: pyload/plugins/hooks/UpdateManager.py:180 -#: pyload/plugins/hooks/UpdateManager.py:185 +#: pyload/plugin/hooks/UpdateManager.py:180 +#: pyload/plugin/hooks/UpdateManager.py:185 #, python-format msgid "Error when updating plugin %s" msgstr "" -#: pyload/plugins/hooks/UpdateManager.py:185 +#: pyload/plugin/hooks/UpdateManager.py:185 msgid "Version mismatch" msgstr "" -#: pyload/plugins/hooks/UpdateManager.py:196 +#: pyload/plugin/hooks/UpdateManager.py:196 #, python-format msgid "Removed blacklisted plugin: [%(type)s] %(name)s" msgstr "" -#: pyload/plugins/hooks/UpdateManager.py:204 +#: pyload/plugin/hooks/UpdateManager.py:204 msgid "Plugins updated and reloaded" msgstr "" -#: pyload/plugins/hooks/UpdateManager.py:206 +#: pyload/plugin/hooks/UpdateManager.py:206 msgid "*** Plugins have been updated, pyLoad will be restarted now ***" msgstr "" -#: pyload/plugins/hooks/UpdateManager.py:211 +#: pyload/plugin/hooks/UpdateManager.py:211 msgid "No plugin updates available" msgstr "" -#: pyload/plugins/hooks/IRCInterface.py:82 +#: pyload/plugin/hooks/IRCInterface.py:82 #, python-format msgid "Download finished: %(name)s @ %(plugin)s " msgstr "" -#: pyload/plugins/hooks/IRCInterface.py:95 +#: pyload/plugin/hooks/IRCInterface.py:95 #, python-format msgid "New Captcha Request: %s" msgstr "" -#: pyload/plugins/hooks/IRCInterface.py:96 +#: pyload/plugin/hooks/IRCInterface.py:96 #, python-format msgid "Answer with 'c %s text on the captcha'" msgstr "" -#: pyload/plugins/hooks/Premium4Me.py:29 +#: pyload/plugin/hooks/Premium4Me.py:29 msgid "Please add your premium.to account first and restart pyLoad" msgstr "" -#: pyload/plugins/hooks/HotFolder.py:81 +#: pyload/plugin/hooks/HotFolder.py:81 #, python-format msgid "Added %s from HotFolder" msgstr "" -#: pyload/plugins/hooks/ExtractArchive.py:94 +#: pyload/plugin/hooks/ExtractArchive.py:94 #, python-format msgid "No %s installed" msgstr "" -#: pyload/plugins/hooks/ExtractArchive.py:96 -#: pyload/plugins/hooks/ExtractArchive.py:101 +#: pyload/plugin/hooks/ExtractArchive.py:96 +#: pyload/plugin/hooks/ExtractArchive.py:101 #, python-format msgid "Could not activate %s" msgstr "" -#: pyload/plugins/hooks/ExtractArchive.py:106 +#: pyload/plugin/hooks/ExtractArchive.py:106 msgid "Activated" msgstr "" -#: pyload/plugins/hooks/ExtractArchive.py:108 +#: pyload/plugin/hooks/ExtractArchive.py:108 msgid "No Extract plugins activated" msgstr "" -#: pyload/plugins/hooks/ExtractArchive.py:120 +#: pyload/plugin/hooks/ExtractArchive.py:120 #, python-format msgid "Package %s queued for later extracting" msgstr "" -#: pyload/plugins/hooks/ExtractArchive.py:143 +#: pyload/plugin/hooks/ExtractArchive.py:143 #, python-format msgid "Check package %s" msgstr "" -#: pyload/plugins/hooks/ExtractArchive.py:184 +#: pyload/plugin/hooks/ExtractArchive.py:184 #, python-format msgid "Extract to %s" msgstr "" -#: pyload/plugins/hooks/ExtractArchive.py:199 +#: pyload/plugin/hooks/ExtractArchive.py:199 msgid "No files found to extract" msgstr "" -#: pyload/plugins/hooks/ExtractArchive.py:206 +#: pyload/plugin/hooks/ExtractArchive.py:206 msgid "extracting" msgstr "" -#: pyload/plugins/hooks/ExtractArchive.py:217 +#: pyload/plugin/hooks/ExtractArchive.py:217 msgid "Password protected" msgstr "" -#: pyload/plugins/hooks/ExtractArchive.py:238 +#: pyload/plugin/hooks/ExtractArchive.py:238 msgid "Wrong password" msgstr "" -#: pyload/plugins/hooks/ExtractArchive.py:246 +#: pyload/plugin/hooks/ExtractArchive.py:246 #, python-format msgid "Deleting %s files" msgstr "" -#: pyload/plugins/hooks/ExtractArchive.py:253 +#: pyload/plugin/hooks/ExtractArchive.py:253 msgid "Extracting finished" msgstr "" -#: pyload/plugins/hooks/ExtractArchive.py:259 +#: pyload/plugin/hooks/ExtractArchive.py:259 msgid "Archive Error" msgstr "" -#: pyload/plugins/hooks/ExtractArchive.py:261 +#: pyload/plugin/hooks/ExtractArchive.py:261 msgid "CRC Mismatch" msgstr "" -#: pyload/plugins/hooks/ExtractArchive.py:265 +#: pyload/plugin/hooks/ExtractArchive.py:265 msgid "Unknown Error" msgstr "" -#: pyload/plugins/hooks/ExtractArchive.py:317 +#: pyload/plugin/hooks/ExtractArchive.py:317 msgid "Setting User and Group failed" msgstr "" -#: pyload/plugins/hooks/ClickAndLoad.py:75 +#: pyload/plugin/hooks/ClickAndLoad.py:75 msgid "Click'N'Load: Port 9666 already in use" msgstr "" -#: pyload/plugins/hooks/CaptchaTrader.py:70 -#: pyload/plugins/hooks/Captcha9kw.py:60 -#: pyload/plugins/hooks/ExpertDecoders.py:51 +#: pyload/plugin/hooks/CaptchaTrader.py:70 +#: pyload/plugin/hooks/Captcha9kw.py:60 +#: pyload/plugin/hooks/ExpertDecoders.py:51 #, python-format msgid "%s credits left" msgstr "" -#: pyload/plugins/hooks/CaptchaTrader.py:118 +#: pyload/plugin/hooks/CaptchaTrader.py:118 msgid "Could not send response." msgstr "" -#: pyload/plugins/hooks/CaptchaTrader.py:136 +#: pyload/plugin/hooks/CaptchaTrader.py:136 msgid "Your CaptchaTrader Account has not enough credits" msgstr "" -#: pyload/plugins/hooks/LinkdecrypterCom.py:45 +#: pyload/plugin/hooks/LinkdecrypterCom.py:45 msgid "Crypter list not found" msgstr "" -#: pyload/plugins/hooks/LinkdecrypterCom.py:59 +#: pyload/plugin/hooks/LinkdecrypterCom.py:59 msgid "Crypter list is empty" msgstr "" -#: pyload/plugins/hooks/XMPPInterface.py:91 +#: pyload/plugin/hooks/XMPPInterface.py:91 #, python-format msgid "Download finished: %(name)s @ %(plugin)s" msgstr "" -#: pyload/plugins/hooks/Captcha9kw.py:94 +#: pyload/plugin/hooks/Captcha9kw.py:94 #, python-format msgid "New CaptchaID from upload: %s : %s" msgstr "" -#: pyload/plugins/hooks/Captcha9kw.py:130 +#: pyload/plugin/hooks/Captcha9kw.py:130 msgid "Your Captcha 9kw.eu Account has not enough credits" msgstr "" -#: pyload/plugins/hooks/ExternalScripts.py:54 +#: pyload/plugin/hooks/ExternalScripts.py:54 #, python-format msgid "Installed scripts for %s: " msgstr "" -#: pyload/plugins/hooks/ExternalScripts.py:69 +#: pyload/plugin/hooks/ExternalScripts.py:69 msgid "Script not executable:" msgstr "" -#: pyload/plugins/hooks/ExternalScripts.py:80 +#: pyload/plugin/hooks/ExternalScripts.py:80 #, python-format msgid "Error in %(script)s: %(error)s" msgstr "" -#: pyload/plugins/hooks/ExpertDecoders.py:96 +#: pyload/plugin/hooks/ExpertDecoders.py:96 msgid "Your ExpertDecoders Account has not enough credits" msgstr "" -#: pyload/plugins/hooks/RehostTo.py:32 +#: pyload/plugin/hooks/RehostTo.py:32 msgid "Please add your rehost.to account first and restart pyLoad" msgstr "" -#: pyload/plugins/hooks/PremiumizeMe.py:50 +#: pyload/plugin/hooks/PremiumizeMe.py:50 msgid "Please add a valid premiumize.me account first and restart pyLoad." msgstr "" -#: pyload/plugins/hooks/CaptchaBrotherhood.py:70 +#: pyload/plugin/hooks/CaptchaBrotherhood.py:70 #, python-format msgid "%d credits left" msgstr "" -#: pyload/plugins/Plugin.py:389 +#: pyload/plugin/Plugin.py:389 msgid "" "Pil and tesseract not installed and no Client connected for captcha " "decrypting" msgstr "" -#: pyload/plugins/Plugin.py:393 +#: pyload/plugin/Plugin.py:393 msgid "No captcha result obtained in appropiate time by any of the plugins." msgstr "" -#: pyload/plugins/Plugin.py:498 pyload/plugins/Plugin.py:532 +#: pyload/plugin/Plugin.py:498 pyload/plugin/Plugin.py:532 #, python-format msgid "Setting User and Group failed: %s" msgstr "" diff --git a/locale/pavement.py b/locale/pavement.py new file mode 100644 index 000000000..0cdfb4872 --- /dev/null +++ b/locale/pavement.py @@ -0,0 +1,415 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from __future__ import with_statement + +from paver.easy import * +from paver.setuputils import setup +from paver.doctools import cog + +import os +import sys +import shutil +import re +from glob import glob +from tempfile import mkdtemp +from urllib import urlretrieve +from subprocess import call, Popen, PIPE +from zipfile import ZipFile + +PROJECT_DIR = path(__file__).dirname() +sys.path.append(PROJECT_DIR) + +options = environment.options +path("pyload").mkdir() + +extradeps = [] +if sys.version_info <= (2, 5): + extradeps += 'simplejson' + +setup( + name="pyload", + version="0.4.10", + description='Fast, lightweight and full featured download manager.', + long_description=open(PROJECT_DIR / "README.md").read(), + keywords = ("pyload", "download-manager", "one-click-hoster", "download"), + url="http://pyload.org", + download_url='http://pyload.org/download', + license='GPL v3', + author="pyLoad Team", + author_email="support@pyload.org", + platforms = ('Any',), + #package_dir={'pyload': "src"}, + packages=["pyload"], + #package_data=find_package_data(), + #data_files=[], + include_package_data=True, + exclude_package_data={'pyload': ["docs*", "scripts*", "tests*"]}, #exluced from build but not from sdist + # 'bottle >= 0.10.0' not in list, because its small and contain little modifications + install_requires=['thrift >= 0.8.0', 'jinja2', 'pycurl', 'Beaker', 'BeautifulSoup >= 3.2, < 3.3'] + extradeps, + extras_require={ + 'SSL': ["pyOpenSSL"], + 'DLC': ['pycrypto'], + 'lightweight webserver': ['bjoern'], + 'RSS plugins': ['feedparser'], + }, + #setup_requires=["setuptools_hg"], + entry_points={ + 'console_scripts': [ + 'pyLoadCore = pyLoadCore:main', + 'pyLoadCli = pyLoadCli:main' + ]}, + zip_safe=False, + classifiers=[ + "Development Status :: 5 - Production/Stable", + "Topic :: Internet :: WWW/HTTP", + "Environment :: Console", + "Environment :: Web Environment", + "Intended Audience :: End Users/Desktop", + "License :: OSI Approved :: GNU General Public License (GPL)", + "Operating System :: OS Independent", + "Programming Language :: Python :: 2" + ] +) + +options( + sphinx=Bunch( + builddir="_build", + sourcedir="" + ), + get_source=Bunch( + src="https://bitbucket.org/spoob/pyload/get/tip.zip", + rev=None, + clean=False + ), + thrift=Bunch( + path="../thrift/trunk/compiler/cpp/thrift", + gen="" + ), + virtualenv=Bunch( + dir="env", + python="python2", + virtual="virtualenv2", + ), + cog=Bunch( + pattern="*.py", + ) +) + +# xgettext args +xargs = ["--language=Python", "--add-comments=L10N", + "--from-code=utf-8", "--copyright-holder=pyLoad Team", "--package-name=pyLoad", + "--package-version=%s" % options.version, "--msgid-bugs-address='bugs@pyload.org'"] + +@task +@needs('cog') +def html(): + """Build html documentation""" + module = path("docs") / "pyload" + pyload.rmtree() + call_task('paver.doctools.html') + + +@task +@cmdopts([ + ('src=', 's', 'Url to source'), + ('rev=', 'r', "HG revision"), + ("clean", 'c', 'Delete old source folder') +]) +def get_source(options): + """ Downloads pyload source from bitbucket tip or given rev""" + if options.rev: options.url = "https://bitbucket.org/spoob/pyload/get/%s.zip" % options.rev + + pyload = path("pyload") + + if len(pyload.listdir()) and not options.clean: + return + elif pyload.exists(): + pyload.rmtree() + + urlretrieve(options.src, "pyload_src.zip") + zip = ZipFile("pyload_src.zip") + zip.extractall() + path("pyload_src.zip").remove() + + folder = [x for x in path(".").dirs() if x.name.startswith("spoob-pyload-")][0] + folder.move(pyload) + + change_mode(pyload, 0644) + change_mode(pyload, 0755, folder=True) + + for file in pyload.files(): + if file.name.endswith(".py"): + file.chmod(0755) + + (pyload / ".hgtags").remove() + (pyload / ".gitignore").remove() + #(pyload / "docs").rmtree() + + f = open(pyload / "__init__.py", "wb") + f.close() + + #options.setup.packages = find_packages() + #options.setup.package_data = find_package_data() + + +@task +@needs('clean', 'generate_setup', 'minilib', 'get_source', 'setuptools.command.sdist') +def sdist(): + """ Build source code package with distutils """ + + +@task +@cmdopts([ + ('path=', 'p', 'Thrift path'), + ('gen=', 'g', "Extra --gen option") +]) +def thrift(options): + """ Generate Thrift stubs """ + + print "add import for TApplicationException manually as long it is not fixed" + + outdir = path("pyload") / "remote" / "thriftbackend" + (outdir / "gen-py").rmtree() + + cmd = [options.thrift.path, "-strict", "-o", outdir, "--gen", "py:slots, dynamic", outdir / "pyload.thrift"] + + if options.gen: + cmd.insert(len(cmd) - 1, "--gen") + cmd.insert(len(cmd) - 1, options.gen) + + print "running", cmd + + p = Popen(cmd) + p.communicate() + + (outdir / "thriftgen").rmtree() + (outdir / "gen-py").move(outdir / "thriftgen") + + #create light ttypes + from pyload.remote.socketbackend.create_ttypes import main + main() + +@task +def compile_js(): + """ Compile .coffee files to javascript""" + + root = path("pyload") / "web" / "media" / "js" + for f in root.glob("*.coffee"): + print "generate", f + coffee = Popen(["coffee", "-cbs"], stdin=open(f, "rb"), stdout=PIPE) + yui = Popen(["yuicompressor", "--type", "js"], stdin=coffee.stdout, stdout=PIPE) + coffee.stdout.close() + content = yui.communicate()[0] + with open(root / f.name.replace(".coffee", ".js"), "wb") as js: + js.write("{% autoescape true %}\n") + js.write(content) + js.write("\n{% endautoescape %}") + + +@task +def generate_locale(): + """ Generates localization files """ + + EXCLUDE = ["BeautifulSoup.py", "pyload/cli", "web/locale", "web/ajax", "web/cnl", "web/pyload", + "setup.py"] + makepot("core", path("pyload"), EXCLUDE, "./pyload.py\n") + + makepot("cli", path("pyload") / "cli", [], includes="./pyload-cli.py\n") + makepot("setup", "", [], includes="./pyload/setup.py\n") + + EXCLUDE = ["ServerThread.py", "web/media/default"] + + # strings from js files + strings = set() + + for fi in path("pyload/web").walkfiles(): + if not fi.name.endswith(".js") and not fi.endswith(".coffee"): continue + with open(fi, "rb") as c: + content = c.read() + + strings.update(re.findall(r"_\s*\(\s*\"([^\"]+)", content)) + strings.update(re.findall(r"_\s*\(\s*\'([^\']+)", content)) + + trans = path("pyload") / "web" / "translations.js" + + with open(trans, "wb") as js: + for s in strings: + js.write('_("%s")\n' % s) + + makepot("django", path("pyload/web"), EXCLUDE, "./%s\n" % trans.relpath(), [".py", ".html"], ["--language=Python"]) + + trans.remove() + + path("includes.txt").remove() + + print "Locale generated" + + +@task +@cmdopts([ + ('key=', 'k', 'api key') +]) +def upload_translations(options): + """ Uploads the locale files to translation server """ + tmp = path(mkdtemp()) + + shutil.copy('locale/crowdin.yaml', tmp) + os.mkdir(tmp / 'pyLoad') + for f in glob('locale/*.pot'): + if os.path.isfile(f): + shutil.copy(f, tmp / 'pyLoad') + + config = tmp / 'crowdin.yaml' + content = open(config, 'rb').read() + content = content.format(key=options.key, tmp=tmp) + f = open(config, 'wb') + f.write(content) + f.close() + + call(['crowdin-cli', '-c', config, 'upload', 'source']) + + shutil.rmtree(tmp) + + print "Translations uploaded" + + +@task +@cmdopts([ + ('key=', 'k', 'api key') +]) +def download_translations(options): + """ Downloads the translated files from translation server """ + tmp = path(mkdtemp()) + + shutil.copy('locale/crowdin.yaml', tmp) + os.mkdir(tmp / 'pyLoad') + for f in glob('locale/*.pot'): + if os.path.isfile(f): + shutil.copy(f, tmp / 'pyLoad') + + config = tmp / 'crowdin.yaml' + content = open(config, 'rb').read() + content = content.format(key=options.key, tmp=tmp) + f = open(config, 'wb') + f.write(content) + f.close() + + call(['crowdin-cli', '-c', config, 'download']) + + for language in (tmp / 'pyLoad').listdir(): + if not language.isdir(): + continue + + target = path('locale') / language.basename() + print "Copy language %s" % target + if target.exists(): + shutil.rmtree(target) + + shutil.copytree(language, target) + + shutil.rmtree(tmp) + + +@task +def compile_translations(): + """ Compile PO files to MO """ + for language in path('locale').listdir(): + if not language.isdir(): + continue + + for f in glob(language / 'LC_MESSAGES' / '*.po'): + print "Compiling %s" % f + call(['msgfmt', '-o', f.replace('.po', '.mo'), f]) + + +@task +def tests(): + call(["nosetests2"]) + +@task +def virtualenv(options): + """Setup virtual environment""" + if path(options.dir).exists(): + return + + call([options.virtual, "--no-site-packages", "--python", options.python, options.dir]) + print "$ source %s/bin/activate" % options.dir + + +@task +def clean_env(): + """Deletes the virtual environment""" + env = path(options.virtualenv.dir) + if env.exists(): + env.rmtree() + + +@task +@needs('generate_setup', 'minilib', 'get_source', 'virtualenv') +def env_install(): + """Install pyLoad into the virtualenv""" + venv = options.virtualenv + call([path(venv.dir) / "bin" / "easy_install", "."]) + + +@task +def clean(): + """Cleans build directories""" + path("build").rmtree() + path("dist").rmtree() + + +#helper functions + +def walk_trans(path, EXCLUDE, endings=[".py"]): + result = "" + + for f in path.walkfiles(): + if [True for x in EXCLUDE if x in f.dirname().relpath()]: continue + if f.name in EXCLUDE: continue + + for e in endings: + if f.name.endswith(e): + result += "./%s\n" % f.relpath() + break + + return result + + +def makepot(domain, p, excludes=[], includes="", endings=[".py"], xxargs=[]): + print "Generate %s.pot" % domain + + f = open("includes.txt", "wb") + if includes: + f.write(includes) + + if p: + f.write(walk_trans(path(p), excludes, endings)) + + f.close() + + call(["xgettext", "--files-from=includes.txt", "--default-domain=%s" % domain] + xargs + xxargs) + + # replace charset und move file + with open("%s.po" % domain, "rb") as f: + content = f.read() + + path("%s.po" % domain).remove() + content = content.replace("charset=CHARSET", "charset=UTF-8") + + with open("locale/%s.pot" % domain, "wb") as f: + f.write(content) + + +def change_owner(dir, uid, gid): + for p in dir.walk(): + p.chown(uid, gid) + + +def change_mode(dir, mode, folder=False): + for p in dir.walk(): + if folder and p.isdir(): + p.chmod(mode) + elif p.isfile() and not folder: + p.chmod(mode) diff --git a/pavement.py b/pavement.py deleted file mode 100644 index 0cdfb4872..000000000 --- a/pavement.py +++ /dev/null @@ -1,415 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from __future__ import with_statement - -from paver.easy import * -from paver.setuputils import setup -from paver.doctools import cog - -import os -import sys -import shutil -import re -from glob import glob -from tempfile import mkdtemp -from urllib import urlretrieve -from subprocess import call, Popen, PIPE -from zipfile import ZipFile - -PROJECT_DIR = path(__file__).dirname() -sys.path.append(PROJECT_DIR) - -options = environment.options -path("pyload").mkdir() - -extradeps = [] -if sys.version_info <= (2, 5): - extradeps += 'simplejson' - -setup( - name="pyload", - version="0.4.10", - description='Fast, lightweight and full featured download manager.', - long_description=open(PROJECT_DIR / "README.md").read(), - keywords = ("pyload", "download-manager", "one-click-hoster", "download"), - url="http://pyload.org", - download_url='http://pyload.org/download', - license='GPL v3', - author="pyLoad Team", - author_email="support@pyload.org", - platforms = ('Any',), - #package_dir={'pyload': "src"}, - packages=["pyload"], - #package_data=find_package_data(), - #data_files=[], - include_package_data=True, - exclude_package_data={'pyload': ["docs*", "scripts*", "tests*"]}, #exluced from build but not from sdist - # 'bottle >= 0.10.0' not in list, because its small and contain little modifications - install_requires=['thrift >= 0.8.0', 'jinja2', 'pycurl', 'Beaker', 'BeautifulSoup >= 3.2, < 3.3'] + extradeps, - extras_require={ - 'SSL': ["pyOpenSSL"], - 'DLC': ['pycrypto'], - 'lightweight webserver': ['bjoern'], - 'RSS plugins': ['feedparser'], - }, - #setup_requires=["setuptools_hg"], - entry_points={ - 'console_scripts': [ - 'pyLoadCore = pyLoadCore:main', - 'pyLoadCli = pyLoadCli:main' - ]}, - zip_safe=False, - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Topic :: Internet :: WWW/HTTP", - "Environment :: Console", - "Environment :: Web Environment", - "Intended Audience :: End Users/Desktop", - "License :: OSI Approved :: GNU General Public License (GPL)", - "Operating System :: OS Independent", - "Programming Language :: Python :: 2" - ] -) - -options( - sphinx=Bunch( - builddir="_build", - sourcedir="" - ), - get_source=Bunch( - src="https://bitbucket.org/spoob/pyload/get/tip.zip", - rev=None, - clean=False - ), - thrift=Bunch( - path="../thrift/trunk/compiler/cpp/thrift", - gen="" - ), - virtualenv=Bunch( - dir="env", - python="python2", - virtual="virtualenv2", - ), - cog=Bunch( - pattern="*.py", - ) -) - -# xgettext args -xargs = ["--language=Python", "--add-comments=L10N", - "--from-code=utf-8", "--copyright-holder=pyLoad Team", "--package-name=pyLoad", - "--package-version=%s" % options.version, "--msgid-bugs-address='bugs@pyload.org'"] - -@task -@needs('cog') -def html(): - """Build html documentation""" - module = path("docs") / "pyload" - pyload.rmtree() - call_task('paver.doctools.html') - - -@task -@cmdopts([ - ('src=', 's', 'Url to source'), - ('rev=', 'r', "HG revision"), - ("clean", 'c', 'Delete old source folder') -]) -def get_source(options): - """ Downloads pyload source from bitbucket tip or given rev""" - if options.rev: options.url = "https://bitbucket.org/spoob/pyload/get/%s.zip" % options.rev - - pyload = path("pyload") - - if len(pyload.listdir()) and not options.clean: - return - elif pyload.exists(): - pyload.rmtree() - - urlretrieve(options.src, "pyload_src.zip") - zip = ZipFile("pyload_src.zip") - zip.extractall() - path("pyload_src.zip").remove() - - folder = [x for x in path(".").dirs() if x.name.startswith("spoob-pyload-")][0] - folder.move(pyload) - - change_mode(pyload, 0644) - change_mode(pyload, 0755, folder=True) - - for file in pyload.files(): - if file.name.endswith(".py"): - file.chmod(0755) - - (pyload / ".hgtags").remove() - (pyload / ".gitignore").remove() - #(pyload / "docs").rmtree() - - f = open(pyload / "__init__.py", "wb") - f.close() - - #options.setup.packages = find_packages() - #options.setup.package_data = find_package_data() - - -@task -@needs('clean', 'generate_setup', 'minilib', 'get_source', 'setuptools.command.sdist') -def sdist(): - """ Build source code package with distutils """ - - -@task -@cmdopts([ - ('path=', 'p', 'Thrift path'), - ('gen=', 'g', "Extra --gen option") -]) -def thrift(options): - """ Generate Thrift stubs """ - - print "add import for TApplicationException manually as long it is not fixed" - - outdir = path("pyload") / "remote" / "thriftbackend" - (outdir / "gen-py").rmtree() - - cmd = [options.thrift.path, "-strict", "-o", outdir, "--gen", "py:slots, dynamic", outdir / "pyload.thrift"] - - if options.gen: - cmd.insert(len(cmd) - 1, "--gen") - cmd.insert(len(cmd) - 1, options.gen) - - print "running", cmd - - p = Popen(cmd) - p.communicate() - - (outdir / "thriftgen").rmtree() - (outdir / "gen-py").move(outdir / "thriftgen") - - #create light ttypes - from pyload.remote.socketbackend.create_ttypes import main - main() - -@task -def compile_js(): - """ Compile .coffee files to javascript""" - - root = path("pyload") / "web" / "media" / "js" - for f in root.glob("*.coffee"): - print "generate", f - coffee = Popen(["coffee", "-cbs"], stdin=open(f, "rb"), stdout=PIPE) - yui = Popen(["yuicompressor", "--type", "js"], stdin=coffee.stdout, stdout=PIPE) - coffee.stdout.close() - content = yui.communicate()[0] - with open(root / f.name.replace(".coffee", ".js"), "wb") as js: - js.write("{% autoescape true %}\n") - js.write(content) - js.write("\n{% endautoescape %}") - - -@task -def generate_locale(): - """ Generates localization files """ - - EXCLUDE = ["BeautifulSoup.py", "pyload/cli", "web/locale", "web/ajax", "web/cnl", "web/pyload", - "setup.py"] - makepot("core", path("pyload"), EXCLUDE, "./pyload.py\n") - - makepot("cli", path("pyload") / "cli", [], includes="./pyload-cli.py\n") - makepot("setup", "", [], includes="./pyload/setup.py\n") - - EXCLUDE = ["ServerThread.py", "web/media/default"] - - # strings from js files - strings = set() - - for fi in path("pyload/web").walkfiles(): - if not fi.name.endswith(".js") and not fi.endswith(".coffee"): continue - with open(fi, "rb") as c: - content = c.read() - - strings.update(re.findall(r"_\s*\(\s*\"([^\"]+)", content)) - strings.update(re.findall(r"_\s*\(\s*\'([^\']+)", content)) - - trans = path("pyload") / "web" / "translations.js" - - with open(trans, "wb") as js: - for s in strings: - js.write('_("%s")\n' % s) - - makepot("django", path("pyload/web"), EXCLUDE, "./%s\n" % trans.relpath(), [".py", ".html"], ["--language=Python"]) - - trans.remove() - - path("includes.txt").remove() - - print "Locale generated" - - -@task -@cmdopts([ - ('key=', 'k', 'api key') -]) -def upload_translations(options): - """ Uploads the locale files to translation server """ - tmp = path(mkdtemp()) - - shutil.copy('locale/crowdin.yaml', tmp) - os.mkdir(tmp / 'pyLoad') - for f in glob('locale/*.pot'): - if os.path.isfile(f): - shutil.copy(f, tmp / 'pyLoad') - - config = tmp / 'crowdin.yaml' - content = open(config, 'rb').read() - content = content.format(key=options.key, tmp=tmp) - f = open(config, 'wb') - f.write(content) - f.close() - - call(['crowdin-cli', '-c', config, 'upload', 'source']) - - shutil.rmtree(tmp) - - print "Translations uploaded" - - -@task -@cmdopts([ - ('key=', 'k', 'api key') -]) -def download_translations(options): - """ Downloads the translated files from translation server """ - tmp = path(mkdtemp()) - - shutil.copy('locale/crowdin.yaml', tmp) - os.mkdir(tmp / 'pyLoad') - for f in glob('locale/*.pot'): - if os.path.isfile(f): - shutil.copy(f, tmp / 'pyLoad') - - config = tmp / 'crowdin.yaml' - content = open(config, 'rb').read() - content = content.format(key=options.key, tmp=tmp) - f = open(config, 'wb') - f.write(content) - f.close() - - call(['crowdin-cli', '-c', config, 'download']) - - for language in (tmp / 'pyLoad').listdir(): - if not language.isdir(): - continue - - target = path('locale') / language.basename() - print "Copy language %s" % target - if target.exists(): - shutil.rmtree(target) - - shutil.copytree(language, target) - - shutil.rmtree(tmp) - - -@task -def compile_translations(): - """ Compile PO files to MO """ - for language in path('locale').listdir(): - if not language.isdir(): - continue - - for f in glob(language / 'LC_MESSAGES' / '*.po'): - print "Compiling %s" % f - call(['msgfmt', '-o', f.replace('.po', '.mo'), f]) - - -@task -def tests(): - call(["nosetests2"]) - -@task -def virtualenv(options): - """Setup virtual environment""" - if path(options.dir).exists(): - return - - call([options.virtual, "--no-site-packages", "--python", options.python, options.dir]) - print "$ source %s/bin/activate" % options.dir - - -@task -def clean_env(): - """Deletes the virtual environment""" - env = path(options.virtualenv.dir) - if env.exists(): - env.rmtree() - - -@task -@needs('generate_setup', 'minilib', 'get_source', 'virtualenv') -def env_install(): - """Install pyLoad into the virtualenv""" - venv = options.virtualenv - call([path(venv.dir) / "bin" / "easy_install", "."]) - - -@task -def clean(): - """Cleans build directories""" - path("build").rmtree() - path("dist").rmtree() - - -#helper functions - -def walk_trans(path, EXCLUDE, endings=[".py"]): - result = "" - - for f in path.walkfiles(): - if [True for x in EXCLUDE if x in f.dirname().relpath()]: continue - if f.name in EXCLUDE: continue - - for e in endings: - if f.name.endswith(e): - result += "./%s\n" % f.relpath() - break - - return result - - -def makepot(domain, p, excludes=[], includes="", endings=[".py"], xxargs=[]): - print "Generate %s.pot" % domain - - f = open("includes.txt", "wb") - if includes: - f.write(includes) - - if p: - f.write(walk_trans(path(p), excludes, endings)) - - f.close() - - call(["xgettext", "--files-from=includes.txt", "--default-domain=%s" % domain] + xargs + xxargs) - - # replace charset und move file - with open("%s.po" % domain, "rb") as f: - content = f.read() - - path("%s.po" % domain).remove() - content = content.replace("charset=CHARSET", "charset=UTF-8") - - with open("locale/%s.pot" % domain, "wb") as f: - f.write(content) - - -def change_owner(dir, uid, gid): - for p in dir.walk(): - p.chown(uid, gid) - - -def change_mode(dir, mode, folder=False): - for p in dir.walk(): - if folder and p.isdir(): - p.chmod(mode) - elif p.isfile() and not folder: - p.chmod(mode) diff --git a/pyload/Core.py b/pyload/Core.py index ec53bf7da..fe4ae566e 100644 --- a/pyload/Core.py +++ b/pyload/Core.py @@ -21,17 +21,17 @@ from sys import argv, executable, exit from time import time, sleep from traceback import print_exc -from pyload.manager.AccountManager import AccountManager -from pyload.manager.CaptchaManager import CaptchaManager +from pyload.manager.Account import AccountManager +from pyload.manager.Captcha import CaptchaManager from pyload.config.Parser import ConfigParser -from pyload.manager.PluginManager import PluginManager -from pyload.manager.event.PullEvents import PullManager +from pyload.manager.Plugin import PluginManager +from pyload.manager.Event import PullManager from pyload.network.RequestFactory import RequestFactory -from pyload.manager.thread.ServerThread import WebServer +from pyload.manager.thread.Server import WebServer from pyload.manager.event.Scheduler import Scheduler from pyload.network.JsEngine import JsEngine from pyload import remote -from pyload.manager.RemoteManager import RemoteManager +from pyload.manager.Remote import RemoteManager from pyload.database import DatabaseBackend, FileHandler from pyload.utils import freeSpace, formatSize, get_console_encoding @@ -358,8 +358,8 @@ class Core(object): # later imported because they would trigger api import, and remote value not set correctly from pyload import api - from pyload.manager.AddonManager import AddonManager - from pyload.manager.ThreadManager import ThreadManager + from pyload.manager.Addon import AddonManager + from pyload.manager.Thread import ThreadManager if api.activated != self.remote: self.log.warning("Import error: API remote status not correct.") diff --git a/pyload/__init__.py b/pyload/__init__.py index 03bab80fb..ade59b396 100644 --- a/pyload/__init__.py +++ b/pyload/__init__.py @@ -5,6 +5,7 @@ from __future__ import with_statement import __builtin__ import os +import platform import sys from codecs import getwriter @@ -40,12 +41,18 @@ __authors__ = [("Marius" , "mkaay@mkaay.de" ), ################################# InitHomeDir ################################# -rootdir = os.path.abspath(os.path.join(__file__, "..")) -homedir = os.path.expanduser("~") -enc = get_console_encoding(sys.stdout.encoding) +__builtin__.owd = os.path.abspath("") #: original working directory +__builtin__.homedir = os.path.expanduser("~") +__builtin__.rootdir = os.path.abspath(os.path.join(__file__, "..")) +__builtin__.configdir = "" +__builtin__.pypath = os.path.abspath(os.path.join(rootdir, "..")) -sys.path.append(os.path.join(rootdir, "lib")) -sys.stdout = getwriter(enc)(sys.stdout, errors="replace") + +if "64" in platform.machine(): + sys.path.append(os.path.join(pypath, "lib64")) +sys.path.append(os.path.join(pypath, "lib")) + +sys.stdout = getwriter(get_console_encoding(sys.stdout.encoding))(sys.stdout, errors="replace") if homedir == "~" and os.name == "nt": import ctypes @@ -63,7 +70,7 @@ if homedir == "~" and os.name == "nt": _SHGetFolderPath(0, CSIDL_APPDATA, 0, 0, path_buf) - homedir = path_buf.value + __builtin__.homedir = path_buf.value try: p = os.path.join(rootdir, "config", "configdir") @@ -83,13 +90,9 @@ try: os.chdir(configdir) -except IOError: +except IOError, e: + print >> sys.stderr, "configdir init failed: %d (%s)" % (e.errno, e.strerror) sys.exit(1) - -__builtin__.owd = os.path.abspath("") #: original working directory -__builtin__.pypath = os.path.abspath(os.path.join(rootdir, "..")) - -__builtin__.rootdir = rootdir -__builtin__.homedir = homedir -__builtin__.configdir = configdir +else: + __builtin__.configdir = configdir diff --git a/pyload/api/__init__.py b/pyload/api/__init__.py index 399117845..387481da2 100644 --- a/pyload/api/__init__.py +++ b/pyload/api/__init__.py @@ -8,7 +8,7 @@ import re from urlparse import urlparse -from pyload.datatype.PyFile import PyFile +from pyload.datatype.File import PyFile from pyload.utils.packagetools import parseNames from pyload.network.RequestFactory import getURL from pyload.remote import activated diff --git a/pyload/database/File.py b/pyload/database/File.py new file mode 100644 index 000000000..2b7c6cad9 --- /dev/null +++ b/pyload/database/File.py @@ -0,0 +1,875 @@ +# -*- coding: utf-8 -*- +# @author: RaNaN, mkaay + +from threading import RLock +from time import time + +from pyload.utils import formatSize, lock +from pyload.manager.Event import InsertEvent, ReloadAllEvent, RemoveEvent, UpdateEvent +from pyload.datatype.Package import PyPackage +from pyload.datatype.File import PyFile +from pyload.database import style, DatabaseBackend + +try: + from pysqlite2 import dbapi2 as sqlite3 +except Exception: + import sqlite3 + + +class FileHandler(object): + """Handles all request made to obtain information, + modify status or other request for links or packages""" + + def __init__(self, core): + """Constructor""" + self.core = core + + # translations + self.statusMsg = [_("finished"), _("offline"), _("online"), _("queued"), _("skipped"), _("waiting"), _("temp. offline"), _("starting"), _("failed"), _("aborted"), _("decrypting"), _("custom"), _("downloading"), _("processing"), _("unknown")] + + self.cache = {} #holds instances for files + self.packageCache = {} # same for packages + #@TODO: purge the cache + + self.jobCache = {} + + self.lock = RLock() #@TODO should be a Lock w/o R + #self.lock._Verbose__verbose = True + + self.filecount = -1 # if an invalid value is set get current value from db + self.queuecount = -1 #number of package to be loaded + self.unchanged = False #determines if any changes was made since last call + + self.db = self.core.db + + def change(func): + def new(*args): + args[0].unchanged = False + args[0].filecount = -1 + args[0].queuecount = -1 + args[0].jobCache = {} + return func(*args) + return new + + #-------------------------------------------------------------------------- + def save(self): + """saves all data to backend""" + self.db.commit() + + #-------------------------------------------------------------------------- + def syncSave(self): + """saves all data to backend and waits until all data are written""" + pyfiles = self.cache.values() + for pyfile in pyfiles: + pyfile.sync() + + pypacks = self.packageCache.values() + for pypack in pypacks: + pypack.sync() + + self.db.syncSave() + + @lock + def getCompleteData(self, queue=1): + """gets a complete data representation""" + + data = self.db.getAllLinks(queue) + packs = self.db.getAllPackages(queue) + + data.update([(x.id, x.toDbDict()[x.id]) for x in self.cache.values()]) + + for x in self.packageCache.itervalues(): + if x.queue != queue or x.id not in packs: continue + packs[x.id].update(x.toDict()[x.id]) + + for key, value in data.iteritems(): + if value["package"] in packs: + packs[value["package"]]["links"][key] = value + + return packs + + @lock + def getInfoData(self, queue=1): + """gets a data representation without links""" + + packs = self.db.getAllPackages(queue) + for x in self.packageCache.itervalues(): + if x.queue != queue or x.id not in packs: continue + packs[x.id].update(x.toDict()[x.id]) + + return packs + + @lock + @change + def addLinks(self, urls, package): + """adds links""" + + self.core.addonManager.dispatchEvent("links-added", urls, package) + + data = self.core.pluginManager.parseUrls(urls) + + self.db.addLinks(data, package) + self.core.threadManager.createInfoThread(data, package) + + #@TODO change from reloadAll event to package update event + self.core.pullManager.addEvent(ReloadAllEvent("collector")) + + #-------------------------------------------------------------------------- + @lock + @change + def addPackage(self, name, folder, queue=0): + """adds a package, default to link collector""" + lastID = self.db.addPackage(name, folder, queue) + p = self.db.getPackage(lastID) + e = InsertEvent("pack", lastID, p.order, "collector" if not queue else "queue") + self.core.pullManager.addEvent(e) + return lastID + + #-------------------------------------------------------------------------- + @lock + @change + def deletePackage(self, id): + """delete package and all contained links""" + + p = self.getPackage(id) + if not p: + if id in self.packageCache: del self.packageCache[id] + return + + oldorder = p.order + queue = p.queue + + e = RemoveEvent("pack", id, "collector" if not p.queue else "queue") + + pyfiles = self.cache.values() + + for pyfile in pyfiles: + if pyfile.packageid == id: + pyfile.abortDownload() + pyfile.release() + + self.db.deletePackage(p) + self.core.pullManager.addEvent(e) + self.core.addonManager.dispatchEvent("package-deleted", id) + + if id in self.packageCache: + del self.packageCache[id] + + packs = self.packageCache.values() + for pack in packs: + if pack.queue == queue and pack.order > oldorder: + pack.order -= 1 + pack.notifyChange() + + #-------------------------------------------------------------------------- + @lock + @change + def deleteLink(self, id): + """deletes links""" + + f = self.getFile(id) + if not f: + return None + + pid = f.packageid + e = RemoveEvent("file", id, "collector" if not f.package().queue else "queue") + + oldorder = f.order + + if id in self.core.threadManager.processingIds(): + self.cache[id].abortDownload() + + if id in self.cache: + del self.cache[id] + + self.db.deleteLink(f) + + self.core.pullManager.addEvent(e) + + p = self.getPackage(pid) + if not len(p.getChildren()): + p.delete() + + pyfiles = self.cache.values() + for pyfile in pyfiles: + if pyfile.packageid == pid and pyfile.order > oldorder: + pyfile.order -= 1 + pyfile.notifyChange() + + #-------------------------------------------------------------------------- + def releaseLink(self, id): + """removes pyfile from cache""" + if id in self.cache: + del self.cache[id] + + #-------------------------------------------------------------------------- + def releasePackage(self, id): + """removes package from cache""" + if id in self.packageCache: + del self.packageCache[id] + + #-------------------------------------------------------------------------- + def updateLink(self, pyfile): + """updates link""" + self.db.updateLink(pyfile) + + e = UpdateEvent("file", pyfile.id, "collector" if not pyfile.package().queue else "queue") + self.core.pullManager.addEvent(e) + + #-------------------------------------------------------------------------- + def updatePackage(self, pypack): + """updates a package""" + self.db.updatePackage(pypack) + + e = UpdateEvent("pack", pypack.id, "collector" if not pypack.queue else "queue") + self.core.pullManager.addEvent(e) + + #-------------------------------------------------------------------------- + def getPackage(self, id): + """return package instance""" + + if id in self.packageCache: + return self.packageCache[id] + else: + return self.db.getPackage(id) + + #-------------------------------------------------------------------------- + def getPackageData(self, id): + """returns dict with package information""" + pack = self.getPackage(id) + + if not pack: + return None + + pack = pack.toDict()[id] + + data = self.db.getPackageData(id) + + tmplist = [] + + cache = self.cache.values() + for x in cache: + if int(x.toDbDict()[x.id]["package"]) == int(id): + tmplist.append((x.id, x.toDbDict()[x.id])) + data.update(tmplist) + + pack["links"] = data + + return pack + + #-------------------------------------------------------------------------- + def getFileData(self, id): + """returns dict with file information""" + if id in self.cache: + return self.cache[id].toDbDict() + + return self.db.getLinkData(id) + + #-------------------------------------------------------------------------- + def getFile(self, id): + """returns pyfile instance""" + if id in self.cache: + return self.cache[id] + else: + return self.db.getFile(id) + + #-------------------------------------------------------------------------- + @lock + def getJob(self, occ): + """get suitable job""" + + #@TODO clean mess + #@TODO improve selection of valid jobs + + if occ in self.jobCache: + if self.jobCache[occ]: + id = self.jobCache[occ].pop() + if id == "empty": + pyfile = None + self.jobCache[occ].append("empty") + else: + pyfile = self.getFile(id) + else: + jobs = self.db.getJob(occ) + jobs.reverse() + if not jobs: + self.jobCache[occ].append("empty") + pyfile = None + else: + self.jobCache[occ].extend(jobs) + pyfile = self.getFile(self.jobCache[occ].pop()) + + else: + self.jobCache = {} #better not caching to much + jobs = self.db.getJob(occ) + jobs.reverse() + self.jobCache[occ] = jobs + + if not jobs: + self.jobCache[occ].append("empty") + pyfile = None + else: + pyfile = self.getFile(self.jobCache[occ].pop()) + + #@TODO: maybe the new job has to be approved... + + + #pyfile = self.getFile(self.jobCache[occ].pop()) + return pyfile + + @lock + def getDecryptJob(self): + """return job for decrypting""" + if "decrypt" in self.jobCache: + return None + + plugins = self.core.pluginManager.crypterPlugins.keys() + self.core.pluginManager.containerPlugins.keys() + plugins = str(tuple(plugins)) + + jobs = self.db.getPluginJob(plugins) + if jobs: + return self.getFile(jobs[0]) + else: + self.jobCache["decrypt"] = "empty" + return None + + def getFileCount(self): + """returns number of files""" + + if self.filecount == -1: + self.filecount = self.db.filecount(1) + + return self.filecount + + def getQueueCount(self, force=False): + """number of files that have to be processed""" + if self.queuecount == -1 or force: + self.queuecount = self.db.queuecount(1) + + return self.queuecount + + def checkAllLinksFinished(self): + """checks if all files are finished and dispatch event""" + + if not self.getQueueCount(True): + self.core.addonManager.dispatchEvent("all_downloads-finished") + self.core.log.debug("All downloads finished") + return True + + return False + + def checkAllLinksProcessed(self, fid): + """checks if all files was processed and pyload would idle now, needs fid which will be ignored when counting""" + + # reset count so statistic will update (this is called when dl was processed) + self.resetCount() + + if not self.db.processcount(1, fid): + self.core.addonManager.dispatchEvent("all_downloads-processed") + self.core.log.debug("All downloads processed") + return True + + return False + + def resetCount(self): + self.queuecount = -1 + + @lock + @change + def restartPackage(self, id): + """restart package""" + pyfiles = self.cache.values() + for pyfile in pyfiles: + if pyfile.packageid == id: + self.restartFile(pyfile.id) + + self.db.restartPackage(id) + + if id in self.packageCache: + self.packageCache[id].setFinished = False + + e = UpdateEvent("pack", id, "collector" if not self.getPackage(id).queue else "queue") + self.core.pullManager.addEvent(e) + + @lock + @change + def restartFile(self, id): + """ restart file""" + if id in self.cache: + self.cache[id].status = 3 + self.cache[id].name = self.cache[id].url + self.cache[id].error = "" + self.cache[id].abortDownload() + + + self.db.restartFile(id) + + e = UpdateEvent("file", id, "collector" if not self.getFile(id).package().queue else "queue") + self.core.pullManager.addEvent(e) + + @lock + @change + def setPackageLocation(self, id, queue): + """push package to queue""" + + p = self.db.getPackage(id) + oldorder = p.order + + e = RemoveEvent("pack", id, "collector" if not p.queue else "queue") + self.core.pullManager.addEvent(e) + + self.db.clearPackageOrder(p) + + p = self.db.getPackage(id) + + p.queue = queue + self.db.updatePackage(p) + + self.db.reorderPackage(p, -1, True) + + packs = self.packageCache.values() + for pack in packs: + if pack.queue != queue and pack.order > oldorder: + pack.order -= 1 + pack.notifyChange() + + self.db.commit() + self.releasePackage(id) + p = self.getPackage(id) + + e = InsertEvent("pack", id, p.order, "collector" if not p.queue else "queue") + self.core.pullManager.addEvent(e) + + @lock + @change + def reorderPackage(self, id, position): + p = self.getPackage(id) + + e = RemoveEvent("pack", id, "collector" if not p.queue else "queue") + self.core.pullManager.addEvent(e) + self.db.reorderPackage(p, position) + + packs = self.packageCache.values() + for pack in packs: + if pack.queue != p.queue or pack.order < 0 or pack == p: continue + if p.order > position: + if pack.order >= position and pack.order < p.order: + pack.order += 1 + pack.notifyChange() + elif p.order < position: + if pack.order <= position and pack.order > p.order: + pack.order -= 1 + pack.notifyChange() + + p.order = position + self.db.commit() + + e = InsertEvent("pack", id, position, "collector" if not p.queue else "queue") + self.core.pullManager.addEvent(e) + + @lock + @change + def reorderFile(self, id, position): + f = self.getFileData(id) + f = f[id] + + e = RemoveEvent("file", id, "collector" if not self.getPackage(f["package"]).queue else "queue") + self.core.pullManager.addEvent(e) + + self.db.reorderLink(f, position) + + pyfiles = self.cache.values() + for pyfile in pyfiles: + if pyfile.packageid != f["package"] or pyfile.order < 0: continue + if f["order"] > position: + if pyfile.order >= position and pyfile.order < f["order"]: + pyfile.order += 1 + pyfile.notifyChange() + elif f["order"] < position: + if pyfile.order <= position and pyfile.order > f["order"]: + pyfile.order -= 1 + pyfile.notifyChange() + + if id in self.cache: + self.cache[id].order = position + + self.db.commit() + + e = InsertEvent("file", id, position, "collector" if not self.getPackage(f["package"]).queue else "queue") + self.core.pullManager.addEvent(e) + + @change + def updateFileInfo(self, data, pid): + """ updates file info (name, size, status, url)""" + ids = self.db.updateLinkInfo(data) + e = UpdateEvent("pack", pid, "collector" if not self.getPackage(pid).queue else "queue") + self.core.pullManager.addEvent(e) + + def checkPackageFinished(self, pyfile): + """ checks if package is finished and calls AddonManager """ + + ids = self.db.getUnfinished(pyfile.packageid) + if not ids or (pyfile.id in ids and len(ids) == 1): + if not pyfile.package().setFinished: + self.core.log.info(_("Package finished: %s") % pyfile.package().name) + self.core.addonManager.packageFinished(pyfile.package()) + pyfile.package().setFinished = True + + + def reCheckPackage(self, pid): + """ recheck links in package """ + data = self.db.getPackageData(pid) + + urls = [] + + for pyfile in data.itervalues(): + if pyfile["status"] not in (0, 12, 13): + urls.append((pyfile["url"], pyfile["plugin"])) + + self.core.threadManager.createInfoThread(urls, pid) + + @lock + @change + def deleteFinishedLinks(self): + """ deletes finished links and packages, return deleted packages """ + + old_packs = self.getInfoData(0) + old_packs.update(self.getInfoData(1)) + + self.db.deleteFinished() + + new_packs = self.db.getAllPackages(0) + new_packs.update(self.db.getAllPackages(1)) + #get new packages only from db + + deleted = [] + for id in old_packs.iterkeys(): + if id not in new_packs: + deleted.append(id) + self.deletePackage(int(id)) + + return deleted + + @lock + @change + def restartFailed(self): + """ restart all failed links """ + self.db.restartFailed() + +class FileMethods(object): + @style.queue + def filecount(self, queue): + """returns number of files in queue""" + self.c.execute("SELECT COUNT(*) FROM links as l INNER JOIN packages as p ON l.package=p.id WHERE p.queue=?", (queue,)) + return self.c.fetchone()[0] + + @style.queue + def queuecount(self, queue): + """ number of files in queue not finished yet""" + self.c.execute("SELECT COUNT(*) FROM links as l INNER JOIN packages as p ON l.package=p.id WHERE p.queue=? AND l.status NOT IN (0, 4)", (queue,)) + return self.c.fetchone()[0] + + @style.queue + def processcount(self, queue, fid): + """ number of files which have to be proccessed """ + self.c.execute("SELECT COUNT(*) FROM links as l INNER JOIN packages as p ON l.package=p.id WHERE p.queue=? AND l.status IN (2, 3, 5, 7, 12) AND l.id != ?", (queue, str(fid))) + return self.c.fetchone()[0] + + @style.inner + def _nextPackageOrder(self, queue=0): + self.c.execute('SELECT MAX(packageorder) FROM packages WHERE queue=?', (queue,)) + max = self.c.fetchone()[0] + if max is not None: + return max + 1 + else: + return 0 + + @style.inner + def _nextFileOrder(self, package): + self.c.execute('SELECT MAX(linkorder) FROM links WHERE package=?', (package,)) + max = self.c.fetchone()[0] + if max is not None: + return max + 1 + else: + return 0 + + @style.queue + def addLink(self, url, name, plugin, package): + order = self._nextFileOrder(package) + self.c.execute('INSERT INTO links(url, name, plugin, package, linkorder) VALUES(?,?,?,?,?)', (url, name, (plugintype, pluginname), package, order)) + return self.c.lastrowid + + @style.queue + def addLinks(self, links, package): + """ links is a list of tupels (url, plugin)""" + order = self._nextFileOrder(package) + orders = [order + x for x in range(len(links))] + links = [(x[0], x[0], (x[1], x[2]), package, o) for x, o in zip(links, orders)] + self.c.executemany('INSERT INTO links(url, name, plugin, package, linkorder) VALUES(?,?,?,?,?)', links) + + @style.queue + def addPackage(self, name, folder, queue): + order = self._nextPackageOrder(queue) + self.c.execute('INSERT INTO packages(name, folder, queue, packageorder) VALUES(?,?,?,?)', (name, folder, queue, order)) + return self.c.lastrowid + + @style.queue + def deletePackage(self, p): + + self.c.execute('DELETE FROM links WHERE package=?', (str(p.id),)) + self.c.execute('DELETE FROM packages WHERE id=?', (str(p.id),)) + self.c.execute('UPDATE packages SET packageorder=packageorder-1 WHERE packageorder > ? AND queue=?', (p.order, p.queue)) + + @style.queue + def deleteLink(self, f): + + self.c.execute('DELETE FROM links WHERE id=?', (str(f.id),)) + self.c.execute('UPDATE links SET linkorder=linkorder-1 WHERE linkorder > ? AND package=?', (f.order, str(f.packageid))) + + + @style.queue + def getAllLinks(self, q): + """return information about all links in queue q + + q0 queue + q1 collector + + format: + + { + id: {'name': name, ... 'package': id }, ... + } + + """ + self.c.execute('SELECT l.id, l.url, l.name, l.size, l.status, l.error, l.plugin, l.package, l.linkorder FROM links as l INNER JOIN packages as p ON l.package=p.id WHERE p.queue=? ORDER BY l.linkorder', (q,)) + data = {} + for r in self.c: + data[r[0]] = { + 'id': r[0], + 'url': r[1], + 'name': r[2], + 'size': r[3], + 'format_size': formatSize(r[3]), + 'status': r[4], + 'statusmsg': self.manager.statusMsg[r[4]], + 'error': r[5], + 'plugin': r[6], + 'package': r[7], + 'order': r[8], + } + + return data + + @style.queue + def getAllPackages(self, q): + """return information about packages in queue q + (only useful in get all data) + + q0 queue + q1 collector + + format: + + { + id: {'name': name ... 'links': {}}, ... + } + """ + self.c.execute('SELECT p.id, p.name, p.folder, p.site, p.password, p.queue, p.packageorder, s.sizetotal, s.sizedone, s.linksdone, s.linkstotal \ + FROM packages p JOIN pstats s ON p.id = s.id \ + WHERE p.queue=? ORDER BY p.packageorder', str(q)) + + data = {} + for r in self.c: + data[r[0]] = { + 'id': r[0], + 'name': r[1], + 'folder': r[2], + 'site': r[3], + 'password': r[4], + 'queue': r[5], + 'order': r[6], + 'sizetotal': int(r[7]), + 'sizedone': r[8] if r[8] else 0, #these can be None + 'linksdone': r[9] if r[9] else 0, + 'linkstotal': r[10], + 'links': {} + } + + return data + + @style.queue + def getLinkData(self, id): + """get link information as dict""" + self.c.execute('SELECT id, url, name, size, status, error, plugin, package, linkorder FROM links WHERE id=?', (str(id),)) + data = {} + r = self.c.fetchone() + if not r: + return None + data[r[0]] = { + 'id': r[0], + 'url': r[1], + 'name': r[2], + 'size': r[3], + 'format_size': formatSize(r[3]), + 'status': r[4], + 'statusmsg': self.manager.statusMsg[r[4]], + 'error': r[5], + 'plugin': r[6], + 'package': r[7], + 'order': r[8], + } + + return data + + @style.queue + def getPackageData(self, id): + """get data about links for a package""" + self.c.execute('SELECT id, url, name, size, status, error, plugin, package, linkorder FROM links WHERE package=? ORDER BY linkorder', (str(id),)) + + data = {} + for r in self.c: + data[r[0]] = { + 'id': r[0], + 'url': r[1], + 'name': r[2], + 'size': r[3], + 'format_size': formatSize(r[3]), + 'status': r[4], + 'statusmsg': self.manager.statusMsg[r[4]], + 'error': r[5], + 'plugin': r[6], + 'package': r[7], + 'order': r[8], + } + + return data + + + @style.async + def updateLink(self, f): + self.c.execute('UPDATE links SET url=?, name=?, size=?, status=?, error=?, package=? WHERE id=?', (f.url, f.name, f.size, f.status, f.error, str(f.packageid), str(f.id))) + + @style.queue + def updatePackage(self, p): + self.c.execute('UPDATE packages SET name=?, folder=?, site=?, password=?, queue=? WHERE id=?', (p.name, p.folder, p.site, p.password, p.queue, str(p.id))) + + @style.queue + def updateLinkInfo(self, data): + """ data is list of tupels (name, size, status, url) """ + self.c.executemany('UPDATE links SET name=?, size=?, status=? WHERE url=? AND status IN (1, 2, 3, 14)', data) + ids = [] + self.c.execute('SELECT id FROM links WHERE url IN (\'%s\')' % "','".join([x[3] for x in data])) + for r in self.c: + ids.append(int(r[0])) + return ids + + @style.queue + def reorderPackage(self, p, position, noMove=False): + if position == -1: + position = self._nextPackageOrder(p.queue) + if not noMove: + if p.order > position: + self.c.execute('UPDATE packages SET packageorder=packageorder+1 WHERE packageorder >= ? AND packageorder < ? AND queue=? AND packageorder >= 0', (position, p.order, p.queue)) + elif p.order < position: + self.c.execute('UPDATE packages SET packageorder=packageorder-1 WHERE packageorder <= ? AND packageorder > ? AND queue=? AND packageorder >= 0', (position, p.order, p.queue)) + + self.c.execute('UPDATE packages SET packageorder=? WHERE id=?', (position, str(p.id))) + + @style.queue + def reorderLink(self, f, position): + """ reorder link with f as dict for pyfile """ + if f["order"] > position: + self.c.execute('UPDATE links SET linkorder=linkorder+1 WHERE linkorder >= ? AND linkorder < ? AND package=?', (position, f["order"], f["package"])) + elif f["order"] < position: + self.c.execute('UPDATE links SET linkorder=linkorder-1 WHERE linkorder <= ? AND linkorder > ? AND package=?', (position, f["order"], f["package"])) + + self.c.execute('UPDATE links SET linkorder=? WHERE id=?', (position, f["id"])) + + @style.queue + def clearPackageOrder(self, p): + self.c.execute('UPDATE packages SET packageorder=? WHERE id=?', (-1, str(p.id))) + self.c.execute('UPDATE packages SET packageorder=packageorder-1 WHERE packageorder > ? AND queue=? AND id != ?', (p.order, p.queue, str(p.id))) + + @style.async + def restartFile(self, id): + self.c.execute('UPDATE links SET status=3, error="" WHERE id=?', (str(id),)) + + @style.async + def restartPackage(self, id): + self.c.execute('UPDATE links SET status=3 WHERE package=?', (str(id),)) + + @style.queue + def getPackage(self, id): + """return package instance from id""" + self.c.execute("SELECT name, folder, site, password, queue, packageorder FROM packages WHERE id=?", (str(id),)) + r = self.c.fetchone() + if not r: return None + return PyPackage(self.manager, id, * r) + + #-------------------------------------------------------------------------- + @style.queue + def getFile(self, id): + """return link instance from id""" + self.c.execute("SELECT url, name, size, status, error, plugin, package, linkorder FROM links WHERE id=?", (str(id),)) + r = self.c.fetchone() + if not r: return None + return PyFile(self.manager, id, * r) + + + @style.queue + def getJob(self, occ): + """return pyfile ids, which are suitable for download and dont use a occupied plugin""" + + #@TODO improve this hardcoded method + pre = "('DLC', 'LinkList', 'SerienjunkiesOrg', 'CCF', 'RSDF')" #plugins which are processed in collector + + cmd = "(" + for i, item in enumerate(occ): + if i: cmd += ", " + cmd += "'%s'" % item + + cmd += ")" + + cmd = "SELECT l.id FROM links as l INNER JOIN packages as p ON l.package=p.id WHERE ((p.queue=1 AND l.plugin NOT IN %s) OR l.plugin IN %s) AND l.status IN (2, 3, 14) ORDER BY p.packageorder ASC, l.linkorder ASC LIMIT 5" % (cmd, pre) + + self.c.execute(cmd) # very bad! + + return [x[0] for x in self.c] + + @style.queue + def getPluginJob(self, plugins): + """returns pyfile ids with suited plugins""" + cmd = "SELECT l.id FROM links as l INNER JOIN packages as p ON l.package=p.id WHERE l.plugin IN %s AND l.status IN (2, 3, 14) ORDER BY p.packageorder ASC, l.linkorder ASC LIMIT 5" % plugins + + self.c.execute(cmd) # very bad! + + return [x[0] for x in self.c] + + @style.queue + def getUnfinished(self, pid): + """return list of max length 3 ids with pyfiles in package not finished or processed""" + + self.c.execute("SELECT id FROM links WHERE package=? AND status NOT IN (0, 4, 13) LIMIT 3", (str(pid),)) + return [r[0] for r in self.c] + + @style.queue + def deleteFinished(self): + self.c.execute("DELETE FROM links WHERE status IN (0, 4)") + self.c.execute("DELETE FROM packages WHERE NOT EXISTS(SELECT 1 FROM links WHERE packages.id=links.package)") + + @style.queue + def restartFailed(self): + self.c.execute("UPDATE links SET status=3, error='' WHERE status IN (6, 8, 9)") + + @style.queue + def findDuplicates(self, id, folder, filename): + """ checks if filename exists with different id and same package """ + self.c.execute("SELECT l.plugin FROM links as l INNER JOIN packages as p ON l.package=p.id AND p.folder=? WHERE l.id!=? AND l.status=0 AND l.name=?", (folder, id, filename)) + return self.c.fetchone() + + @style.queue + def purgeLinks(self): + self.c.execute("DELETE FROM links;") + self.c.execute("DELETE FROM packages;") + +DatabaseBackend.registerSub(FileMethods) diff --git a/pyload/database/FileDatabase.py b/pyload/database/FileDatabase.py deleted file mode 100644 index 933e06d80..000000000 --- a/pyload/database/FileDatabase.py +++ /dev/null @@ -1,875 +0,0 @@ -# -*- coding: utf-8 -*- -# @author: RaNaN, mkaay - -from threading import RLock -from time import time - -from pyload.utils import formatSize, lock -from pyload.manager.event.PullEvents import InsertEvent, ReloadAllEvent, RemoveEvent, UpdateEvent -from pyload.datatype.PyPackage import PyPackage -from pyload.datatype.PyFile import PyFile -from pyload.database import style, DatabaseBackend - -try: - from pysqlite2 import dbapi2 as sqlite3 -except Exception: - import sqlite3 - - -class FileHandler(object): - """Handles all request made to obtain information, - modify status or other request for links or packages""" - - def __init__(self, core): - """Constructor""" - self.core = core - - # translations - self.statusMsg = [_("finished"), _("offline"), _("online"), _("queued"), _("skipped"), _("waiting"), _("temp. offline"), _("starting"), _("failed"), _("aborted"), _("decrypting"), _("custom"), _("downloading"), _("processing"), _("unknown")] - - self.cache = {} #holds instances for files - self.packageCache = {} # same for packages - #@TODO: purge the cache - - self.jobCache = {} - - self.lock = RLock() #@TODO should be a Lock w/o R - #self.lock._Verbose__verbose = True - - self.filecount = -1 # if an invalid value is set get current value from db - self.queuecount = -1 #number of package to be loaded - self.unchanged = False #determines if any changes was made since last call - - self.db = self.core.db - - def change(func): - def new(*args): - args[0].unchanged = False - args[0].filecount = -1 - args[0].queuecount = -1 - args[0].jobCache = {} - return func(*args) - return new - - #-------------------------------------------------------------------------- - def save(self): - """saves all data to backend""" - self.db.commit() - - #-------------------------------------------------------------------------- - def syncSave(self): - """saves all data to backend and waits until all data are written""" - pyfiles = self.cache.values() - for pyfile in pyfiles: - pyfile.sync() - - pypacks = self.packageCache.values() - for pypack in pypacks: - pypack.sync() - - self.db.syncSave() - - @lock - def getCompleteData(self, queue=1): - """gets a complete data representation""" - - data = self.db.getAllLinks(queue) - packs = self.db.getAllPackages(queue) - - data.update([(x.id, x.toDbDict()[x.id]) for x in self.cache.values()]) - - for x in self.packageCache.itervalues(): - if x.queue != queue or x.id not in packs: continue - packs[x.id].update(x.toDict()[x.id]) - - for key, value in data.iteritems(): - if value["package"] in packs: - packs[value["package"]]["links"][key] = value - - return packs - - @lock - def getInfoData(self, queue=1): - """gets a data representation without links""" - - packs = self.db.getAllPackages(queue) - for x in self.packageCache.itervalues(): - if x.queue != queue or x.id not in packs: continue - packs[x.id].update(x.toDict()[x.id]) - - return packs - - @lock - @change - def addLinks(self, urls, package): - """adds links""" - - self.core.addonManager.dispatchEvent("links-added", urls, package) - - data = self.core.pluginManager.parseUrls(urls) - - self.db.addLinks(data, package) - self.core.threadManager.createInfoThread(data, package) - - #@TODO change from reloadAll event to package update event - self.core.pullManager.addEvent(ReloadAllEvent("collector")) - - #-------------------------------------------------------------------------- - @lock - @change - def addPackage(self, name, folder, queue=0): - """adds a package, default to link collector""" - lastID = self.db.addPackage(name, folder, queue) - p = self.db.getPackage(lastID) - e = InsertEvent("pack", lastID, p.order, "collector" if not queue else "queue") - self.core.pullManager.addEvent(e) - return lastID - - #-------------------------------------------------------------------------- - @lock - @change - def deletePackage(self, id): - """delete package and all contained links""" - - p = self.getPackage(id) - if not p: - if id in self.packageCache: del self.packageCache[id] - return - - oldorder = p.order - queue = p.queue - - e = RemoveEvent("pack", id, "collector" if not p.queue else "queue") - - pyfiles = self.cache.values() - - for pyfile in pyfiles: - if pyfile.packageid == id: - pyfile.abortDownload() - pyfile.release() - - self.db.deletePackage(p) - self.core.pullManager.addEvent(e) - self.core.addonManager.dispatchEvent("package-deleted", id) - - if id in self.packageCache: - del self.packageCache[id] - - packs = self.packageCache.values() - for pack in packs: - if pack.queue == queue and pack.order > oldorder: - pack.order -= 1 - pack.notifyChange() - - #-------------------------------------------------------------------------- - @lock - @change - def deleteLink(self, id): - """deletes links""" - - f = self.getFile(id) - if not f: - return None - - pid = f.packageid - e = RemoveEvent("file", id, "collector" if not f.package().queue else "queue") - - oldorder = f.order - - if id in self.core.threadManager.processingIds(): - self.cache[id].abortDownload() - - if id in self.cache: - del self.cache[id] - - self.db.deleteLink(f) - - self.core.pullManager.addEvent(e) - - p = self.getPackage(pid) - if not len(p.getChildren()): - p.delete() - - pyfiles = self.cache.values() - for pyfile in pyfiles: - if pyfile.packageid == pid and pyfile.order > oldorder: - pyfile.order -= 1 - pyfile.notifyChange() - - #-------------------------------------------------------------------------- - def releaseLink(self, id): - """removes pyfile from cache""" - if id in self.cache: - del self.cache[id] - - #-------------------------------------------------------------------------- - def releasePackage(self, id): - """removes package from cache""" - if id in self.packageCache: - del self.packageCache[id] - - #-------------------------------------------------------------------------- - def updateLink(self, pyfile): - """updates link""" - self.db.updateLink(pyfile) - - e = UpdateEvent("file", pyfile.id, "collector" if not pyfile.package().queue else "queue") - self.core.pullManager.addEvent(e) - - #-------------------------------------------------------------------------- - def updatePackage(self, pypack): - """updates a package""" - self.db.updatePackage(pypack) - - e = UpdateEvent("pack", pypack.id, "collector" if not pypack.queue else "queue") - self.core.pullManager.addEvent(e) - - #-------------------------------------------------------------------------- - def getPackage(self, id): - """return package instance""" - - if id in self.packageCache: - return self.packageCache[id] - else: - return self.db.getPackage(id) - - #-------------------------------------------------------------------------- - def getPackageData(self, id): - """returns dict with package information""" - pack = self.getPackage(id) - - if not pack: - return None - - pack = pack.toDict()[id] - - data = self.db.getPackageData(id) - - tmplist = [] - - cache = self.cache.values() - for x in cache: - if int(x.toDbDict()[x.id]["package"]) == int(id): - tmplist.append((x.id, x.toDbDict()[x.id])) - data.update(tmplist) - - pack["links"] = data - - return pack - - #-------------------------------------------------------------------------- - def getFileData(self, id): - """returns dict with file information""" - if id in self.cache: - return self.cache[id].toDbDict() - - return self.db.getLinkData(id) - - #-------------------------------------------------------------------------- - def getFile(self, id): - """returns pyfile instance""" - if id in self.cache: - return self.cache[id] - else: - return self.db.getFile(id) - - #-------------------------------------------------------------------------- - @lock - def getJob(self, occ): - """get suitable job""" - - #@TODO clean mess - #@TODO improve selection of valid jobs - - if occ in self.jobCache: - if self.jobCache[occ]: - id = self.jobCache[occ].pop() - if id == "empty": - pyfile = None - self.jobCache[occ].append("empty") - else: - pyfile = self.getFile(id) - else: - jobs = self.db.getJob(occ) - jobs.reverse() - if not jobs: - self.jobCache[occ].append("empty") - pyfile = None - else: - self.jobCache[occ].extend(jobs) - pyfile = self.getFile(self.jobCache[occ].pop()) - - else: - self.jobCache = {} #better not caching to much - jobs = self.db.getJob(occ) - jobs.reverse() - self.jobCache[occ] = jobs - - if not jobs: - self.jobCache[occ].append("empty") - pyfile = None - else: - pyfile = self.getFile(self.jobCache[occ].pop()) - - #@TODO: maybe the new job has to be approved... - - - #pyfile = self.getFile(self.jobCache[occ].pop()) - return pyfile - - @lock - def getDecryptJob(self): - """return job for decrypting""" - if "decrypt" in self.jobCache: - return None - - plugins = self.core.pluginManager.crypterPlugins.keys() + self.core.pluginManager.containerPlugins.keys() - plugins = str(tuple(plugins)) - - jobs = self.db.getPluginJob(plugins) - if jobs: - return self.getFile(jobs[0]) - else: - self.jobCache["decrypt"] = "empty" - return None - - def getFileCount(self): - """returns number of files""" - - if self.filecount == -1: - self.filecount = self.db.filecount(1) - - return self.filecount - - def getQueueCount(self, force=False): - """number of files that have to be processed""" - if self.queuecount == -1 or force: - self.queuecount = self.db.queuecount(1) - - return self.queuecount - - def checkAllLinksFinished(self): - """checks if all files are finished and dispatch event""" - - if not self.getQueueCount(True): - self.core.addonManager.dispatchEvent("all_downloads-finished") - self.core.log.debug("All downloads finished") - return True - - return False - - def checkAllLinksProcessed(self, fid): - """checks if all files was processed and pyload would idle now, needs fid which will be ignored when counting""" - - # reset count so statistic will update (this is called when dl was processed) - self.resetCount() - - if not self.db.processcount(1, fid): - self.core.addonManager.dispatchEvent("all_downloads-processed") - self.core.log.debug("All downloads processed") - return True - - return False - - def resetCount(self): - self.queuecount = -1 - - @lock - @change - def restartPackage(self, id): - """restart package""" - pyfiles = self.cache.values() - for pyfile in pyfiles: - if pyfile.packageid == id: - self.restartFile(pyfile.id) - - self.db.restartPackage(id) - - if id in self.packageCache: - self.packageCache[id].setFinished = False - - e = UpdateEvent("pack", id, "collector" if not self.getPackage(id).queue else "queue") - self.core.pullManager.addEvent(e) - - @lock - @change - def restartFile(self, id): - """ restart file""" - if id in self.cache: - self.cache[id].status = 3 - self.cache[id].name = self.cache[id].url - self.cache[id].error = "" - self.cache[id].abortDownload() - - - self.db.restartFile(id) - - e = UpdateEvent("file", id, "collector" if not self.getFile(id).package().queue else "queue") - self.core.pullManager.addEvent(e) - - @lock - @change - def setPackageLocation(self, id, queue): - """push package to queue""" - - p = self.db.getPackage(id) - oldorder = p.order - - e = RemoveEvent("pack", id, "collector" if not p.queue else "queue") - self.core.pullManager.addEvent(e) - - self.db.clearPackageOrder(p) - - p = self.db.getPackage(id) - - p.queue = queue - self.db.updatePackage(p) - - self.db.reorderPackage(p, -1, True) - - packs = self.packageCache.values() - for pack in packs: - if pack.queue != queue and pack.order > oldorder: - pack.order -= 1 - pack.notifyChange() - - self.db.commit() - self.releasePackage(id) - p = self.getPackage(id) - - e = InsertEvent("pack", id, p.order, "collector" if not p.queue else "queue") - self.core.pullManager.addEvent(e) - - @lock - @change - def reorderPackage(self, id, position): - p = self.getPackage(id) - - e = RemoveEvent("pack", id, "collector" if not p.queue else "queue") - self.core.pullManager.addEvent(e) - self.db.reorderPackage(p, position) - - packs = self.packageCache.values() - for pack in packs: - if pack.queue != p.queue or pack.order < 0 or pack == p: continue - if p.order > position: - if pack.order >= position and pack.order < p.order: - pack.order += 1 - pack.notifyChange() - elif p.order < position: - if pack.order <= position and pack.order > p.order: - pack.order -= 1 - pack.notifyChange() - - p.order = position - self.db.commit() - - e = InsertEvent("pack", id, position, "collector" if not p.queue else "queue") - self.core.pullManager.addEvent(e) - - @lock - @change - def reorderFile(self, id, position): - f = self.getFileData(id) - f = f[id] - - e = RemoveEvent("file", id, "collector" if not self.getPackage(f["package"]).queue else "queue") - self.core.pullManager.addEvent(e) - - self.db.reorderLink(f, position) - - pyfiles = self.cache.values() - for pyfile in pyfiles: - if pyfile.packageid != f["package"] or pyfile.order < 0: continue - if f["order"] > position: - if pyfile.order >= position and pyfile.order < f["order"]: - pyfile.order += 1 - pyfile.notifyChange() - elif f["order"] < position: - if pyfile.order <= position and pyfile.order > f["order"]: - pyfile.order -= 1 - pyfile.notifyChange() - - if id in self.cache: - self.cache[id].order = position - - self.db.commit() - - e = InsertEvent("file", id, position, "collector" if not self.getPackage(f["package"]).queue else "queue") - self.core.pullManager.addEvent(e) - - @change - def updateFileInfo(self, data, pid): - """ updates file info (name, size, status, url)""" - ids = self.db.updateLinkInfo(data) - e = UpdateEvent("pack", pid, "collector" if not self.getPackage(pid).queue else "queue") - self.core.pullManager.addEvent(e) - - def checkPackageFinished(self, pyfile): - """ checks if package is finished and calls AddonManager """ - - ids = self.db.getUnfinished(pyfile.packageid) - if not ids or (pyfile.id in ids and len(ids) == 1): - if not pyfile.package().setFinished: - self.core.log.info(_("Package finished: %s") % pyfile.package().name) - self.core.addonManager.packageFinished(pyfile.package()) - pyfile.package().setFinished = True - - - def reCheckPackage(self, pid): - """ recheck links in package """ - data = self.db.getPackageData(pid) - - urls = [] - - for pyfile in data.itervalues(): - if pyfile["status"] not in (0, 12, 13): - urls.append((pyfile["url"], pyfile["plugin"])) - - self.core.threadManager.createInfoThread(urls, pid) - - @lock - @change - def deleteFinishedLinks(self): - """ deletes finished links and packages, return deleted packages """ - - old_packs = self.getInfoData(0) - old_packs.update(self.getInfoData(1)) - - self.db.deleteFinished() - - new_packs = self.db.getAllPackages(0) - new_packs.update(self.db.getAllPackages(1)) - #get new packages only from db - - deleted = [] - for id in old_packs.iterkeys(): - if id not in new_packs: - deleted.append(id) - self.deletePackage(int(id)) - - return deleted - - @lock - @change - def restartFailed(self): - """ restart all failed links """ - self.db.restartFailed() - -class FileMethods(object): - @style.queue - def filecount(self, queue): - """returns number of files in queue""" - self.c.execute("SELECT COUNT(*) FROM links as l INNER JOIN packages as p ON l.package=p.id WHERE p.queue=?", (queue,)) - return self.c.fetchone()[0] - - @style.queue - def queuecount(self, queue): - """ number of files in queue not finished yet""" - self.c.execute("SELECT COUNT(*) FROM links as l INNER JOIN packages as p ON l.package=p.id WHERE p.queue=? AND l.status NOT IN (0, 4)", (queue,)) - return self.c.fetchone()[0] - - @style.queue - def processcount(self, queue, fid): - """ number of files which have to be proccessed """ - self.c.execute("SELECT COUNT(*) FROM links as l INNER JOIN packages as p ON l.package=p.id WHERE p.queue=? AND l.status IN (2, 3, 5, 7, 12) AND l.id != ?", (queue, str(fid))) - return self.c.fetchone()[0] - - @style.inner - def _nextPackageOrder(self, queue=0): - self.c.execute('SELECT MAX(packageorder) FROM packages WHERE queue=?', (queue,)) - max = self.c.fetchone()[0] - if max is not None: - return max + 1 - else: - return 0 - - @style.inner - def _nextFileOrder(self, package): - self.c.execute('SELECT MAX(linkorder) FROM links WHERE package=?', (package,)) - max = self.c.fetchone()[0] - if max is not None: - return max + 1 - else: - return 0 - - @style.queue - def addLink(self, url, name, plugin, package): - order = self._nextFileOrder(package) - self.c.execute('INSERT INTO links(url, name, plugin, package, linkorder) VALUES(?,?,?,?,?)', (url, name, (plugintype, pluginname), package, order)) - return self.c.lastrowid - - @style.queue - def addLinks(self, links, package): - """ links is a list of tupels (url, plugin)""" - order = self._nextFileOrder(package) - orders = [order + x for x in range(len(links))] - links = [(x[0], x[0], (x[1], x[2]), package, o) for x, o in zip(links, orders)] - self.c.executemany('INSERT INTO links(url, name, plugin, package, linkorder) VALUES(?,?,?,?,?)', links) - - @style.queue - def addPackage(self, name, folder, queue): - order = self._nextPackageOrder(queue) - self.c.execute('INSERT INTO packages(name, folder, queue, packageorder) VALUES(?,?,?,?)', (name, folder, queue, order)) - return self.c.lastrowid - - @style.queue - def deletePackage(self, p): - - self.c.execute('DELETE FROM links WHERE package=?', (str(p.id),)) - self.c.execute('DELETE FROM packages WHERE id=?', (str(p.id),)) - self.c.execute('UPDATE packages SET packageorder=packageorder-1 WHERE packageorder > ? AND queue=?', (p.order, p.queue)) - - @style.queue - def deleteLink(self, f): - - self.c.execute('DELETE FROM links WHERE id=?', (str(f.id),)) - self.c.execute('UPDATE links SET linkorder=linkorder-1 WHERE linkorder > ? AND package=?', (f.order, str(f.packageid))) - - - @style.queue - def getAllLinks(self, q): - """return information about all links in queue q - - q0 queue - q1 collector - - format: - - { - id: {'name': name, ... 'package': id }, ... - } - - """ - self.c.execute('SELECT l.id, l.url, l.name, l.size, l.status, l.error, l.plugin, l.package, l.linkorder FROM links as l INNER JOIN packages as p ON l.package=p.id WHERE p.queue=? ORDER BY l.linkorder', (q,)) - data = {} - for r in self.c: - data[r[0]] = { - 'id': r[0], - 'url': r[1], - 'name': r[2], - 'size': r[3], - 'format_size': formatSize(r[3]), - 'status': r[4], - 'statusmsg': self.manager.statusMsg[r[4]], - 'error': r[5], - 'plugin': r[6], - 'package': r[7], - 'order': r[8], - } - - return data - - @style.queue - def getAllPackages(self, q): - """return information about packages in queue q - (only useful in get all data) - - q0 queue - q1 collector - - format: - - { - id: {'name': name ... 'links': {}}, ... - } - """ - self.c.execute('SELECT p.id, p.name, p.folder, p.site, p.password, p.queue, p.packageorder, s.sizetotal, s.sizedone, s.linksdone, s.linkstotal \ - FROM packages p JOIN pstats s ON p.id = s.id \ - WHERE p.queue=? ORDER BY p.packageorder', str(q)) - - data = {} - for r in self.c: - data[r[0]] = { - 'id': r[0], - 'name': r[1], - 'folder': r[2], - 'site': r[3], - 'password': r[4], - 'queue': r[5], - 'order': r[6], - 'sizetotal': int(r[7]), - 'sizedone': r[8] if r[8] else 0, #these can be None - 'linksdone': r[9] if r[9] else 0, - 'linkstotal': r[10], - 'links': {} - } - - return data - - @style.queue - def getLinkData(self, id): - """get link information as dict""" - self.c.execute('SELECT id, url, name, size, status, error, plugin, package, linkorder FROM links WHERE id=?', (str(id),)) - data = {} - r = self.c.fetchone() - if not r: - return None - data[r[0]] = { - 'id': r[0], - 'url': r[1], - 'name': r[2], - 'size': r[3], - 'format_size': formatSize(r[3]), - 'status': r[4], - 'statusmsg': self.manager.statusMsg[r[4]], - 'error': r[5], - 'plugin': r[6], - 'package': r[7], - 'order': r[8], - } - - return data - - @style.queue - def getPackageData(self, id): - """get data about links for a package""" - self.c.execute('SELECT id, url, name, size, status, error, plugin, package, linkorder FROM links WHERE package=? ORDER BY linkorder', (str(id),)) - - data = {} - for r in self.c: - data[r[0]] = { - 'id': r[0], - 'url': r[1], - 'name': r[2], - 'size': r[3], - 'format_size': formatSize(r[3]), - 'status': r[4], - 'statusmsg': self.manager.statusMsg[r[4]], - 'error': r[5], - 'plugin': r[6], - 'package': r[7], - 'order': r[8], - } - - return data - - - @style.async - def updateLink(self, f): - self.c.execute('UPDATE links SET url=?, name=?, size=?, status=?, error=?, package=? WHERE id=?', (f.url, f.name, f.size, f.status, f.error, str(f.packageid), str(f.id))) - - @style.queue - def updatePackage(self, p): - self.c.execute('UPDATE packages SET name=?, folder=?, site=?, password=?, queue=? WHERE id=?', (p.name, p.folder, p.site, p.password, p.queue, str(p.id))) - - @style.queue - def updateLinkInfo(self, data): - """ data is list of tupels (name, size, status, url) """ - self.c.executemany('UPDATE links SET name=?, size=?, status=? WHERE url=? AND status IN (1, 2, 3, 14)', data) - ids = [] - self.c.execute('SELECT id FROM links WHERE url IN (\'%s\')' % "','".join([x[3] for x in data])) - for r in self.c: - ids.append(int(r[0])) - return ids - - @style.queue - def reorderPackage(self, p, position, noMove=False): - if position == -1: - position = self._nextPackageOrder(p.queue) - if not noMove: - if p.order > position: - self.c.execute('UPDATE packages SET packageorder=packageorder+1 WHERE packageorder >= ? AND packageorder < ? AND queue=? AND packageorder >= 0', (position, p.order, p.queue)) - elif p.order < position: - self.c.execute('UPDATE packages SET packageorder=packageorder-1 WHERE packageorder <= ? AND packageorder > ? AND queue=? AND packageorder >= 0', (position, p.order, p.queue)) - - self.c.execute('UPDATE packages SET packageorder=? WHERE id=?', (position, str(p.id))) - - @style.queue - def reorderLink(self, f, position): - """ reorder link with f as dict for pyfile """ - if f["order"] > position: - self.c.execute('UPDATE links SET linkorder=linkorder+1 WHERE linkorder >= ? AND linkorder < ? AND package=?', (position, f["order"], f["package"])) - elif f["order"] < position: - self.c.execute('UPDATE links SET linkorder=linkorder-1 WHERE linkorder <= ? AND linkorder > ? AND package=?', (position, f["order"], f["package"])) - - self.c.execute('UPDATE links SET linkorder=? WHERE id=?', (position, f["id"])) - - @style.queue - def clearPackageOrder(self, p): - self.c.execute('UPDATE packages SET packageorder=? WHERE id=?', (-1, str(p.id))) - self.c.execute('UPDATE packages SET packageorder=packageorder-1 WHERE packageorder > ? AND queue=? AND id != ?', (p.order, p.queue, str(p.id))) - - @style.async - def restartFile(self, id): - self.c.execute('UPDATE links SET status=3, error="" WHERE id=?', (str(id),)) - - @style.async - def restartPackage(self, id): - self.c.execute('UPDATE links SET status=3 WHERE package=?', (str(id),)) - - @style.queue - def getPackage(self, id): - """return package instance from id""" - self.c.execute("SELECT name, folder, site, password, queue, packageorder FROM packages WHERE id=?", (str(id),)) - r = self.c.fetchone() - if not r: return None - return PyPackage(self.manager, id, * r) - - #-------------------------------------------------------------------------- - @style.queue - def getFile(self, id): - """return link instance from id""" - self.c.execute("SELECT url, name, size, status, error, plugin, package, linkorder FROM links WHERE id=?", (str(id),)) - r = self.c.fetchone() - if not r: return None - return PyFile(self.manager, id, * r) - - - @style.queue - def getJob(self, occ): - """return pyfile ids, which are suitable for download and dont use a occupied plugin""" - - #@TODO improve this hardcoded method - pre = "('DLC', 'LinkList', 'SerienjunkiesOrg', 'CCF', 'RSDF')" #plugins which are processed in collector - - cmd = "(" - for i, item in enumerate(occ): - if i: cmd += ", " - cmd += "'%s'" % item - - cmd += ")" - - cmd = "SELECT l.id FROM links as l INNER JOIN packages as p ON l.package=p.id WHERE ((p.queue=1 AND l.plugin NOT IN %s) OR l.plugin IN %s) AND l.status IN (2, 3, 14) ORDER BY p.packageorder ASC, l.linkorder ASC LIMIT 5" % (cmd, pre) - - self.c.execute(cmd) # very bad! - - return [x[0] for x in self.c] - - @style.queue - def getPluginJob(self, plugins): - """returns pyfile ids with suited plugins""" - cmd = "SELECT l.id FROM links as l INNER JOIN packages as p ON l.package=p.id WHERE l.plugin IN %s AND l.status IN (2, 3, 14) ORDER BY p.packageorder ASC, l.linkorder ASC LIMIT 5" % plugins - - self.c.execute(cmd) # very bad! - - return [x[0] for x in self.c] - - @style.queue - def getUnfinished(self, pid): - """return list of max length 3 ids with pyfiles in package not finished or processed""" - - self.c.execute("SELECT id FROM links WHERE package=? AND status NOT IN (0, 4, 13) LIMIT 3", (str(pid),)) - return [r[0] for r in self.c] - - @style.queue - def deleteFinished(self): - self.c.execute("DELETE FROM links WHERE status IN (0, 4)") - self.c.execute("DELETE FROM packages WHERE NOT EXISTS(SELECT 1 FROM links WHERE packages.id=links.package)") - - @style.queue - def restartFailed(self): - self.c.execute("UPDATE links SET status=3, error='' WHERE status IN (6, 8, 9)") - - @style.queue - def findDuplicates(self, id, folder, filename): - """ checks if filename exists with different id and same package """ - self.c.execute("SELECT l.plugin FROM links as l INNER JOIN packages as p ON l.package=p.id AND p.folder=? WHERE l.id!=? AND l.status=0 AND l.name=?", (folder, id, filename)) - return self.c.fetchone() - - @style.queue - def purgeLinks(self): - self.c.execute("DELETE FROM links;") - self.c.execute("DELETE FROM packages;") - -DatabaseBackend.registerSub(FileMethods) diff --git a/pyload/database/Storage.py b/pyload/database/Storage.py new file mode 100644 index 000000000..75e166d39 --- /dev/null +++ b/pyload/database/Storage.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +# @author: mkaay + +from pyload.database import style +from pyload.database import DatabaseBackend + +class StorageMethods(object): + @style.queue + def setStorage(db, identifier, key, value): + db.c.execute("SELECT id FROM storage WHERE identifier=? AND key=?", (identifier, key)) + if db.c.fetchone() is not None: + db.c.execute("UPDATE storage SET value=? WHERE identifier=? AND key=?", (value, identifier, key)) + else: + db.c.execute("INSERT INTO storage (identifier, key, value) VALUES (?, ?, ?)", (identifier, key, value)) + + @style.queue + def getStorage(db, identifier, key=None): + if key is not None: + db.c.execute("SELECT value FROM storage WHERE identifier=? AND key=?", (identifier, key)) + row = db.c.fetchone() + if row is not None: + return row[0] + else: + db.c.execute("SELECT key, value FROM storage WHERE identifier=?", (identifier,)) + d = {} + for row in db.c: + d[row[0]] = row[1] + return d + + @style.queue + def delStorage(db, identifier, key): + db.c.execute("DELETE FROM storage WHERE identifier=? AND key=?", (identifier, key)) + +DatabaseBackend.registerSub(StorageMethods) diff --git a/pyload/database/StorageDatabase.py b/pyload/database/StorageDatabase.py deleted file mode 100644 index 75e166d39..000000000 --- a/pyload/database/StorageDatabase.py +++ /dev/null @@ -1,34 +0,0 @@ -# -*- coding: utf-8 -*- -# @author: mkaay - -from pyload.database import style -from pyload.database import DatabaseBackend - -class StorageMethods(object): - @style.queue - def setStorage(db, identifier, key, value): - db.c.execute("SELECT id FROM storage WHERE identifier=? AND key=?", (identifier, key)) - if db.c.fetchone() is not None: - db.c.execute("UPDATE storage SET value=? WHERE identifier=? AND key=?", (value, identifier, key)) - else: - db.c.execute("INSERT INTO storage (identifier, key, value) VALUES (?, ?, ?)", (identifier, key, value)) - - @style.queue - def getStorage(db, identifier, key=None): - if key is not None: - db.c.execute("SELECT value FROM storage WHERE identifier=? AND key=?", (identifier, key)) - row = db.c.fetchone() - if row is not None: - return row[0] - else: - db.c.execute("SELECT key, value FROM storage WHERE identifier=?", (identifier,)) - d = {} - for row in db.c: - d[row[0]] = row[1] - return d - - @style.queue - def delStorage(db, identifier, key): - db.c.execute("DELETE FROM storage WHERE identifier=? AND key=?", (identifier, key)) - -DatabaseBackend.registerSub(StorageMethods) diff --git a/pyload/database/User.py b/pyload/database/User.py new file mode 100644 index 000000000..67cb62ab9 --- /dev/null +++ b/pyload/database/User.py @@ -0,0 +1,93 @@ +# -*- coding: utf-8 -*- +# @author: mkaay + +from hashlib import sha1 +import random + +from pyload.database.DatabaseBackend import DatabaseBackend +from pyload.database.DatabaseBackend import style + +class UserMethods(object): + @style.queue + def checkAuth(db, user, password): + c = db.c + c.execute('SELECT id, name, password, role, permission, template, email FROM "users" WHERE name=?', (user,)) + r = c.fetchone() + if not r: + return {} + + salt = r[2][:5] + pw = r[2][5:] + h = sha1(salt + password) + if h.hexdigest() == pw: + return {"id": r[0], "name": r[1], "role": r[3], + "permission": r[4], "template": r[5], "email": r[6]} + else: + return {} + + @style.queue + def addUser(db, user, password): + salt = reduce(lambda x, y: x + y, [str(random.randint(0, 9)) for i in range(0, 5)]) + h = sha1(salt + password) + password = salt + h.hexdigest() + + c = db.c + c.execute('SELECT name FROM users WHERE name=?', (user,)) + if c.fetchone() is not None: + c.execute('UPDATE users SET password=? WHERE name=?', (password, user)) + else: + c.execute('INSERT INTO users (name, password) VALUES (?, ?)', (user, password)) + + + @style.queue + def changePassword(db, user, oldpw, newpw): + db.c.execute('SELECT id, name, password FROM users WHERE name=?', (user,)) + r = db.c.fetchone() + if not r: + return False + + salt = r[2][:5] + pw = r[2][5:] + h = sha1(salt + oldpw) + if h.hexdigest() == pw: + salt = reduce(lambda x, y: x + y, [str(random.randint(0, 9)) for i in range(0, 5)]) + h = sha1(salt + newpw) + password = salt + h.hexdigest() + + db.c.execute("UPDATE users SET password=? WHERE name=?", (password, user)) + return True + + return False + + + @style.async + def setPermission(db, user, perms): + db.c.execute("UPDATE users SET permission=? WHERE name=?", (perms, user)) + + @style.async + def setRole(db, user, role): + db.c.execute("UPDATE users SET role=? WHERE name=?", (role, user)) + + + @style.queue + def listUsers(db): + db.c.execute('SELECT name FROM users') + users = [] + for row in db.c: + users.append(row[0]) + return users + + @style.queue + def getAllUserData(db): + db.c.execute("SELECT name, permission, role, template, email FROM users") + user = {} + for r in db.c: + user[r[0]] = {"permission": r[1], "role": r[2], "template": r[3], "email": r[4]} + + return user + + @style.queue + def removeUser(db, user): + db.c.execute('DELETE FROM users WHERE name=?', (user,)) + +DatabaseBackend.registerSub(UserMethods) diff --git a/pyload/database/UserDatabase.py b/pyload/database/UserDatabase.py deleted file mode 100644 index 67cb62ab9..000000000 --- a/pyload/database/UserDatabase.py +++ /dev/null @@ -1,93 +0,0 @@ -# -*- coding: utf-8 -*- -# @author: mkaay - -from hashlib import sha1 -import random - -from pyload.database.DatabaseBackend import DatabaseBackend -from pyload.database.DatabaseBackend import style - -class UserMethods(object): - @style.queue - def checkAuth(db, user, password): - c = db.c - c.execute('SELECT id, name, password, role, permission, template, email FROM "users" WHERE name=?', (user,)) - r = c.fetchone() - if not r: - return {} - - salt = r[2][:5] - pw = r[2][5:] - h = sha1(salt + password) - if h.hexdigest() == pw: - return {"id": r[0], "name": r[1], "role": r[3], - "permission": r[4], "template": r[5], "email": r[6]} - else: - return {} - - @style.queue - def addUser(db, user, password): - salt = reduce(lambda x, y: x + y, [str(random.randint(0, 9)) for i in range(0, 5)]) - h = sha1(salt + password) - password = salt + h.hexdigest() - - c = db.c - c.execute('SELECT name FROM users WHERE name=?', (user,)) - if c.fetchone() is not None: - c.execute('UPDATE users SET password=? WHERE name=?', (password, user)) - else: - c.execute('INSERT INTO users (name, password) VALUES (?, ?)', (user, password)) - - - @style.queue - def changePassword(db, user, oldpw, newpw): - db.c.execute('SELECT id, name, password FROM users WHERE name=?', (user,)) - r = db.c.fetchone() - if not r: - return False - - salt = r[2][:5] - pw = r[2][5:] - h = sha1(salt + oldpw) - if h.hexdigest() == pw: - salt = reduce(lambda x, y: x + y, [str(random.randint(0, 9)) for i in range(0, 5)]) - h = sha1(salt + newpw) - password = salt + h.hexdigest() - - db.c.execute("UPDATE users SET password=? WHERE name=?", (password, user)) - return True - - return False - - - @style.async - def setPermission(db, user, perms): - db.c.execute("UPDATE users SET permission=? WHERE name=?", (perms, user)) - - @style.async - def setRole(db, user, role): - db.c.execute("UPDATE users SET role=? WHERE name=?", (role, user)) - - - @style.queue - def listUsers(db): - db.c.execute('SELECT name FROM users') - users = [] - for row in db.c: - users.append(row[0]) - return users - - @style.queue - def getAllUserData(db): - db.c.execute("SELECT name, permission, role, template, email FROM users") - user = {} - for r in db.c: - user[r[0]] = {"permission": r[1], "role": r[2], "template": r[3], "email": r[4]} - - return user - - @style.queue - def removeUser(db, user): - db.c.execute('DELETE FROM users WHERE name=?', (user,)) - -DatabaseBackend.registerSub(UserMethods) diff --git a/pyload/database/__init__.py b/pyload/database/__init__.py index 5c6658f01..64f049be1 100644 --- a/pyload/database/__init__.py +++ b/pyload/database/__init__.py @@ -2,6 +2,6 @@ from pyload.database.DatabaseBackend import DatabaseBackend, style -from pyload.database.FileDatabase import FileHandler -from pyload.database.UserDatabase import UserMethods -from pyload.database.StorageDatabase import StorageMethods +from pyload.database.File import FileHandler +from pyload.database.User import UserMethods +from pyload.database.Storage import StorageMethods diff --git a/pyload/datatype/File.py b/pyload/datatype/File.py new file mode 100644 index 000000000..1df0a8590 --- /dev/null +++ b/pyload/datatype/File.py @@ -0,0 +1,270 @@ +# -*- coding: utf-8 -*- +# @author: RaNaN, mkaay + +from pyload.manager.Event import UpdateEvent +from pyload.utils import formatSize, lock + +from time import sleep, time + +from threading import RLock + +statusMap = { + "finished": 0, + "offline": 1, + "online": 2, + "queued": 3, + "skipped": 4, + "waiting": 5, + "temp. offline": 6, + "starting": 7, + "failed": 8, + "aborted": 9, + "decrypting": 10, + "custom": 11, + "downloading": 12, + "processing": 13, + "unknown": 14, +} + + +def setSize(self, value): + self._size = int(value) + +class PyFile(object): + """ + Represents a file object at runtime + """ + __slots__ = ("m", "id", "url", "name", "size", "_size", "status", "plugin", + "packageid", "error", "order", "lock", "plugin", "waitUntil", + "active", "abort", "statusname", "reconnected", "progress", + "maxprogress", "pluginmodule", "pluginclass") + + def __init__(self, manager, id, url, name, size, status, error, plugin, package, order): + self.m = manager + + self.id = int(id) + self.url = url + self.name = name + self.size = size + self.status = status + self.plugin = self.plugintype, self.pluginname = plugin + self.packageid = package #should not be used, use package() instead + self.error = error + self.order = order + # database information ends here + + self.lock = RLock() + + self.plugin = None + #self.download = None + + self.waitUntil = 0 # time() + time to wait + + # status attributes + self.active = False #obsolete? + self.abort = False + self.reconnected = False + + self.statusname = None + + self.progress = 0 + self.maxprogress = 100 + + self.m.cache[int(id)] = self + + + # will convert all sizes to ints + size = property(lambda self: self._size, setSize) + + def __repr__(self): + return "PyFile %s: %s@%s" % (self.id, self.name, self.pluginname) + + @lock + def initPlugin(self): + """ inits plugin instance """ + if not self.plugin: + self.pluginmodule = self.m.core.pluginManager.getPlugin(self.plugintype, self.pluginname) + self.pluginclass = getattr(self.pluginmodule, self.m.core.pluginManager.getPluginName(self.plugintype, self.pluginname)) + self.plugin = self.pluginclass(self) + + @lock + def hasPlugin(self): + """Thread safe way to determine this file has initialized plugin attribute + + :return: + """ + return hasattr(self, "plugin") and self.plugin + + def package(self): + """ return package instance""" + return self.m.getPackage(self.packageid) + + def setStatus(self, status): + self.status = statusMap[status] + self.sync() #@TODO needed aslong no better job approving exists + + def setCustomStatus(self, msg, status="processing"): + self.statusname = msg + self.setStatus(status) + + def getStatusName(self): + if self.status not in (13, 14) or not self.statusname: + return self.m.statusMsg[self.status] + else: + return self.statusname + + def hasStatus(self, status): + return statusMap[status] == self.status + + def sync(self): + """sync PyFile instance with database""" + self.m.updateLink(self) + + @lock + def release(self): + """sync and remove from cache""" + # file has valid package + if self.packageid > 0: + self.sync() + + if hasattr(self, "plugin") and self.plugin: + self.plugin.clean() + del self.plugin + + self.m.releaseLink(self.id) + + def delete(self): + """delete pyfile from database""" + self.m.deleteLink(self.id) + + def toDict(self): + """return dict with all information for interface""" + return self.toDbDict() + + def toDbDict(self): + """return data as dict for databse + + format: + + { + id: {'url': url, 'name': name ... } + } + + """ + return { + self.id: { + 'id': self.id, + 'url': self.url, + 'name': self.name, + 'plugin': self.pluginname, + 'size': self.getSize(), + 'format_size': self.formatSize(), + 'status': self.status, + 'statusmsg': self.getStatusName(), + 'package': self.packageid, + 'error': self.error, + 'order': self.order + } + } + + def abortDownload(self): + """abort pyfile if possible""" + while self.id in self.m.core.threadManager.processingIds(): + self.abort = True + if self.plugin and self.plugin.req: + self.plugin.req.abortDownloads() + sleep(0.1) + + self.abort = False + if self.hasPlugin() and self.plugin.req: + self.plugin.req.abortDownloads() + + self.release() + + def finishIfDone(self): + """set status to finish and release file if every thread is finished with it""" + + if self.id in self.m.core.threadManager.processingIds(): + return False + + self.setStatus("finished") + self.release() + self.m.checkAllLinksFinished() + return True + + def checkIfProcessed(self): + self.m.checkAllLinksProcessed(self.id) + + def formatWait(self): + """ formats and return wait time in humanreadable format """ + seconds = self.waitUntil - time() + + if seconds < 0: return "00:00:00" + + hours, seconds = divmod(seconds, 3600) + minutes, seconds = divmod(seconds, 60) + return "%.2i:%.2i:%.2i" % (hours, minutes, seconds) + + def formatSize(self): + """ formats size to readable format """ + return formatSize(self.getSize()) + + def formatETA(self): + """ formats eta to readable format """ + seconds = self.getETA() + + if seconds < 0: return "00:00:00" + + hours, seconds = divmod(seconds, 3600) + minutes, seconds = divmod(seconds, 60) + return "%.2i:%.2i:%.2i" % (hours, minutes, seconds) + + def getSpeed(self): + """ calculates speed """ + try: + return self.plugin.req.speed + except Exception: + return 0 + + def getETA(self): + """ gets established time of arrival""" + try: + return self.getBytesLeft() / self.getSpeed() + except Exception: + return 0 + + def getBytesLeft(self): + """ gets bytes left """ + try: + return self.getSize() - self.plugin.req.arrived + except Exception: + return 0 + + def getPercent(self): + """ get % of download """ + if self.status == 12: + try: + return self.plugin.req.percent + except Exception: + return 0 + else: + return self.progress + + def getSize(self): + """ get size of download """ + try: + if self.plugin.req.size: + return self.plugin.req.size + else: + return self.size + except Exception: + return self.size + + def notifyChange(self): + e = UpdateEvent("file", self.id, "collector" if not self.package().queue else "queue") + self.m.core.pullManager.addEvent(e) + + def setProgress(self, value): + if not value == self.progress: + self.progress = value + self.notifyChange() diff --git a/pyload/datatype/Package.py b/pyload/datatype/Package.py new file mode 100644 index 000000000..bf3edffea --- /dev/null +++ b/pyload/datatype/Package.py @@ -0,0 +1,64 @@ +# -*- coding: utf-8 -*- +# @author: RaNaN, mkaay + +from pyload.manager.Event import UpdateEvent +from pyload.utils import safe_filename + +class PyPackage(object): + """ + Represents a package object at runtime + """ + def __init__(self, manager, id, name, folder, site, password, queue, order): + self.m = manager + self.m.packageCache[int(id)] = self + + self.id = int(id) + self.name = name + self._folder = folder + self.site = site + self.password = password + self.queue = queue + self.order = order + self.setFinished = False + + @property + def folder(self): + return safe_filename(self._folder) + + def toDict(self): + """ Returns a dictionary representation of the data. + + :return: dict: {id: { attr: value }} + """ + return { + self.id: { + 'id': self.id, + 'name': self.name, + 'folder': self.folder, + 'site': self.site, + 'password': self.password, + 'queue': self.queue, + 'order': self.order, + 'links': {} + } + } + + def getChildren(self): + """get information about contained links""" + return self.m.getPackageData(self.id)["links"] + + def sync(self): + """sync with db""" + self.m.updatePackage(self) + + def release(self): + """sync and delete from cache""" + self.sync() + self.m.releasePackage(self.id) + + def delete(self): + self.m.deletePackage(self.id) + + def notifyChange(self): + e = UpdateEvent("pack", self.id, "collector" if not self.queue else "queue") + self.m.core.pullManager.addEvent(e) diff --git a/pyload/datatype/PyFile.py b/pyload/datatype/PyFile.py deleted file mode 100644 index 173203a8d..000000000 --- a/pyload/datatype/PyFile.py +++ /dev/null @@ -1,270 +0,0 @@ -# -*- coding: utf-8 -*- -# @author: RaNaN, mkaay - -from pyload.manager.event.PullEvents import UpdateEvent -from pyload.utils import formatSize, lock - -from time import sleep, time - -from threading import RLock - -statusMap = { - "finished": 0, - "offline": 1, - "online": 2, - "queued": 3, - "skipped": 4, - "waiting": 5, - "temp. offline": 6, - "starting": 7, - "failed": 8, - "aborted": 9, - "decrypting": 10, - "custom": 11, - "downloading": 12, - "processing": 13, - "unknown": 14, -} - - -def setSize(self, value): - self._size = int(value) - -class PyFile(object): - """ - Represents a file object at runtime - """ - __slots__ = ("m", "id", "url", "name", "size", "_size", "status", "plugin", - "packageid", "error", "order", "lock", "plugin", "waitUntil", - "active", "abort", "statusname", "reconnected", "progress", - "maxprogress", "pluginmodule", "pluginclass") - - def __init__(self, manager, id, url, name, size, status, error, plugin, package, order): - self.m = manager - - self.id = int(id) - self.url = url - self.name = name - self.size = size - self.status = status - self.plugin = self.plugintype, self.pluginname = plugin - self.packageid = package #should not be used, use package() instead - self.error = error - self.order = order - # database information ends here - - self.lock = RLock() - - self.plugin = None - #self.download = None - - self.waitUntil = 0 # time() + time to wait - - # status attributes - self.active = False #obsolete? - self.abort = False - self.reconnected = False - - self.statusname = None - - self.progress = 0 - self.maxprogress = 100 - - self.m.cache[int(id)] = self - - - # will convert all sizes to ints - size = property(lambda self: self._size, setSize) - - def __repr__(self): - return "PyFile %s: %s@%s" % (self.id, self.name, self.pluginname) - - @lock - def initPlugin(self): - """ inits plugin instance """ - if not self.plugin: - self.pluginmodule = self.m.core.pluginManager.getPlugin(self.plugintype, self.pluginname) - self.pluginclass = getattr(self.pluginmodule, self.m.core.pluginManager.getPluginName(self.plugintype, self.pluginname)) - self.plugin = self.pluginclass(self) - - @lock - def hasPlugin(self): - """Thread safe way to determine this file has initialized plugin attribute - - :return: - """ - return hasattr(self, "plugin") and self.plugin - - def package(self): - """ return package instance""" - return self.m.getPackage(self.packageid) - - def setStatus(self, status): - self.status = statusMap[status] - self.sync() #@TODO needed aslong no better job approving exists - - def setCustomStatus(self, msg, status="processing"): - self.statusname = msg - self.setStatus(status) - - def getStatusName(self): - if self.status not in (13, 14) or not self.statusname: - return self.m.statusMsg[self.status] - else: - return self.statusname - - def hasStatus(self, status): - return statusMap[status] == self.status - - def sync(self): - """sync PyFile instance with database""" - self.m.updateLink(self) - - @lock - def release(self): - """sync and remove from cache""" - # file has valid package - if self.packageid > 0: - self.sync() - - if hasattr(self, "plugin") and self.plugin: - self.plugin.clean() - del self.plugin - - self.m.releaseLink(self.id) - - def delete(self): - """delete pyfile from database""" - self.m.deleteLink(self.id) - - def toDict(self): - """return dict with all information for interface""" - return self.toDbDict() - - def toDbDict(self): - """return data as dict for databse - - format: - - { - id: {'url': url, 'name': name ... } - } - - """ - return { - self.id: { - 'id': self.id, - 'url': self.url, - 'name': self.name, - 'plugin': self.pluginname, - 'size': self.getSize(), - 'format_size': self.formatSize(), - 'status': self.status, - 'statusmsg': self.getStatusName(), - 'package': self.packageid, - 'error': self.error, - 'order': self.order - } - } - - def abortDownload(self): - """abort pyfile if possible""" - while self.id in self.m.core.threadManager.processingIds(): - self.abort = True - if self.plugin and self.plugin.req: - self.plugin.req.abortDownloads() - sleep(0.1) - - self.abort = False - if self.hasPlugin() and self.plugin.req: - self.plugin.req.abortDownloads() - - self.release() - - def finishIfDone(self): - """set status to finish and release file if every thread is finished with it""" - - if self.id in self.m.core.threadManager.processingIds(): - return False - - self.setStatus("finished") - self.release() - self.m.checkAllLinksFinished() - return True - - def checkIfProcessed(self): - self.m.checkAllLinksProcessed(self.id) - - def formatWait(self): - """ formats and return wait time in humanreadable format """ - seconds = self.waitUntil - time() - - if seconds < 0: return "00:00:00" - - hours, seconds = divmod(seconds, 3600) - minutes, seconds = divmod(seconds, 60) - return "%.2i:%.2i:%.2i" % (hours, minutes, seconds) - - def formatSize(self): - """ formats size to readable format """ - return formatSize(self.getSize()) - - def formatETA(self): - """ formats eta to readable format """ - seconds = self.getETA() - - if seconds < 0: return "00:00:00" - - hours, seconds = divmod(seconds, 3600) - minutes, seconds = divmod(seconds, 60) - return "%.2i:%.2i:%.2i" % (hours, minutes, seconds) - - def getSpeed(self): - """ calculates speed """ - try: - return self.plugin.req.speed - except Exception: - return 0 - - def getETA(self): - """ gets established time of arrival""" - try: - return self.getBytesLeft() / self.getSpeed() - except Exception: - return 0 - - def getBytesLeft(self): - """ gets bytes left """ - try: - return self.getSize() - self.plugin.req.arrived - except Exception: - return 0 - - def getPercent(self): - """ get % of download """ - if self.status == 12: - try: - return self.plugin.req.percent - except Exception: - return 0 - else: - return self.progress - - def getSize(self): - """ get size of download """ - try: - if self.plugin.req.size: - return self.plugin.req.size - else: - return self.size - except Exception: - return self.size - - def notifyChange(self): - e = UpdateEvent("file", self.id, "collector" if not self.package().queue else "queue") - self.m.core.pullManager.addEvent(e) - - def setProgress(self, value): - if not value == self.progress: - self.progress = value - self.notifyChange() diff --git a/pyload/datatype/PyPackage.py b/pyload/datatype/PyPackage.py deleted file mode 100644 index dbd8c8c9b..000000000 --- a/pyload/datatype/PyPackage.py +++ /dev/null @@ -1,64 +0,0 @@ -# -*- coding: utf-8 -*- -# @author: RaNaN, mkaay - -from pyload.manager.event.PullEvents import UpdateEvent -from pyload.utils import safe_filename - -class PyPackage(object): - """ - Represents a package object at runtime - """ - def __init__(self, manager, id, name, folder, site, password, queue, order): - self.m = manager - self.m.packageCache[int(id)] = self - - self.id = int(id) - self.name = name - self._folder = folder - self.site = site - self.password = password - self.queue = queue - self.order = order - self.setFinished = False - - @property - def folder(self): - return safe_filename(self._folder) - - def toDict(self): - """ Returns a dictionary representation of the data. - - :return: dict: {id: { attr: value }} - """ - return { - self.id: { - 'id': self.id, - 'name': self.name, - 'folder': self.folder, - 'site': self.site, - 'password': self.password, - 'queue': self.queue, - 'order': self.order, - 'links': {} - } - } - - def getChildren(self): - """get information about contained links""" - return self.m.getPackageData(self.id)["links"] - - def sync(self): - """sync with db""" - self.m.updatePackage(self) - - def release(self): - """sync and delete from cache""" - self.sync() - self.m.releasePackage(self.id) - - def delete(self): - self.m.deletePackage(self.id) - - def notifyChange(self): - e = UpdateEvent("pack", self.id, "collector" if not self.queue else "queue") - self.m.core.pullManager.addEvent(e) diff --git a/pyload/manager/Account.py b/pyload/manager/Account.py new file mode 100644 index 000000000..2631e1c7d --- /dev/null +++ b/pyload/manager/Account.py @@ -0,0 +1,191 @@ +# -*- coding: utf-8 -*- + +from __future__ import with_statement + +from os.path import exists +from shutil import copy + +from threading import Lock + +from pyload.manager.Event import AccountUpdateEvent +from pyload.utils import chmod, lock + +ACC_VERSION = 1 + + +class AccountManager(object): + """manages all accounts""" + + #---------------------------------------------------------------------- + def __init__(self, core): + """Constructor""" + + self.core = core + self.lock = Lock() + + self.initPlugins() + self.saveAccounts() # save to add categories to conf + + + def initPlugins(self): + self.accounts = {} # key = ( plugin ) + self.plugins = {} + + self.initAccountPlugins() + self.loadAccounts() + + + def getAccountPlugin(self, plugin): + """get account instance for plugin or None if anonymous""" + try: + if plugin in self.accounts: + if plugin not in self.plugins: + klass = self.core.pluginManager.loadClass("accounts", plugin) + if klass: + self.plugins[plugin] = klass(self, self.accounts[plugin]) + else: #@NOTE: The account class no longer exists (blacklisted plugin). Skipping the account to avoid crash + raise + + return self.plugins[plugin] + else: + raise + except Exception: + return None + + + def getAccountPlugins(self): + """ get all account instances""" + + plugins = [] + for plugin in self.accounts.keys(): + plugins.append(self.getAccountPlugin(plugin)) + + return plugins + + + #---------------------------------------------------------------------- + def loadAccounts(self): + """loads all accounts available""" + + try: + with open("accounts.conf", "a+") as f: + content = f.readlines() + version = content[0].split(":")[1].strip() if content else "" + + if not version or int(version) < ACC_VERSION: + copy("accounts.conf", "accounts.backup") + f.seek(0) + f.write("version: " + str(ACC_VERSION)) + + self.core.log.warning(_("Account settings deleted, due to new config format")) + return + + except IOError, e: + self.core.log.error(str(e)) + return + + plugin = "" + name = "" + + for line in content[1:]: + line = line.strip() + + if not line: continue + if line.startswith("#"): continue + if line.startswith("version"): continue + + if line.endswith(":") and line.count(":") == 1: + plugin = line[:-1] + self.accounts[plugin] = {} + + elif line.startswith("@"): + try: + option = line[1:].split() + self.accounts[plugin][name]['options'][option[0]] = [] if len(option) < 2 else ([option[1]] if len(option) < 3 else option[1:]) + except Exception: + pass + + elif ":" in line: + name, sep, pw = line.partition(":") + self.accounts[plugin][name] = {"password": pw, "options": {}, "valid": True} + + + #---------------------------------------------------------------------- + def saveAccounts(self): + """save all account information""" + + try: + with open("accounts.conf", "wb") as f: + f.write("version: " + str(ACC_VERSION) + "\n") + + for plugin, accounts in self.accounts.iteritems(): + f.write("\n") + f.write(plugin + ":\n") + + for name,data in accounts.iteritems(): + f.write("\n\t%s:%s\n" % (name,data['password']) ) + if data['options']: + for option, values in data['options'].iteritems(): + f.write("\t@%s %s\n" % (option, " ".join(values))) + + chmod(f.name, 0600) + + except Exception, e: + self.core.log.error(str(e)) + + + #---------------------------------------------------------------------- + def initAccountPlugins(self): + """init names""" + for name in self.core.pluginManager.getAccountPlugins(): + self.accounts[name] = {} + + + @lock + def updateAccount(self, plugin , user, password=None, options={}): + """add or update account""" + if plugin in self.accounts: + p = self.getAccountPlugin(plugin) + updated = p.updateAccounts(user, password, options) + #since accounts is a ref in plugin self.accounts doesnt need to be updated here + + self.saveAccounts() + if updated: p.scheduleRefresh(user, force=False) + + + @lock + def removeAccount(self, plugin, user): + """remove account""" + + if plugin in self.accounts: + p = self.getAccountPlugin(plugin) + p.removeAccount(user) + + self.saveAccounts() + + + @lock + def getAccountInfos(self, force=True, refresh=False): + data = {} + + if refresh: + self.core.scheduler.addJob(0, self.core.accountManager.getAccountInfos) + force = False + + for p in self.accounts.keys(): + if self.accounts[p]: + p = self.getAccountPlugin(p) + if p: + data[p.__name] = p.getAllAccounts(force) + else: #@NOTE: When an account has been skipped, p is None + data[p] = [] + else: + data[p] = [] + e = AccountUpdateEvent() + self.core.pullManager.addEvent(e) + return data + + + def sendChange(self): + e = AccountUpdateEvent() + self.core.pullManager.addEvent(e) diff --git a/pyload/manager/AccountManager.py b/pyload/manager/AccountManager.py deleted file mode 100644 index 22345de8d..000000000 --- a/pyload/manager/AccountManager.py +++ /dev/null @@ -1,191 +0,0 @@ -# -*- coding: utf-8 -*- - -from __future__ import with_statement - -from os.path import exists -from shutil import copy - -from threading import Lock - -from pyload.manager.event.PullEvents import AccountUpdateEvent -from pyload.utils import chmod, lock - -ACC_VERSION = 1 - - -class AccountManager(object): - """manages all accounts""" - - #---------------------------------------------------------------------- - def __init__(self, core): - """Constructor""" - - self.core = core - self.lock = Lock() - - self.initPlugins() - self.saveAccounts() # save to add categories to conf - - - def initPlugins(self): - self.accounts = {} # key = ( plugin ) - self.plugins = {} - - self.initAccountPlugins() - self.loadAccounts() - - - def getAccountPlugin(self, plugin): - """get account instance for plugin or None if anonymous""" - try: - if plugin in self.accounts: - if plugin not in self.plugins: - klass = self.core.pluginManager.loadClass("accounts", plugin) - if klass: - self.plugins[plugin] = klass(self, self.accounts[plugin]) - else: #@NOTE: The account class no longer exists (blacklisted plugin). Skipping the account to avoid crash - raise - - return self.plugins[plugin] - else: - raise - except Exception: - return None - - - def getAccountPlugins(self): - """ get all account instances""" - - plugins = [] - for plugin in self.accounts.keys(): - plugins.append(self.getAccountPlugin(plugin)) - - return plugins - - - #---------------------------------------------------------------------- - def loadAccounts(self): - """loads all accounts available""" - - try: - with open("accounts.conf", "a+") as f: - content = f.readlines() - version = content[0].split(":")[1].strip() if content else "" - - if not version or int(version) < ACC_VERSION: - copy("accounts.conf", "accounts.backup") - f.seek(0) - f.write("version: " + str(ACC_VERSION)) - - self.core.log.warning(_("Account settings deleted, due to new config format")) - return - - except IOError, e: - self.core.log.error(str(e)) - return - - plugin = "" - name = "" - - for line in content[1:]: - line = line.strip() - - if not line: continue - if line.startswith("#"): continue - if line.startswith("version"): continue - - if line.endswith(":") and line.count(":") == 1: - plugin = line[:-1] - self.accounts[plugin] = {} - - elif line.startswith("@"): - try: - option = line[1:].split() - self.accounts[plugin][name]['options'][option[0]] = [] if len(option) < 2 else ([option[1]] if len(option) < 3 else option[1:]) - except Exception: - pass - - elif ":" in line: - name, sep, pw = line.partition(":") - self.accounts[plugin][name] = {"password": pw, "options": {}, "valid": True} - - - #---------------------------------------------------------------------- - def saveAccounts(self): - """save all account information""" - - try: - with open("accounts.conf", "wb") as f: - f.write("version: " + str(ACC_VERSION) + "\n") - - for plugin, accounts in self.accounts.iteritems(): - f.write("\n") - f.write(plugin + ":\n") - - for name,data in accounts.iteritems(): - f.write("\n\t%s:%s\n" % (name,data['password']) ) - if data['options']: - for option, values in data['options'].iteritems(): - f.write("\t@%s %s\n" % (option, " ".join(values))) - - chmod(f.name, 0600) - - except Exception, e: - self.core.log.error(str(e)) - - - #---------------------------------------------------------------------- - def initAccountPlugins(self): - """init names""" - for name in self.core.pluginManager.getAccountPlugins(): - self.accounts[name] = {} - - - @lock - def updateAccount(self, plugin , user, password=None, options={}): - """add or update account""" - if plugin in self.accounts: - p = self.getAccountPlugin(plugin) - updated = p.updateAccounts(user, password, options) - #since accounts is a ref in plugin self.accounts doesnt need to be updated here - - self.saveAccounts() - if updated: p.scheduleRefresh(user, force=False) - - - @lock - def removeAccount(self, plugin, user): - """remove account""" - - if plugin in self.accounts: - p = self.getAccountPlugin(plugin) - p.removeAccount(user) - - self.saveAccounts() - - - @lock - def getAccountInfos(self, force=True, refresh=False): - data = {} - - if refresh: - self.core.scheduler.addJob(0, self.core.accountManager.getAccountInfos) - force = False - - for p in self.accounts.keys(): - if self.accounts[p]: - p = self.getAccountPlugin(p) - if p: - data[p.__name] = p.getAllAccounts(force) - else: #@NOTE: When an account has been skipped, p is None - data[p] = [] - else: - data[p] = [] - e = AccountUpdateEvent() - self.core.pullManager.addEvent(e) - return data - - - def sendChange(self): - e = AccountUpdateEvent() - self.core.pullManager.addEvent(e) diff --git a/pyload/manager/Addon.py b/pyload/manager/Addon.py new file mode 100644 index 000000000..164068634 --- /dev/null +++ b/pyload/manager/Addon.py @@ -0,0 +1,304 @@ +# -*- coding: utf-8 -*- +# @author: RaNaN, mkaay +# @interface-version: 0.1 + +import __builtin__ + +import traceback +from threading import RLock, Thread + +from types import MethodType + +from pyload.manager.thread.Addon import AddonThread +from pyload.manager.Plugin import literal_eval +from pyload.utils import lock + + +class AddonManager(object): + """Manages addons, delegates and handles Events. + + Every plugin can define events, \ + but some very usefull events are called by the Core. + Contrary to overwriting addon methods you can use event listener, + which provides additional entry point in the control flow. + Only do very short tasks or use threads. + + **Known Events:** + Most addon methods exists as events. These are the additional known events. + + ======================= ============== ================================== + Name Arguments Description + ======================= ============== ================================== + download-preparing fid A download was just queued and will be prepared now. + download-start fid A plugin will immediately starts the download afterwards. + links-added links, pid Someone just added links, you are able to modify the links. + all_downloads-processed Every link was handled, pyload would idle afterwards. + all_downloads-finished Every download in queue is finished. + config-changed The config was changed via the api. + pluginConfigChanged The plugin config changed, due to api or internal process. + ======================= ============== ================================== + + | Notes: + | all_downloads-processed is *always* called before all_downloads-finished. + | config-changed is *always* called before pluginConfigChanged. + + + """ + + def __init__(self, core): + self.core = core + + __builtin__.addonManager = self #: needed to let addons register themself + + self.plugins = [] + self.pluginMap = {} + self.methods = {} #: dict of names and list of methods usable by rpc + + self.events = {} #: contains events + + # registering callback for config event + self.core.config.pluginCB = MethodType(self.dispatchEvent, "pluginConfigChanged", basestring) #@TODO: Rename event pluginConfigChanged + + self.addEvent("pluginConfigChanged", self.manageAddon) + + self.lock = RLock() + self.createIndex() + + + def try_catch(func): + + def new(*args): + try: + return func(*args) + except Exception, e: + args[0].log.error(_("Error executing addon: %s") % e) + if args[0].core.debug: + traceback.print_exc() + + return new + + + def addRPC(self, plugin, func, doc): + plugin = plugin.rpartition(".")[2] + doc = doc.strip() if doc else "" + + if plugin in self.methods: + self.methods[plugin][func] = doc + else: + self.methods[plugin] = {func: doc} + + + def callRPC(self, plugin, func, args, parse): + if not args: + args = tuple() + if parse: + args = tuple([literal_eval(x) for x in args]) + plugin = self.pluginMap[plugin] + f = getattr(plugin, func) + return f(*args) + + + def createIndex(self): + plugins = [] + active = [] + deactive = [] + + for pluginname in self.core.pluginManager.addonPlugins: + try: + # hookClass = getattr(plugin, plugin.__name) + if self.core.config.getPlugin(pluginname, "activated"): + pluginClass = self.core.pluginManager.loadClass("addon", pluginname) + if not pluginClass: + continue + + plugin = pluginClass(self.core, self) + plugins.append(plugin) + self.pluginMap[pluginClass.__name] = plugin + if plugin.isActivated(): + active.append(pluginClass.__name) + else: + deactive.append(pluginname) + + except Exception: + self.core.log.warning(_("Failed activating %(name)s") % {"name": pluginname}) + if self.core.debug: + traceback.print_exc() + + self.core.log.info(_("Activated addons: %s") % ", ".join(sorted(active))) + self.core.log.info(_("Deactivated addons: %s") % ", ".join(sorted(deactive))) + + self.plugins = plugins + + + def manageAddon(self, plugin, name, value): + if name == "activated" and value: + self.activateAddon(plugin) + + elif name == "activated" and not value: + self.deactivateAddon(plugin) + + + def activateAddon(self, pluginname): + # check if already loaded + for inst in self.plugins: + if inst.__name == pluginname: + return + + pluginClass = self.core.pluginManager.loadClass("addon", pluginname) + + if not pluginClass: + return + + self.core.log.debug("Activate addon: %s" % pluginname) + + addon = pluginClass(self.core, self) + self.plugins.append(addon) + self.pluginMap[pluginClass.__name] = addon + + addon.activate() + + + def deactivateAddon(self, pluginname): + for plugin in self.plugins: + if plugin.__name == pluginname: + addon = plugin + break + else: + return + + self.core.log.debug("Deactivate addon: %s" % pluginname) + + addon.deactivate() + + #remove periodic call + self.core.log.debug("Removed callback: %s" % self.core.scheduler.removeJob(addon.cb)) + + self.plugins.remove(addon) + del self.pluginMap[addon.__name] + + + @try_catch + def coreReady(self): + for plugin in self.plugins: + if plugin.isActivated(): + plugin.activate() + + self.dispatchEvent("addon-start") + + + @try_catch + def coreExiting(self): + for plugin in self.plugins: + if plugin.isActivated(): + plugin.exit() + + self.dispatchEvent("addon-exit") + + + @lock + def downloadPreparing(self, pyfile): + for plugin in self.plugins: + if plugin.isActivated(): + plugin.downloadPreparing(pyfile) + + self.dispatchEvent("download-preparing", pyfile) + + + @lock + def downloadFinished(self, pyfile): + for plugin in self.plugins: + if plugin.isActivated(): + plugin.downloadFinished(pyfile) + + self.dispatchEvent("download-finished", pyfile) + + + @lock + @try_catch + def downloadFailed(self, pyfile): + for plugin in self.plugins: + if plugin.isActivated(): + plugin.downloadFailed(pyfile) + + self.dispatchEvent("download-failed", pyfile) + + + @lock + def packageFinished(self, package): + for plugin in self.plugins: + if plugin.isActivated(): + plugin.packageFinished(package) + + self.dispatchEvent("package-finished", package) + + + @lock + def beforeReconnecting(self, ip): + for plugin in self.plugins: + plugin.beforeReconnecting(ip) + + self.dispatchEvent("beforeReconnecting", ip) + + + @lock + def afterReconnecting(self, ip): + for plugin in self.plugins: + if plugin.isActivated(): + plugin.afterReconnecting(ip) + + self.dispatchEvent("afterReconnecting", ip) + + + def startThread(self, function, *args, **kwargs): + return AddonThread(self.core.threadManager, function, args, kwargs) + + + def activePlugins(self): + """ returns all active plugins """ + return [x for x in self.plugins if x.isActivated()] + + + def getAllInfo(self): + """returns info stored by addon plugins""" + info = {} + for name, plugin in self.pluginMap.iteritems(): + if plugin.info: + # copy and convert so str + info[name] = dict( + [(x, str(y) if not isinstance(y, basestring) else y) for x, y in plugin.info.iteritems()]) + return info + + + def getInfo(self, plugin): + info = {} + if plugin in self.pluginMap and self.pluginMap[plugin].info: + info = dict((x, str(y) if not isinstance(y, basestring) else y) + for x, y in self.pluginMap[plugin].info.iteritems()) + return info + + + def addEvent(self, event, func): + """Adds an event listener for event name""" + if event in self.events: + self.events[event].append(func) + else: + self.events[event] = [func] + + + def removeEvent(self, event, func): + """removes previously added event listener""" + if event in self.events: + self.events[event].remove(func) + + + def dispatchEvent(self, event, *args): + """dispatches event with args""" + if event in self.events: + for f in self.events[event]: + try: + f(*args) + except Exception, e: + self.core.log.warning("Error calling event handler %s: %s, %s, %s" + % (event, f, args, str(e))) + if self.core.debug: + traceback.print_exc() diff --git a/pyload/manager/AddonManager.py b/pyload/manager/AddonManager.py deleted file mode 100644 index 2fd744776..000000000 --- a/pyload/manager/AddonManager.py +++ /dev/null @@ -1,304 +0,0 @@ -# -*- coding: utf-8 -*- -# @author: RaNaN, mkaay -# @interface-version: 0.1 - -import __builtin__ - -import traceback -from threading import RLock, Thread - -from types import MethodType - -from pyload.manager.thread.AddonThread import AddonThread -from pyload.manager.PluginManager import literal_eval -from pyload.utils import lock - - -class AddonManager(object): - """Manages addons, delegates and handles Events. - - Every plugin can define events, \ - but some very usefull events are called by the Core. - Contrary to overwriting addon methods you can use event listener, - which provides additional entry point in the control flow. - Only do very short tasks or use threads. - - **Known Events:** - Most addon methods exists as events. These are the additional known events. - - ======================= ============== ================================== - Name Arguments Description - ======================= ============== ================================== - download-preparing fid A download was just queued and will be prepared now. - download-start fid A plugin will immediately starts the download afterwards. - links-added links, pid Someone just added links, you are able to modify the links. - all_downloads-processed Every link was handled, pyload would idle afterwards. - all_downloads-finished Every download in queue is finished. - config-changed The config was changed via the api. - pluginConfigChanged The plugin config changed, due to api or internal process. - ======================= ============== ================================== - - | Notes: - | all_downloads-processed is *always* called before all_downloads-finished. - | config-changed is *always* called before pluginConfigChanged. - - - """ - - def __init__(self, core): - self.core = core - - __builtin__.addonManager = self #: needed to let addons register themself - - self.plugins = [] - self.pluginMap = {} - self.methods = {} #: dict of names and list of methods usable by rpc - - self.events = {} #: contains events - - # registering callback for config event - self.core.config.pluginCB = MethodType(self.dispatchEvent, "pluginConfigChanged", basestring) #@TODO: Rename event pluginConfigChanged - - self.addEvent("pluginConfigChanged", self.manageAddon) - - self.lock = RLock() - self.createIndex() - - - def try_catch(func): - - def new(*args): - try: - return func(*args) - except Exception, e: - args[0].log.error(_("Error executing addon: %s") % e) - if args[0].core.debug: - traceback.print_exc() - - return new - - - def addRPC(self, plugin, func, doc): - plugin = plugin.rpartition(".")[2] - doc = doc.strip() if doc else "" - - if plugin in self.methods: - self.methods[plugin][func] = doc - else: - self.methods[plugin] = {func: doc} - - - def callRPC(self, plugin, func, args, parse): - if not args: - args = tuple() - if parse: - args = tuple([literal_eval(x) for x in args]) - plugin = self.pluginMap[plugin] - f = getattr(plugin, func) - return f(*args) - - - def createIndex(self): - plugins = [] - active = [] - deactive = [] - - for pluginname in self.core.pluginManager.addonPlugins: - try: - # hookClass = getattr(plugin, plugin.__name) - if self.core.config.getPlugin(pluginname, "activated"): - pluginClass = self.core.pluginManager.loadClass("addon", pluginname) - if not pluginClass: - continue - - plugin = pluginClass(self.core, self) - plugins.append(plugin) - self.pluginMap[pluginClass.__name] = plugin - if plugin.isActivated(): - active.append(pluginClass.__name) - else: - deactive.append(pluginname) - - except Exception: - self.core.log.warning(_("Failed activating %(name)s") % {"name": pluginname}) - if self.core.debug: - traceback.print_exc() - - self.core.log.info(_("Activated addons: %s") % ", ".join(sorted(active))) - self.core.log.info(_("Deactivated addons: %s") % ", ".join(sorted(deactive))) - - self.plugins = plugins - - - def manageAddon(self, plugin, name, value): - if name == "activated" and value: - self.activateAddon(plugin) - - elif name == "activated" and not value: - self.deactivateAddon(plugin) - - - def activateAddon(self, pluginname): - # check if already loaded - for inst in self.plugins: - if inst.__name == pluginname: - return - - pluginClass = self.core.pluginManager.loadClass("addon", pluginname) - - if not pluginClass: - return - - self.core.log.debug("Activate addon: %s" % pluginname) - - addon = pluginClass(self.core, self) - self.plugins.append(addon) - self.pluginMap[pluginClass.__name] = addon - - addon.activate() - - - def deactivateAddon(self, pluginname): - for plugin in self.plugins: - if plugin.__name == pluginname: - addon = plugin - break - else: - return - - self.core.log.debug("Deactivate addon: %s" % pluginname) - - addon.deactivate() - - #remove periodic call - self.core.log.debug("Removed callback: %s" % self.core.scheduler.removeJob(addon.cb)) - - self.plugins.remove(addon) - del self.pluginMap[addon.__name] - - - @try_catch - def coreReady(self): - for plugin in self.plugins: - if plugin.isActivated(): - plugin.activate() - - self.dispatchEvent("addon-start") - - - @try_catch - def coreExiting(self): - for plugin in self.plugins: - if plugin.isActivated(): - plugin.exit() - - self.dispatchEvent("addon-exit") - - - @lock - def downloadPreparing(self, pyfile): - for plugin in self.plugins: - if plugin.isActivated(): - plugin.downloadPreparing(pyfile) - - self.dispatchEvent("download-preparing", pyfile) - - - @lock - def downloadFinished(self, pyfile): - for plugin in self.plugins: - if plugin.isActivated(): - plugin.downloadFinished(pyfile) - - self.dispatchEvent("download-finished", pyfile) - - - @lock - @try_catch - def downloadFailed(self, pyfile): - for plugin in self.plugins: - if plugin.isActivated(): - plugin.downloadFailed(pyfile) - - self.dispatchEvent("download-failed", pyfile) - - - @lock - def packageFinished(self, package): - for plugin in self.plugins: - if plugin.isActivated(): - plugin.packageFinished(package) - - self.dispatchEvent("package-finished", package) - - - @lock - def beforeReconnecting(self, ip): - for plugin in self.plugins: - plugin.beforeReconnecting(ip) - - self.dispatchEvent("beforeReconnecting", ip) - - - @lock - def afterReconnecting(self, ip): - for plugin in self.plugins: - if plugin.isActivated(): - plugin.afterReconnecting(ip) - - self.dispatchEvent("afterReconnecting", ip) - - - def startThread(self, function, *args, **kwargs): - return AddonThread(self.core.threadManager, function, args, kwargs) - - - def activePlugins(self): - """ returns all active plugins """ - return [x for x in self.plugins if x.isActivated()] - - - def getAllInfo(self): - """returns info stored by addon plugins""" - info = {} - for name, plugin in self.pluginMap.iteritems(): - if plugin.info: - # copy and convert so str - info[name] = dict( - [(x, str(y) if not isinstance(y, basestring) else y) for x, y in plugin.info.iteritems()]) - return info - - - def getInfo(self, plugin): - info = {} - if plugin in self.pluginMap and self.pluginMap[plugin].info: - info = dict((x, str(y) if not isinstance(y, basestring) else y) - for x, y in self.pluginMap[plugin].info.iteritems()) - return info - - - def addEvent(self, event, func): - """Adds an event listener for event name""" - if event in self.events: - self.events[event].append(func) - else: - self.events[event] = [func] - - - def removeEvent(self, event, func): - """removes previously added event listener""" - if event in self.events: - self.events[event].remove(func) - - - def dispatchEvent(self, event, *args): - """dispatches event with args""" - if event in self.events: - for f in self.events[event]: - try: - f(*args) - except Exception, e: - self.core.log.warning("Error calling event handler %s: %s, %s, %s" - % (event, f, args, str(e))) - if self.core.debug: - traceback.print_exc() diff --git a/pyload/manager/Captcha.py b/pyload/manager/Captcha.py new file mode 100644 index 000000000..e54eacf30 --- /dev/null +++ b/pyload/manager/Captcha.py @@ -0,0 +1,138 @@ +# -*- coding: utf-8 -*- +# @author: RaNaN, mkaay + +from time import time +from traceback import print_exc +from threading import Lock + +from pyload.utils import encode + + +class CaptchaManager(object): + def __init__(self, core): + self.lock = Lock() + self.core = core + self.tasks = [] # task store, for outgoing tasks only + self.ids = 0 # only for internal purpose + + def newTask(self, img, format, file, result_type): + task = CaptchaTask(self.ids, img, format, file, result_type) + self.ids += 1 + return task + + def removeTask(self, task): + self.lock.acquire() + if task in self.tasks: + self.tasks.remove(task) + self.lock.release() + + def getTask(self): + self.lock.acquire() + for task in self.tasks: + if task.status in ("waiting", "shared-user"): + self.lock.release() + return task + self.lock.release() + return None + + def getTaskByID(self, tid): + self.lock.acquire() + for task in self.tasks: + if task.id == str(tid): # task ids are strings + self.lock.release() + return task + self.lock.release() + return None + + def handleCaptcha(self, task, timeout=50): + cli = self.core.isClientConnected() + + if cli: #: client connected -> should solve the captcha + task.setWaiting(timeout) #wait 50 sec for response + + for plugin in self.core.addonManager.activePlugins(): + try: + plugin.captchaTask(task) + except Exception: + if self.core.debug: + print_exc() + + if task.handler or cli: #: the captcha was handled + self.tasks.append(task) + return True + task.error = _("No Client connected for captcha decrypting") + return False + + +class CaptchaTask(object): + def __init__(self, id, img, format, file, result_type='textual'): + self.id = str(id) + self.captchaImg = img + self.captchaFormat = format + self.captchaFile = file + self.captchaResultType = result_type + self.handler = [] #: the hook plugins that will take care of the solution + self.result = None + self.waitUntil = None + self.error = None # error message + self.status = "init" + self.data = {} # handler can store data here + + def getCaptcha(self): + return self.captchaImg, self.captchaFormat, self.captchaResultType + + def setResult(self, text): + if self.isTextual(): + self.result = text + if self.isPositional(): + try: + parts = text.split(',') + self.result = (int(parts[0]), int(parts[1])) + except Exception: + self.result = None + + def getResult(self): + return encode(self.result) + + def getStatus(self): + return self.status + + def setWaiting(self, sec): + """ let the captcha wait secs for the solution """ + self.waitUntil = max(time() + sec, self.waitUntil) + self.status = "waiting" + + def isWaiting(self): + if self.result or self.error or self.timedOut(): + return False + else: + return True + + def isTextual(self): + """ returns if text is written on the captcha """ + return self.captchaResultType == 'textual' + + def isPositional(self): + """ returns if user have to click a specific region on the captcha """ + return self.captchaResultType == 'positional' + + def setWatingForUser(self, exclusive): + if exclusive: + self.status = "user" + else: + self.status = "shared-user" + + def timedOut(self): + return time() > self.waitUntil + + def invalid(self): + """ indicates the captcha was not correct """ + for x in self.handler: + x.captchaInvalid(self) + + def correct(self): + for x in self.handler: + x.captchaCorrect(self) + + def __str__(self): + return "" % self.id diff --git a/pyload/manager/CaptchaManager.py b/pyload/manager/CaptchaManager.py deleted file mode 100644 index e54eacf30..000000000 --- a/pyload/manager/CaptchaManager.py +++ /dev/null @@ -1,138 +0,0 @@ -# -*- coding: utf-8 -*- -# @author: RaNaN, mkaay - -from time import time -from traceback import print_exc -from threading import Lock - -from pyload.utils import encode - - -class CaptchaManager(object): - def __init__(self, core): - self.lock = Lock() - self.core = core - self.tasks = [] # task store, for outgoing tasks only - self.ids = 0 # only for internal purpose - - def newTask(self, img, format, file, result_type): - task = CaptchaTask(self.ids, img, format, file, result_type) - self.ids += 1 - return task - - def removeTask(self, task): - self.lock.acquire() - if task in self.tasks: - self.tasks.remove(task) - self.lock.release() - - def getTask(self): - self.lock.acquire() - for task in self.tasks: - if task.status in ("waiting", "shared-user"): - self.lock.release() - return task - self.lock.release() - return None - - def getTaskByID(self, tid): - self.lock.acquire() - for task in self.tasks: - if task.id == str(tid): # task ids are strings - self.lock.release() - return task - self.lock.release() - return None - - def handleCaptcha(self, task, timeout=50): - cli = self.core.isClientConnected() - - if cli: #: client connected -> should solve the captcha - task.setWaiting(timeout) #wait 50 sec for response - - for plugin in self.core.addonManager.activePlugins(): - try: - plugin.captchaTask(task) - except Exception: - if self.core.debug: - print_exc() - - if task.handler or cli: #: the captcha was handled - self.tasks.append(task) - return True - task.error = _("No Client connected for captcha decrypting") - return False - - -class CaptchaTask(object): - def __init__(self, id, img, format, file, result_type='textual'): - self.id = str(id) - self.captchaImg = img - self.captchaFormat = format - self.captchaFile = file - self.captchaResultType = result_type - self.handler = [] #: the hook plugins that will take care of the solution - self.result = None - self.waitUntil = None - self.error = None # error message - self.status = "init" - self.data = {} # handler can store data here - - def getCaptcha(self): - return self.captchaImg, self.captchaFormat, self.captchaResultType - - def setResult(self, text): - if self.isTextual(): - self.result = text - if self.isPositional(): - try: - parts = text.split(',') - self.result = (int(parts[0]), int(parts[1])) - except Exception: - self.result = None - - def getResult(self): - return encode(self.result) - - def getStatus(self): - return self.status - - def setWaiting(self, sec): - """ let the captcha wait secs for the solution """ - self.waitUntil = max(time() + sec, self.waitUntil) - self.status = "waiting" - - def isWaiting(self): - if self.result or self.error or self.timedOut(): - return False - else: - return True - - def isTextual(self): - """ returns if text is written on the captcha """ - return self.captchaResultType == 'textual' - - def isPositional(self): - """ returns if user have to click a specific region on the captcha """ - return self.captchaResultType == 'positional' - - def setWatingForUser(self, exclusive): - if exclusive: - self.status = "user" - else: - self.status = "shared-user" - - def timedOut(self): - return time() > self.waitUntil - - def invalid(self): - """ indicates the captcha was not correct """ - for x in self.handler: - x.captchaInvalid(self) - - def correct(self): - for x in self.handler: - x.captchaCorrect(self) - - def __str__(self): - return "" % self.id diff --git a/pyload/manager/Event.py b/pyload/manager/Event.py new file mode 100644 index 000000000..20897290e --- /dev/null +++ b/pyload/manager/Event.py @@ -0,0 +1,104 @@ +# -*- coding: utf-8 -*- +# @author: mkaay + +from time import time +from pyload.utils import uniqify + +class PullManager(object): + def __init__(self, core): + self.core = core + self.clients = [] + + def newClient(self, uuid): + self.clients.append(Client(uuid)) + + def clean(self): + for n, client in enumerate(self.clients): + if client.lastActive + 30 < time(): + del self.clients[n] + + def getEvents(self, uuid): + events = [] + validUuid = False + for client in self.clients: + if client.uuid == uuid: + client.lastActive = time() + validUuid = True + while client.newEvents(): + events.append(client.popEvent().toList()) + break + if not validUuid: + self.newClient(uuid) + events = [ReloadAllEvent("queue").toList(), ReloadAllEvent("collector").toList()] + return uniqify(events) + + def addEvent(self, event): + for client in self.clients: + client.addEvent(event) + +class Client(object): + def __init__(self, uuid): + self.uuid = uuid + self.lastActive = time() + self.events = [] + + def newEvents(self): + return len(self.events) > 0 + + def popEvent(self): + if not len(self.events): + return None + return self.events.pop(0) + + def addEvent(self, event): + self.events.append(event) + +class UpdateEvent(object): + def __init__(self, itype, iid, destination): + assert itype == "pack" or itype == "file" + assert destination == "queue" or destination == "collector" + self.type = itype + self.id = iid + self.destination = destination + + def toList(self): + return ["update", self.destination, self.type, self.id] + +class RemoveEvent(object): + def __init__(self, itype, iid, destination): + assert itype == "pack" or itype == "file" + assert destination == "queue" or destination == "collector" + self.type = itype + self.id = iid + self.destination = destination + + def toList(self): + return ["remove", self.destination, self.type, self.id] + +class InsertEvent(object): + def __init__(self, itype, iid, after, destination): + assert itype == "pack" or itype == "file" + assert destination == "queue" or destination == "collector" + self.type = itype + self.id = iid + self.after = after + self.destination = destination + + def toList(self): + return ["insert", self.destination, self.type, self.id, self.after] + +class ReloadAllEvent(object): + def __init__(self, destination): + assert destination == "queue" or destination == "collector" + self.destination = destination + + def toList(self): + return ["reload", self.destination] + +class AccountUpdateEvent(object): + def toList(self): + return ["account"] + +class ConfigUpdateEvent(object): + def toList(self): + return ["config"] diff --git a/pyload/manager/Plugin.py b/pyload/manager/Plugin.py new file mode 100644 index 000000000..71a7131c4 --- /dev/null +++ b/pyload/manager/Plugin.py @@ -0,0 +1,404 @@ +# -*- coding: utf-8 -*- + +from __future__ import with_statement + +import re +import sys + +from itertools import chain +from os import listdir, makedirs +from os.path import isdir, isfile, join, exists, abspath +from sys import version_info +from traceback import print_exc +from urllib import unquote + +from SafeEval import const_eval as literal_eval + + +class PluginManager(object): + ROOT = "pyload.plugin." + USERROOT = "userplugins." + TYPES = ["account", "addon", "container", "crypter", "hook", "hoster", "internal", "ocr"] + + PATTERN = re.compile(r'__pattern\s*=\s*u?r("|\')([^"\']+)') + VERSION = re.compile(r'__version\s*=\s*("|\')([\d.]+)') + CONFIG = re.compile(r'__config\s*=\s*\[([^\]]+)', re.M) + DESC = re.compile(r'__description\s*=\s*("|"""|\')([^"\']+)') + + + def __init__(self, core): + self.core = core + + self.plugins = {} + self.createIndex() + + #register for import addon + sys.meta_path.append(self) + + + def loadTypes(self): + rootdir = join(pypath, "pyload", "plugins") + userdir = "userplugins" + + types = set().union(*[[d for d in listdir(p) if isdir(join(p, d))] + for p in (rootdir, userdir) if exists(p)]) + + if not types: + self.log.critical(_("No plugins found!")) + + self.TYPES = list(set(self.TYPES) | types) + + + def createIndex(self): + """create information for all plugins available""" + + sys.path.append(abspath("")) + + self.loadTypes() + + for type in self.TYPES: + self.plugins[type] = self.parse(type) + setattr(self, "%sPlugins" % type, self.plugins[type]) + + self.plugins['addon'] = self.addonPlugins.update(self.hookPlugins) + + self.core.log.debug("Created index of plugins") + + + def parse(self, folder, rootplugins={}): + """ + returns dict with information + home contains parsed plugins from pyload. + """ + + plugins = {} + + if rootplugins: + try: + pfolder = join("userplugins", folder) + if not exists(pfolder): + makedirs(pfolder) + + for ifile in (join("userplugins", "__init__.py"), + join(pfolder, "__init__.py")): + if not exists(ifile): + f = open(ifile, "wb") + f.close() + + except IOError, e: + self.core.log.critical(str(e)) + return rootplugins + + else: + pfolder = join(pypath, "pyload", "plugins", folder) + + for f in listdir(pfolder): + if (isfile(join(pfolder, f)) and f.endswith(".py") or f.endswith("_25.pyc") or f.endswith( + "_26.pyc") or f.endswith("_27.pyc")) and not f.startswith("_"): + + try: + with open(join(pfolder, f)) as data: + content = data.read() + + except IOError, e: + self.core.log.error(str(e)) + continue + + if f.endswith("_25.pyc") and version_info[0:2] != (2, 5): #@TODO: Remove in 0.4.10 + continue + + elif f.endswith("_26.pyc") and version_info[0:2] != (2, 6): #@TODO: Remove in 0.4.10 + continue + + elif f.endswith("_27.pyc") and version_info[0:2] != (2, 7): #@TODO: Remove in 0.4.10 + continue + + name = f[:-3] + if name[-1] == ".": + name = name[:-4] + + version = self.VERSION.findall(content) + if version: + version = float(version[0][1]) + else: + version = 0 + + if rootplugins and name in rootplugins: + if rootplugins[name]['version'] >= version: + continue + + plugins[name] = {} + plugins[name]['version'] = version + + module = f.replace(".pyc", "").replace(".py", "") + + # the plugin is loaded from user directory + plugins[name]['user'] = True if rootplugins else False + plugins[name]['name'] = module + + pattern = self.PATTERN.findall(content) + + if pattern: + pattern = pattern[0][1] + + try: + regexp = re.compile(pattern) + except Exception: + self.core.log.error(_("%s has a invalid pattern") % name) + pattern = r'^unmatchable$' + regexp = re.compile(pattern) + + plugins[name]['pattern'] = pattern + plugins[name]['re'] = regexp + + # internals have no config + if folder == "internal": + self.core.config.deleteConfig(name) + continue + + config = self.CONFIG.findall(content) + if config: + try: + config = literal_eval(config[0].strip().replace("\n", "").replace("\r", "")) + desc = self.DESC.findall(content) + desc = desc[0][1] if desc else "" + + if type(config[0]) == tuple: + config = [list(x) for x in config] + else: + config = [list(config)] + + if folder not in ("account", "internal") and not [True for item in config if item[0] == "activated"]: + config.insert(0, ["activated", "bool", "Activated", False if folder in ("addon", "hook") else True]) + + self.core.config.addPluginConfig(name, config, desc) + except Exception: + self.core.log.error("Invalid config in %s: %s" % (name, config)) + + elif folder in ("addon", "hook"): #force config creation + desc = self.DESC.findall(content) + desc = desc[0][1] if desc else "" + config = (["activated", "bool", "Activated", False],) + + try: + self.core.config.addPluginConfig(name, config, desc) + except Exception: + self.core.log.error("Invalid config in %s: %s" % (name, config)) + + if not rootplugins and plugins: #: Double check + plugins.update(self.parse(folder, plugins)) + + return plugins + + + def parseUrls(self, urls): + """parse plugins for given list of urls""" + + last = None + res = [] #: tupels of (url, plugintype, pluginname) + + for url in urls: + if type(url) not in (str, unicode, buffer): + continue + + url = unquote(url) + + if last and last[2]['re'].match(url): + res.append((url, last[0], last[1])) + continue + + for type in self.TYPES: + for name, plugin in self.plugins[type]: + + m = None + try: + if 'pattern' in plugin: + m = plugin['re'].match(url) + + except KeyError: + self.core.log.error(_("Plugin [%(type)s] %(name)s skipped due broken pattern") + % {'name': name, 'type': type}) + + if m: + res.append((url, type, name)) + last = (type, name, plugin) + break + else: + res.append((url, "internal", "BasePlugin")) + + return res + + + def findPlugin(self, type, name): + if type not in self.plugins: + return None + + elif name not in self.plugins[type]: + self.core.log.warning(_("Plugin [%(type)s] %(name)s not found | Using plugin: [internal] BasePlugin") + % {'name': name, 'type': type}) + return self.internalPlugins["BasePlugin"] + + else: + return self.plugins[type][name] + + + def getPlugin(self, type, name, original=False): + """return plugin module from hoster|decrypter|container""" + plugin = self.findPlugin(type, name) + + if plugin is None: + return {} + + if "new_module" in plugin and not original: + return plugin['new_module'] + else: + return self.loadModule(type, name) + + + def getPluginName(self, type, name): + """ used to obtain new name if other plugin was injected""" + plugin = self.findPlugin(type, name) + + if plugin is None: + return "" + + if "new_name" in plugin: + return plugin['new_name'] + + return name + + + def loadModule(self, type, name): + """ Returns loaded module for plugin + + :param type: plugin type, subfolder of pyload.plugins + :param name: + """ + plugins = self.plugins[type] + + if name in plugins: + if "module" in plugins[name]: + return plugins[name]['module'] + + try: + module = __import__(self.ROOT + "%s.%s" % (type, plugins[name]['name']), globals(), locals(), + plugins[name]['name']) + + except Exception, e: + self.core.log.error(_("Error importing plugin: [%(type)s] %(name)s (v%(version).2f) | %(errmsg)s") + % {'name': name, 'type': type, 'version': plugins[name]['version'], "errmsg": str(e)}) + if self.core.debug: + print_exc() + + else: + plugins[name]['module'] = module #: cache import, maybe unneeded + + self.core.log.debug(_("Loaded plugin: [%(type)s] %(name)s (v%(version).2f)") + % {'name': name, 'type': type, 'version': plugins[name]['version']}) + return module + + + def loadClass(self, type, name): + """Returns the class of a plugin with the same name""" + module = self.loadModule(type, name) + if module: + return getattr(module, name) + else: + return None + + + def getAccountPlugins(self): + """return list of account plugin names""" + return self.accountPlugins.keys() + + + def find_module(self, fullname, path=None): + #redirecting imports if necesarry + if fullname.startswith(self.ROOT) or fullname.startswith(self.USERROOT): #seperate pyload plugins + if fullname.startswith(self.USERROOT): user = 1 + else: user = 0 #used as bool and int + + split = fullname.split(".") + if len(split) != 4 - user: return + type, name = split[2 - user:4 - user] + + if type in self.plugins and name in self.plugins[type]: + #userplugin is a newer version + if not user and self.plugins[type][name]['user']: + return self + #imported from userdir, but pyloads is newer + if user and not self.plugins[type][name]['user']: + return self + + + def load_module(self, name, replace=True): + if name not in sys.modules: #could be already in modules + if replace: + if self.ROOT in name: + newname = name.replace(self.ROOT, self.USERROOT) + else: + newname = name.replace(self.USERROOT, self.ROOT) + else: + newname = name + + base, plugin = newname.rsplit(".", 1) + + self.core.log.debug("Redirected import %s -> %s" % (name, newname)) + + module = __import__(newname, globals(), locals(), [plugin]) + #inject under new an old name + sys.modules[name] = module + sys.modules[newname] = module + + return sys.modules[name] + + + def reloadPlugins(self, type_plugins): + """ reload and reindex plugins """ + if not type_plugins: + return None + + self.core.log.debug("Request reload of plugins: %s" % type_plugins) + + reloaded = [] + + as_dict = {} + for t,n in type_plugins: + if t in as_dict: + as_dict[t].append(n) + else: + as_dict[t] = [n] + + for type in as_dict.iterkeys(): + if type in ("addon", "internal"): #: do not reload them because would cause to much side effects + self.core.log.debug("Skipping reload for plugin: [%(type)s] %(name)s" % {'name': plugin, 'type': type}) + continue + + for plugin in as_dict[type]: + if plugin in self.plugins[type] and "module" in self.plugins[type][plugin]: + self.core.log.debug(_("Reloading plugin: [%(type)s] %(name)s") % {'name': plugin, 'type': type}) + + try: + reload(self.plugins[type][plugin]['module']) + + except Exception, e: + self.core.log.error(_("Error when reloading plugin: [%(type)s] %(name)s") % {'name': plugin, 'type': type}, e) + continue + + else: + reloaded.append((type, plugin)) + + #index creation + self.plugins[type] = self.parse(type) + setattr(self, "%sPlugins" % type, self.plugins[type]) + + if "account" in as_dict: #: accounts needs to be reloaded + self.core.accountManager.initPlugins() + self.core.scheduler.addJob(0, self.core.accountManager.getAccountInfos) + + return reloaded #: return a list of the plugins successfully reloaded + + + def reloadPlugin(self, type_plugin): + """ reload and reindex ONE plugin """ + return True if self.reloadPlugins(type_plugin) else False diff --git a/pyload/manager/PluginManager.py b/pyload/manager/PluginManager.py deleted file mode 100644 index c327c991a..000000000 --- a/pyload/manager/PluginManager.py +++ /dev/null @@ -1,404 +0,0 @@ -# -*- coding: utf-8 -*- - -from __future__ import with_statement - -import re -import sys - -from itertools import chain -from os import listdir, makedirs -from os.path import isdir, isfile, join, exists, abspath -from sys import version_info -from traceback import print_exc -from urllib import unquote - -from SafeEval import const_eval as literal_eval - - -class PluginManager(object): - ROOT = "pyload.plugins." - USERROOT = "userplugins." - TYPES = ["account", "addon", "container", "crypter", "hook", "hoster", "internal", "ocr"] - - PATTERN = re.compile(r'__pattern\s*=\s*u?r("|\')([^"\']+)') - VERSION = re.compile(r'__version\s*=\s*("|\')([\d.]+)') - CONFIG = re.compile(r'__config\s*=\s*\[([^\]]+)', re.M) - DESC = re.compile(r'__description\s*=\s*("|"""|\')([^"\']+)') - - - def __init__(self, core): - self.core = core - - self.plugins = {} - self.createIndex() - - #register for import addon - sys.meta_path.append(self) - - - def loadTypes(self): - rootdir = join(pypath, "pyload", "plugins") - userdir = "userplugins" - - types = set().union(*[[d for d in listdir(p) if isdir(join(p, d))] - for p in (rootdir, userdir) if exists(p)]) - - if not types: - self.log.critical(_("No plugins found!")) - - self.TYPES = list(set(self.TYPES) | types) - - - def createIndex(self): - """create information for all plugins available""" - - sys.path.append(abspath("")) - - self.loadTypes() - - for type in self.TYPES: - self.plugins[type] = self.parse(type) - setattr(self, "%sPlugins" % type, self.plugins[type]) - - self.plugins['addon'] = self.addonPlugins.update(self.hookPlugins) - - self.core.log.debug("Created index of plugins") - - - def parse(self, folder, rootplugins={}): - """ - returns dict with information - home contains parsed plugins from pyload. - """ - - plugins = {} - - if rootplugins: - try: - pfolder = join("userplugins", folder) - if not exists(pfolder): - makedirs(pfolder) - - for ifile in (join("userplugins", "__init__.py"), - join(pfolder, "__init__.py")): - if not exists(ifile): - f = open(ifile, "wb") - f.close() - - except IOError, e: - self.core.log.critical(str(e)) - return rootplugins - - else: - pfolder = join(pypath, "pyload", "plugins", folder) - - for f in listdir(pfolder): - if (isfile(join(pfolder, f)) and f.endswith(".py") or f.endswith("_25.pyc") or f.endswith( - "_26.pyc") or f.endswith("_27.pyc")) and not f.startswith("_"): - - try: - with open(join(pfolder, f)) as data: - content = data.read() - - except IOError, e: - self.core.log.error(str(e)) - continue - - if f.endswith("_25.pyc") and version_info[0:2] != (2, 5): #@TODO: Remove in 0.4.10 - continue - - elif f.endswith("_26.pyc") and version_info[0:2] != (2, 6): #@TODO: Remove in 0.4.10 - continue - - elif f.endswith("_27.pyc") and version_info[0:2] != (2, 7): #@TODO: Remove in 0.4.10 - continue - - name = f[:-3] - if name[-1] == ".": - name = name[:-4] - - version = self.VERSION.findall(content) - if version: - version = float(version[0][1]) - else: - version = 0 - - if rootplugins and name in rootplugins: - if rootplugins[name]['version'] >= version: - continue - - plugins[name] = {} - plugins[name]['version'] = version - - module = f.replace(".pyc", "").replace(".py", "") - - # the plugin is loaded from user directory - plugins[name]['user'] = True if rootplugins else False - plugins[name]['name'] = module - - pattern = self.PATTERN.findall(content) - - if pattern: - pattern = pattern[0][1] - - try: - regexp = re.compile(pattern) - except Exception: - self.core.log.error(_("%s has a invalid pattern") % name) - pattern = r'^unmatchable$' - regexp = re.compile(pattern) - - plugins[name]['pattern'] = pattern - plugins[name]['re'] = regexp - - # internals have no config - if folder == "internal": - self.core.config.deleteConfig(name) - continue - - config = self.CONFIG.findall(content) - if config: - try: - config = literal_eval(config[0].strip().replace("\n", "").replace("\r", "")) - desc = self.DESC.findall(content) - desc = desc[0][1] if desc else "" - - if type(config[0]) == tuple: - config = [list(x) for x in config] - else: - config = [list(config)] - - if folder not in ("account", "internal") and not [True for item in config if item[0] == "activated"]: - config.insert(0, ["activated", "bool", "Activated", False if folder in ("addon", "hook") else True]) - - self.core.config.addPluginConfig(name, config, desc) - except Exception: - self.core.log.error("Invalid config in %s: %s" % (name, config)) - - elif folder in ("addon", "hook"): #force config creation - desc = self.DESC.findall(content) - desc = desc[0][1] if desc else "" - config = (["activated", "bool", "Activated", False],) - - try: - self.core.config.addPluginConfig(name, config, desc) - except Exception: - self.core.log.error("Invalid config in %s: %s" % (name, config)) - - if not rootplugins and plugins: #: Double check - plugins.update(self.parse(folder, plugins)) - - return plugins - - - def parseUrls(self, urls): - """parse plugins for given list of urls""" - - last = None - res = [] #: tupels of (url, plugintype, pluginname) - - for url in urls: - if type(url) not in (str, unicode, buffer): - continue - - url = unquote(url) - - if last and last[2]['re'].match(url): - res.append((url, last[0], last[1])) - continue - - for type in self.TYPES: - for name, plugin in self.plugins[type]: - - m = None - try: - if 'pattern' in plugin: - m = plugin['re'].match(url) - - except KeyError: - self.core.log.error(_("Plugin [%(type)s] %(name)s skipped due broken pattern") - % {'name': name, 'type': type}) - - if m: - res.append((url, type, name)) - last = (type, name, plugin) - break - else: - res.append((url, "internal", "BasePlugin")) - - return res - - - def findPlugin(self, type, name): - if type not in self.plugins: - return None - - elif name not in self.plugins[type]: - self.core.log.warning(_("Plugin [%(type)s] %(name)s not found | Using plugin: [internal] BasePlugin") - % {'name': name, 'type': type}) - return self.internalPlugins["BasePlugin"] - - else: - return self.plugins[type][name] - - - def getPlugin(self, type, name, original=False): - """return plugin module from hoster|decrypter|container""" - plugin = self.findPlugin(type, name) - - if plugin is None: - return {} - - if "new_module" in plugin and not original: - return plugin['new_module'] - else: - return self.loadModule(type, name) - - - def getPluginName(self, type, name): - """ used to obtain new name if other plugin was injected""" - plugin = self.findPlugin(type, name) - - if plugin is None: - return "" - - if "new_name" in plugin: - return plugin['new_name'] - - return name - - - def loadModule(self, type, name): - """ Returns loaded module for plugin - - :param type: plugin type, subfolder of pyload.plugins - :param name: - """ - plugins = self.plugins[type] - - if name in plugins: - if "module" in plugins[name]: - return plugins[name]['module'] - - try: - module = __import__(self.ROOT + "%s.%s" % (type, plugins[name]['name']), globals(), locals(), - plugins[name]['name']) - - except Exception, e: - self.core.log.error(_("Error importing plugin: [%(type)s] %(name)s (v%(version).2f) | %(errmsg)s") - % {'name': name, 'type': type, 'version': plugins[name]['version'], "errmsg": str(e)}) - if self.core.debug: - print_exc() - - else: - plugins[name]['module'] = module #: cache import, maybe unneeded - - self.core.log.debug(_("Loaded plugin: [%(type)s] %(name)s (v%(version).2f)") - % {'name': name, 'type': type, 'version': plugins[name]['version']}) - return module - - - def loadClass(self, type, name): - """Returns the class of a plugin with the same name""" - module = self.loadModule(type, name) - if module: - return getattr(module, name) - else: - return None - - - def getAccountPlugins(self): - """return list of account plugin names""" - return self.accountPlugins.keys() - - - def find_module(self, fullname, path=None): - #redirecting imports if necesarry - if fullname.startswith(self.ROOT) or fullname.startswith(self.USERROOT): #seperate pyload plugins - if fullname.startswith(self.USERROOT): user = 1 - else: user = 0 #used as bool and int - - split = fullname.split(".") - if len(split) != 4 - user: return - type, name = split[2 - user:4 - user] - - if type in self.plugins and name in self.plugins[type]: - #userplugin is a newer version - if not user and self.plugins[type][name]['user']: - return self - #imported from userdir, but pyloads is newer - if user and not self.plugins[type][name]['user']: - return self - - - def load_module(self, name, replace=True): - if name not in sys.modules: #could be already in modules - if replace: - if self.ROOT in name: - newname = name.replace(self.ROOT, self.USERROOT) - else: - newname = name.replace(self.USERROOT, self.ROOT) - else: - newname = name - - base, plugin = newname.rsplit(".", 1) - - self.core.log.debug("Redirected import %s -> %s" % (name, newname)) - - module = __import__(newname, globals(), locals(), [plugin]) - #inject under new an old name - sys.modules[name] = module - sys.modules[newname] = module - - return sys.modules[name] - - - def reloadPlugins(self, type_plugins): - """ reload and reindex plugins """ - if not type_plugins: - return None - - self.core.log.debug("Request reload of plugins: %s" % type_plugins) - - reloaded = [] - - as_dict = {} - for t,n in type_plugins: - if t in as_dict: - as_dict[t].append(n) - else: - as_dict[t] = [n] - - for type in as_dict.iterkeys(): - if type in ("addon", "internal"): #: do not reload them because would cause to much side effects - self.core.log.debug("Skipping reload for plugin: [%(type)s] %(name)s" % {'name': plugin, 'type': type}) - continue - - for plugin in as_dict[type]: - if plugin in self.plugins[type] and "module" in self.plugins[type][plugin]: - self.core.log.debug(_("Reloading plugin: [%(type)s] %(name)s") % {'name': plugin, 'type': type}) - - try: - reload(self.plugins[type][plugin]['module']) - - except Exception, e: - self.core.log.error(_("Error when reloading plugin: [%(type)s] %(name)s") % {'name': plugin, 'type': type}, e) - continue - - else: - reloaded.append((type, plugin)) - - #index creation - self.plugins[type] = self.parse(type) - setattr(self, "%sPlugins" % type, self.plugins[type]) - - if "account" in as_dict: #: accounts needs to be reloaded - self.core.accountManager.initPlugins() - self.core.scheduler.addJob(0, self.core.accountManager.getAccountInfos) - - return reloaded #: return a list of the plugins successfully reloaded - - - def reloadPlugin(self, type_plugin): - """ reload and reindex ONE plugin """ - return True if self.reloadPlugins(type_plugin) else False diff --git a/pyload/manager/Remote.py b/pyload/manager/Remote.py new file mode 100644 index 000000000..910881164 --- /dev/null +++ b/pyload/manager/Remote.py @@ -0,0 +1,76 @@ +# -*- coding: utf-8 -*- +# @author: RaNaN + +from threading import Thread +from traceback import print_exc + +class BackendBase(Thread): + def __init__(self, manager): + Thread.__init__(self) + self.m = manager + self.core = manager.core + self.enabled = True + self.running = False + + def run(self): + self.running = True + try: + self.serve() + except Exception, e: + self.core.log.error(_("Remote backend error: %s") % e) + if self.core.debug: + print_exc() + finally: + self.running = False + + def setup(self, host, port): + pass + + def checkDeps(self): + return True + + def serve(self): + pass + + def shutdown(self): + pass + + def stop(self): + self.enabled = False# set flag and call shutdowm message, so thread can react + self.shutdown() + + +class RemoteManager(object): + available = [] + + def __init__(self, core): + self.core = core + self.backends = [] + + if self.core.remote: + self.available.append("ThriftBackend") +# else: +# self.available.append("SocketBackend") + + + def startBackends(self): + host = self.core.config["remote"]["listenaddr"] + port = self.core.config["remote"]["port"] + + for b in self.available: + klass = getattr(__import__("pyload.remote.%s" % b, globals(), locals(), [b], -1), b) + backend = klass(self) + if not backend.checkDeps(): + continue + try: + backend.setup(host, port) + self.core.log.info(_("Starting %(name)s: %(addr)s:%(port)s") % {"name": b, "addr": host, "port": port}) + except Exception, e: + self.core.log.error(_("Failed loading backend %(name)s | %(error)s") % {"name": b, "error": str(e)}) + if self.core.debug: + print_exc() + else: + backend.start() + self.backends.append(backend) + + port += 1 diff --git a/pyload/manager/RemoteManager.py b/pyload/manager/RemoteManager.py deleted file mode 100644 index 910881164..000000000 --- a/pyload/manager/RemoteManager.py +++ /dev/null @@ -1,76 +0,0 @@ -# -*- coding: utf-8 -*- -# @author: RaNaN - -from threading import Thread -from traceback import print_exc - -class BackendBase(Thread): - def __init__(self, manager): - Thread.__init__(self) - self.m = manager - self.core = manager.core - self.enabled = True - self.running = False - - def run(self): - self.running = True - try: - self.serve() - except Exception, e: - self.core.log.error(_("Remote backend error: %s") % e) - if self.core.debug: - print_exc() - finally: - self.running = False - - def setup(self, host, port): - pass - - def checkDeps(self): - return True - - def serve(self): - pass - - def shutdown(self): - pass - - def stop(self): - self.enabled = False# set flag and call shutdowm message, so thread can react - self.shutdown() - - -class RemoteManager(object): - available = [] - - def __init__(self, core): - self.core = core - self.backends = [] - - if self.core.remote: - self.available.append("ThriftBackend") -# else: -# self.available.append("SocketBackend") - - - def startBackends(self): - host = self.core.config["remote"]["listenaddr"] - port = self.core.config["remote"]["port"] - - for b in self.available: - klass = getattr(__import__("pyload.remote.%s" % b, globals(), locals(), [b], -1), b) - backend = klass(self) - if not backend.checkDeps(): - continue - try: - backend.setup(host, port) - self.core.log.info(_("Starting %(name)s: %(addr)s:%(port)s") % {"name": b, "addr": host, "port": port}) - except Exception, e: - self.core.log.error(_("Failed loading backend %(name)s | %(error)s") % {"name": b, "error": str(e)}) - if self.core.debug: - print_exc() - else: - backend.start() - self.backends.append(backend) - - port += 1 diff --git a/pyload/manager/Thread.py b/pyload/manager/Thread.py new file mode 100644 index 000000000..6c9304e87 --- /dev/null +++ b/pyload/manager/Thread.py @@ -0,0 +1,302 @@ +# -*- coding: utf-8 -*- +# @author: RaNaN + +from os.path import exists, join +import re +from subprocess import Popen +from threading import Event, Lock +from time import sleep, time +from traceback import print_exc +from random import choice + +import pycurl + +from pyload.manager.thread.Decrypter import DecrypterThread +from pyload.manager.thread.Download import DownloadThread +from pyload.manager.thread.Info import InfoThread +from pyload.datatype.File import PyFile +from pyload.network.RequestFactory import getURL +from pyload.utils import freeSpace, lock + + +class ThreadManager(object): + """manages the download threads, assign jobs, reconnect etc""" + + + def __init__(self, core): + """Constructor""" + self.core = core + + self.threads = [] #: thread list + self.localThreads = [] #: addon+decrypter threads + + self.pause = True + + self.reconnecting = Event() + self.reconnecting.clear() + self.downloaded = 0 #number of files downloaded since last cleanup + + self.lock = Lock() + + # some operations require to fetch url info from hoster, so we caching them so it wont be done twice + # contains a timestamp and will be purged after timeout + self.infoCache = {} + + # pool of ids for online check + self.resultIDs = 0 + + # threads which are fetching hoster results + self.infoResults = {} + #timeout for cache purge + self.timestamp = 0 + + pycurl.global_init(pycurl.GLOBAL_DEFAULT) + + for i in range(0, self.core.config.get("download", "max_downloads")): + self.createThread() + + + def createThread(self): + """create a download thread""" + + thread = DownloadThread(self) + self.threads.append(thread) + + def createInfoThread(self, data, pid): + """ + start a thread whichs fetches online status and other infos + data = [ .. () .. ] + """ + self.timestamp = time() + 5 * 60 + + InfoThread(self, data, pid) + + @lock + def createResultThread(self, data, add=False): + """ creates a thread to fetch online status, returns result id """ + self.timestamp = time() + 5 * 60 + + rid = self.resultIDs + self.resultIDs += 1 + + InfoThread(self, data, rid=rid, add=add) + + return rid + + + @lock + def getInfoResult(self, rid): + """returns result and clears it""" + self.timestamp = time() + 5 * 60 + + if rid in self.infoResults: + data = self.infoResults[rid] + self.infoResults[rid] = {} + return data + else: + return {} + + @lock + def setInfoResults(self, rid, result): + self.infoResults[rid].update(result) + + def getActiveFiles(self): + active = [x.active for x in self.threads if x.active and isinstance(x.active, PyFile)] + + for t in self.localThreads: + active.extend(t.getActiveFiles()) + + return active + + def processingIds(self): + """get a id list of all pyfiles processed""" + return [x.id for x in self.getActiveFiles()] + + + def work(self): + """run all task which have to be done (this is for repetivive call by core)""" + try: + self.tryReconnect() + except Exception, e: + self.core.log.error(_("Reconnect Failed: %s") % str(e) ) + self.reconnecting.clear() + if self.core.debug: + print_exc() + self.checkThreadCount() + + try: + self.assignJob() + except Exception, e: + self.core.log.warning("Assign job error", e) + if self.core.debug: + print_exc() + + sleep(0.5) + self.assignJob() + #it may be failed non critical so we try it again + + if (self.infoCache or self.infoResults) and self.timestamp < time(): + self.infoCache.clear() + self.infoResults.clear() + self.core.log.debug("Cleared Result cache") + + #-------------------------------------------------------------------------- + def tryReconnect(self): + """checks if reconnect needed""" + + if not (self.core.config["reconnect"]["activated"] and self.core.api.isTimeReconnect()): + return False + + active = [x.active.plugin.wantReconnect and x.active.plugin.waiting for x in self.threads if x.active] + + if not (0 < active.count(True) == len(active)): + return False + + if not exists(self.core.config['reconnect']['method']): + if exists(join(pypath, self.core.config['reconnect']['method'])): + self.core.config['reconnect']['method'] = join(pypath, self.core.config['reconnect']['method']) + else: + self.core.config["reconnect"]["activated"] = False + self.core.log.warning(_("Reconnect script not found!")) + return + + self.reconnecting.set() + + #Do reconnect + self.core.log.info(_("Starting reconnect")) + + while [x.active.plugin.waiting for x in self.threads if x.active].count(True) != 0: + sleep(0.25) + + ip = self.getIP() + + self.core.addonManager.beforeReconnecting(ip) + + self.core.log.debug("Old IP: %s" % ip) + + try: + reconn = Popen(self.core.config['reconnect']['method'], bufsize=-1, shell=True)#, stdout=subprocess.PIPE) + except Exception: + self.core.log.warning(_("Failed executing reconnect script!")) + self.core.config["reconnect"]["activated"] = False + self.reconnecting.clear() + if self.core.debug: + print_exc() + return + + reconn.wait() + sleep(1) + ip = self.getIP() + self.core.addonManager.afterReconnecting(ip) + + self.core.log.info(_("Reconnected, new IP: %s") % ip) + + self.reconnecting.clear() + + def getIP(self): + """retrieve current ip""" + services = [("http://automation.whatismyip.com/n09230945.asp", "(\S+)"), + ("http://checkip.dyndns.org/",".*Current IP Address: (\S+).*")] + + ip = "" + for i in range(10): + try: + sv = choice(services) + ip = getURL(sv[0]) + ip = re.match(sv[1], ip).group(1) + break + except Exception: + ip = "" + sleep(1) + + return ip + + #-------------------------------------------------------------------------- + def checkThreadCount(self): + """checks if there are need for increasing or reducing thread count""" + + if len(self.threads) == self.core.config.get("download", "max_downloads"): + return True + elif len(self.threads) < self.core.config.get("download", "max_downloads"): + self.createThread() + else: + free = [x for x in self.threads if not x.active] + if free: + free[0].put("quit") + + + def cleanPycurl(self): + """ make a global curl cleanup (currently ununused) """ + if self.processingIds(): + return False + pycurl.global_cleanup() + pycurl.global_init(pycurl.GLOBAL_DEFAULT) + self.downloaded = 0 + self.core.log.debug("Cleaned up pycurl") + return True + + #-------------------------------------------------------------------------- + def assignJob(self): + """assing a job to a thread if possible""" + + if self.pause or not self.core.api.isTimeDownload(): return + + #if self.downloaded > 20: + # if not self.cleanPyCurl(): return + + free = [x for x in self.threads if not x.active] + + inuse = set([(x.active.pluginname, self.getLimit(x)) for x in self.threads if x.active and x.active.hasPlugin() and x.active.plugin.account]) + inuse = map(lambda x: (x[0], x[1], len([y for y in self.threads if y.active and y.active.pluginname == x[0]])) ,inuse) + onlimit = [x[0] for x in inuse if x[1] > 0 and x[2] >= x[1]] + + occ = [x.active.pluginname for x in self.threads if x.active and x.active.hasPlugin() and not x.active.plugin.multiDL] + onlimit + + occ.sort() + occ = tuple(set(occ)) + job = self.core.files.getJob(occ) + if job: + try: + job.initPlugin() + except Exception, e: + self.core.log.critical(str(e)) + print_exc() + job.setStatus("failed") + job.error = str(e) + job.release() + return + + if job.plugin.__type == "hoster": + spaceLeft = freeSpace(self.core.config["general"]["download_folder"]) / 1024 / 1024 + if spaceLeft < self.core.config["general"]["min_free_space"]: + self.core.log.warning(_("Not enough space left on device")) + self.pause = True + + if free and not self.pause: + thread = free[0] + #self.downloaded += 1 + + thread.put(job) + else: + #put job back + if occ not in self.core.files.jobCache: + self.core.files.jobCache[occ] = [] + self.core.files.jobCache[occ].append(job.id) + + #check for decrypt jobs + job = self.core.files.getDecryptJob() + if job: + job.initPlugin() + thread = DecrypterThread(self, job) + + + else: + thread = DecrypterThread(self, job) + + def getLimit(self, thread): + limit = thread.active.plugin.account.getAccountData(thread.active.plugin.user)["options"].get("limitDL", ["0"])[0] + return int(limit) + + def cleanup(self): + """do global cleanup, should be called when finished with pycurl""" + pycurl.global_cleanup() diff --git a/pyload/manager/ThreadManager.py b/pyload/manager/ThreadManager.py deleted file mode 100644 index d6f3c0005..000000000 --- a/pyload/manager/ThreadManager.py +++ /dev/null @@ -1,302 +0,0 @@ -# -*- coding: utf-8 -*- -# @author: RaNaN - -from os.path import exists, join -import re -from subprocess import Popen -from threading import Event, Lock -from time import sleep, time -from traceback import print_exc -from random import choice - -import pycurl - -from pyload.manager.thread.DecrypterThread import DecrypterThread -from pyload.manager.thread.DownloadThread import DownloadThread -from pyload.manager.thread.InfoThread import InfoThread -from pyload.datatype.PyFile import PyFile -from pyload.network.RequestFactory import getURL -from pyload.utils import freeSpace, lock - - -class ThreadManager(object): - """manages the download threads, assign jobs, reconnect etc""" - - - def __init__(self, core): - """Constructor""" - self.core = core - - self.threads = [] #: thread list - self.localThreads = [] #: addon+decrypter threads - - self.pause = True - - self.reconnecting = Event() - self.reconnecting.clear() - self.downloaded = 0 #number of files downloaded since last cleanup - - self.lock = Lock() - - # some operations require to fetch url info from hoster, so we caching them so it wont be done twice - # contains a timestamp and will be purged after timeout - self.infoCache = {} - - # pool of ids for online check - self.resultIDs = 0 - - # threads which are fetching hoster results - self.infoResults = {} - #timeout for cache purge - self.timestamp = 0 - - pycurl.global_init(pycurl.GLOBAL_DEFAULT) - - for i in range(0, self.core.config.get("download", "max_downloads")): - self.createThread() - - - def createThread(self): - """create a download thread""" - - thread = DownloadThread(self) - self.threads.append(thread) - - def createInfoThread(self, data, pid): - """ - start a thread whichs fetches online status and other infos - data = [ .. () .. ] - """ - self.timestamp = time() + 5 * 60 - - InfoThread(self, data, pid) - - @lock - def createResultThread(self, data, add=False): - """ creates a thread to fetch online status, returns result id """ - self.timestamp = time() + 5 * 60 - - rid = self.resultIDs - self.resultIDs += 1 - - InfoThread(self, data, rid=rid, add=add) - - return rid - - - @lock - def getInfoResult(self, rid): - """returns result and clears it""" - self.timestamp = time() + 5 * 60 - - if rid in self.infoResults: - data = self.infoResults[rid] - self.infoResults[rid] = {} - return data - else: - return {} - - @lock - def setInfoResults(self, rid, result): - self.infoResults[rid].update(result) - - def getActiveFiles(self): - active = [x.active for x in self.threads if x.active and isinstance(x.active, PyFile)] - - for t in self.localThreads: - active.extend(t.getActiveFiles()) - - return active - - def processingIds(self): - """get a id list of all pyfiles processed""" - return [x.id for x in self.getActiveFiles()] - - - def work(self): - """run all task which have to be done (this is for repetivive call by core)""" - try: - self.tryReconnect() - except Exception, e: - self.core.log.error(_("Reconnect Failed: %s") % str(e) ) - self.reconnecting.clear() - if self.core.debug: - print_exc() - self.checkThreadCount() - - try: - self.assignJob() - except Exception, e: - self.core.log.warning("Assign job error", e) - if self.core.debug: - print_exc() - - sleep(0.5) - self.assignJob() - #it may be failed non critical so we try it again - - if (self.infoCache or self.infoResults) and self.timestamp < time(): - self.infoCache.clear() - self.infoResults.clear() - self.core.log.debug("Cleared Result cache") - - #-------------------------------------------------------------------------- - def tryReconnect(self): - """checks if reconnect needed""" - - if not (self.core.config["reconnect"]["activated"] and self.core.api.isTimeReconnect()): - return False - - active = [x.active.plugin.wantReconnect and x.active.plugin.waiting for x in self.threads if x.active] - - if not (0 < active.count(True) == len(active)): - return False - - if not exists(self.core.config['reconnect']['method']): - if exists(join(pypath, self.core.config['reconnect']['method'])): - self.core.config['reconnect']['method'] = join(pypath, self.core.config['reconnect']['method']) - else: - self.core.config["reconnect"]["activated"] = False - self.core.log.warning(_("Reconnect script not found!")) - return - - self.reconnecting.set() - - #Do reconnect - self.core.log.info(_("Starting reconnect")) - - while [x.active.plugin.waiting for x in self.threads if x.active].count(True) != 0: - sleep(0.25) - - ip = self.getIP() - - self.core.addonManager.beforeReconnecting(ip) - - self.core.log.debug("Old IP: %s" % ip) - - try: - reconn = Popen(self.core.config['reconnect']['method'], bufsize=-1, shell=True)#, stdout=subprocess.PIPE) - except Exception: - self.core.log.warning(_("Failed executing reconnect script!")) - self.core.config["reconnect"]["activated"] = False - self.reconnecting.clear() - if self.core.debug: - print_exc() - return - - reconn.wait() - sleep(1) - ip = self.getIP() - self.core.addonManager.afterReconnecting(ip) - - self.core.log.info(_("Reconnected, new IP: %s") % ip) - - self.reconnecting.clear() - - def getIP(self): - """retrieve current ip""" - services = [("http://automation.whatismyip.com/n09230945.asp", "(\S+)"), - ("http://checkip.dyndns.org/",".*Current IP Address: (\S+).*")] - - ip = "" - for i in range(10): - try: - sv = choice(services) - ip = getURL(sv[0]) - ip = re.match(sv[1], ip).group(1) - break - except Exception: - ip = "" - sleep(1) - - return ip - - #-------------------------------------------------------------------------- - def checkThreadCount(self): - """checks if there are need for increasing or reducing thread count""" - - if len(self.threads) == self.core.config.get("download", "max_downloads"): - return True - elif len(self.threads) < self.core.config.get("download", "max_downloads"): - self.createThread() - else: - free = [x for x in self.threads if not x.active] - if free: - free[0].put("quit") - - - def cleanPycurl(self): - """ make a global curl cleanup (currently ununused) """ - if self.processingIds(): - return False - pycurl.global_cleanup() - pycurl.global_init(pycurl.GLOBAL_DEFAULT) - self.downloaded = 0 - self.core.log.debug("Cleaned up pycurl") - return True - - #-------------------------------------------------------------------------- - def assignJob(self): - """assing a job to a thread if possible""" - - if self.pause or not self.core.api.isTimeDownload(): return - - #if self.downloaded > 20: - # if not self.cleanPyCurl(): return - - free = [x for x in self.threads if not x.active] - - inuse = set([(x.active.pluginname, self.getLimit(x)) for x in self.threads if x.active and x.active.hasPlugin() and x.active.plugin.account]) - inuse = map(lambda x: (x[0], x[1], len([y for y in self.threads if y.active and y.active.pluginname == x[0]])) ,inuse) - onlimit = [x[0] for x in inuse if x[1] > 0 and x[2] >= x[1]] - - occ = [x.active.pluginname for x in self.threads if x.active and x.active.hasPlugin() and not x.active.plugin.multiDL] + onlimit - - occ.sort() - occ = tuple(set(occ)) - job = self.core.files.getJob(occ) - if job: - try: - job.initPlugin() - except Exception, e: - self.core.log.critical(str(e)) - print_exc() - job.setStatus("failed") - job.error = str(e) - job.release() - return - - if job.plugin.__type == "hoster": - spaceLeft = freeSpace(self.core.config["general"]["download_folder"]) / 1024 / 1024 - if spaceLeft < self.core.config["general"]["min_free_space"]: - self.core.log.warning(_("Not enough space left on device")) - self.pause = True - - if free and not self.pause: - thread = free[0] - #self.downloaded += 1 - - thread.put(job) - else: - #put job back - if occ not in self.core.files.jobCache: - self.core.files.jobCache[occ] = [] - self.core.files.jobCache[occ].append(job.id) - - #check for decrypt jobs - job = self.core.files.getDecryptJob() - if job: - job.initPlugin() - thread = DecrypterThread(self, job) - - - else: - thread = DecrypterThread(self, job) - - def getLimit(self, thread): - limit = thread.active.plugin.account.getAccountData(thread.active.plugin.user)["options"].get("limitDL", ["0"])[0] - return int(limit) - - def cleanup(self): - """do global cleanup, should be called when finished with pycurl""" - pycurl.global_cleanup() diff --git a/pyload/manager/event/PullEvents.py b/pyload/manager/event/PullEvents.py deleted file mode 100644 index 20897290e..000000000 --- a/pyload/manager/event/PullEvents.py +++ /dev/null @@ -1,104 +0,0 @@ -# -*- coding: utf-8 -*- -# @author: mkaay - -from time import time -from pyload.utils import uniqify - -class PullManager(object): - def __init__(self, core): - self.core = core - self.clients = [] - - def newClient(self, uuid): - self.clients.append(Client(uuid)) - - def clean(self): - for n, client in enumerate(self.clients): - if client.lastActive + 30 < time(): - del self.clients[n] - - def getEvents(self, uuid): - events = [] - validUuid = False - for client in self.clients: - if client.uuid == uuid: - client.lastActive = time() - validUuid = True - while client.newEvents(): - events.append(client.popEvent().toList()) - break - if not validUuid: - self.newClient(uuid) - events = [ReloadAllEvent("queue").toList(), ReloadAllEvent("collector").toList()] - return uniqify(events) - - def addEvent(self, event): - for client in self.clients: - client.addEvent(event) - -class Client(object): - def __init__(self, uuid): - self.uuid = uuid - self.lastActive = time() - self.events = [] - - def newEvents(self): - return len(self.events) > 0 - - def popEvent(self): - if not len(self.events): - return None - return self.events.pop(0) - - def addEvent(self, event): - self.events.append(event) - -class UpdateEvent(object): - def __init__(self, itype, iid, destination): - assert itype == "pack" or itype == "file" - assert destination == "queue" or destination == "collector" - self.type = itype - self.id = iid - self.destination = destination - - def toList(self): - return ["update", self.destination, self.type, self.id] - -class RemoveEvent(object): - def __init__(self, itype, iid, destination): - assert itype == "pack" or itype == "file" - assert destination == "queue" or destination == "collector" - self.type = itype - self.id = iid - self.destination = destination - - def toList(self): - return ["remove", self.destination, self.type, self.id] - -class InsertEvent(object): - def __init__(self, itype, iid, after, destination): - assert itype == "pack" or itype == "file" - assert destination == "queue" or destination == "collector" - self.type = itype - self.id = iid - self.after = after - self.destination = destination - - def toList(self): - return ["insert", self.destination, self.type, self.id, self.after] - -class ReloadAllEvent(object): - def __init__(self, destination): - assert destination == "queue" or destination == "collector" - self.destination = destination - - def toList(self): - return ["reload", self.destination] - -class AccountUpdateEvent(object): - def toList(self): - return ["account"] - -class ConfigUpdateEvent(object): - def toList(self): - return ["config"] diff --git a/pyload/manager/thread/Addon.py b/pyload/manager/thread/Addon.py new file mode 100644 index 000000000..7feec227e --- /dev/null +++ b/pyload/manager/thread/Addon.py @@ -0,0 +1,69 @@ +# -*- coding: utf-8 -*- +# @author: RaNaN + +from Queue import Queue +from threading import Thread +from os import listdir, stat +from os.path import join +from time import sleep, time, strftime, gmtime +from traceback import print_exc, format_exc +from pprint import pformat +from sys import exc_info, exc_clear +from copy import copy +from types import MethodType + +from pycurl import error + +from pyload.manager.thread.Plugin import PluginThread + + +class AddonThread(PluginThread): + """thread for addons""" + + #-------------------------------------------------------------------------- + def __init__(self, m, function, args, kwargs): + """Constructor""" + PluginThread.__init__(self, m) + + self.f = function + self.args = args + self.kwargs = kwargs + + self.active = [] + + m.localThreads.append(self) + + self.start() + + def getActiveFiles(self): + return self.active + + def addActive(self, pyfile): + """ Adds a pyfile to active list and thus will be displayed on overview""" + if pyfile not in self.active: + self.active.append(pyfile) + + def finishFile(self, pyfile): + if pyfile in self.active: + self.active.remove(pyfile) + + pyfile.finishIfDone() + + def run(self): + try: + try: + self.kwargs["thread"] = self + self.f(*self.args, **self.kwargs) + except TypeError, e: + #dirty method to filter out exceptions + if "unexpected keyword argument 'thread'" not in e.args[0]: + raise + + del self.kwargs["thread"] + self.f(*self.args, **self.kwargs) + finally: + local = copy(self.active) + for x in local: + self.finishFile(x) + + self.m.localThreads.remove(self) diff --git a/pyload/manager/thread/AddonThread.py b/pyload/manager/thread/AddonThread.py deleted file mode 100644 index a84856b0a..000000000 --- a/pyload/manager/thread/AddonThread.py +++ /dev/null @@ -1,69 +0,0 @@ -# -*- coding: utf-8 -*- -# @author: RaNaN - -from Queue import Queue -from threading import Thread -from os import listdir, stat -from os.path import join -from time import sleep, time, strftime, gmtime -from traceback import print_exc, format_exc -from pprint import pformat -from sys import exc_info, exc_clear -from copy import copy -from types import MethodType - -from pycurl import error - -from pyload.manager.thread.PluginThread import PluginThread - - -class AddonThread(PluginThread): - """thread for addons""" - - #-------------------------------------------------------------------------- - def __init__(self, m, function, args, kwargs): - """Constructor""" - PluginThread.__init__(self, m) - - self.f = function - self.args = args - self.kwargs = kwargs - - self.active = [] - - m.localThreads.append(self) - - self.start() - - def getActiveFiles(self): - return self.active - - def addActive(self, pyfile): - """ Adds a pyfile to active list and thus will be displayed on overview""" - if pyfile not in self.active: - self.active.append(pyfile) - - def finishFile(self, pyfile): - if pyfile in self.active: - self.active.remove(pyfile) - - pyfile.finishIfDone() - - def run(self): - try: - try: - self.kwargs["thread"] = self - self.f(*self.args, **self.kwargs) - except TypeError, e: - #dirty method to filter out exceptions - if "unexpected keyword argument 'thread'" not in e.args[0]: - raise - - del self.kwargs["thread"] - self.f(*self.args, **self.kwargs) - finally: - local = copy(self.active) - for x in local: - self.finishFile(x) - - self.m.localThreads.remove(self) diff --git a/pyload/manager/thread/Decrypter.py b/pyload/manager/thread/Decrypter.py new file mode 100644 index 000000000..51544d1b9 --- /dev/null +++ b/pyload/manager/thread/Decrypter.py @@ -0,0 +1,101 @@ +# -*- coding: utf-8 -*- +# @author: RaNaN + +from Queue import Queue +from threading import Thread +from os import listdir, stat +from os.path import join +from time import sleep, time, strftime, gmtime +from traceback import print_exc, format_exc +from pprint import pformat +from sys import exc_info, exc_clear +from copy import copy +from types import MethodType + +from pycurl import error + +from pyload.manager.thread.Plugin import PluginThread +from pyload.plugin.Plugin import Abort, Fail, Retry + + +class DecrypterThread(PluginThread): + """thread for decrypting""" + + def __init__(self, manager, pyfile): + """constructor""" + PluginThread.__init__(self, manager) + + self.active = pyfile + manager.localThreads.append(self) + + pyfile.setStatus("decrypting") + + self.start() + + def getActiveFiles(self): + return [self.active] + + def run(self): + """run method""" + + pyfile = self.active + retry = False + + try: + self.m.log.info(_("Decrypting starts: %s") % pyfile.name) + pyfile.error = "" + pyfile.plugin.preprocessing(self) + + except NotImplementedError: + self.m.log.error(_("Plugin %s is missing a function.") % pyfile.pluginname) + return + + except Fail, e: + msg = e.args[0] + + if msg == "offline": + pyfile.setStatus("offline") + self.m.log.warning(_("Download is offline: %s") % pyfile.name) + else: + pyfile.setStatus("failed") + self.m.log.error(_("Decrypting failed: %(name)s | %(msg)s") % {"name": pyfile.name, "msg": msg}) + pyfile.error = msg + + if self.m.core.debug: + print_exc() + return + + except Abort: + self.m.log.info(_("Download aborted: %s") % pyfile.name) + pyfile.setStatus("aborted") + + if self.m.core.debug: + print_exc() + return + + except Retry: + self.m.log.info(_("Retrying %s") % pyfile.name) + retry = True + return self.run() + + except Exception, e: + pyfile.setStatus("failed") + self.m.log.error(_("Decrypting failed: %(name)s | %(msg)s") % {"name": pyfile.name, "msg": str(e)}) + pyfile.error = str(e) + + if self.m.core.debug: + print_exc() + self.writeDebugReport(pyfile) + + return + + finally: + if not retry: + pyfile.release() + self.active = False + self.m.core.files.save() + self.m.localThreads.remove(self) + exc_clear() + + if not retry: + pyfile.delete() diff --git a/pyload/manager/thread/DecrypterThread.py b/pyload/manager/thread/DecrypterThread.py deleted file mode 100644 index 003b5f082..000000000 --- a/pyload/manager/thread/DecrypterThread.py +++ /dev/null @@ -1,101 +0,0 @@ -# -*- coding: utf-8 -*- -# @author: RaNaN - -from Queue import Queue -from threading import Thread -from os import listdir, stat -from os.path import join -from time import sleep, time, strftime, gmtime -from traceback import print_exc, format_exc -from pprint import pformat -from sys import exc_info, exc_clear -from copy import copy -from types import MethodType - -from pycurl import error - -from pyload.manager.thread.PluginThread import PluginThread -from pyload.plugins.Plugin import Abort, Fail, Retry - - -class DecrypterThread(PluginThread): - """thread for decrypting""" - - def __init__(self, manager, pyfile): - """constructor""" - PluginThread.__init__(self, manager) - - self.active = pyfile - manager.localThreads.append(self) - - pyfile.setStatus("decrypting") - - self.start() - - def getActiveFiles(self): - return [self.active] - - def run(self): - """run method""" - - pyfile = self.active - retry = False - - try: - self.m.log.info(_("Decrypting starts: %s") % pyfile.name) - pyfile.error = "" - pyfile.plugin.preprocessing(self) - - except NotImplementedError: - self.m.log.error(_("Plugin %s is missing a function.") % pyfile.pluginname) - return - - except Fail, e: - msg = e.args[0] - - if msg == "offline": - pyfile.setStatus("offline") - self.m.log.warning(_("Download is offline: %s") % pyfile.name) - else: - pyfile.setStatus("failed") - self.m.log.error(_("Decrypting failed: %(name)s | %(msg)s") % {"name": pyfile.name, "msg": msg}) - pyfile.error = msg - - if self.m.core.debug: - print_exc() - return - - except Abort: - self.m.log.info(_("Download aborted: %s") % pyfile.name) - pyfile.setStatus("aborted") - - if self.m.core.debug: - print_exc() - return - - except Retry: - self.m.log.info(_("Retrying %s") % pyfile.name) - retry = True - return self.run() - - except Exception, e: - pyfile.setStatus("failed") - self.m.log.error(_("Decrypting failed: %(name)s | %(msg)s") % {"name": pyfile.name, "msg": str(e)}) - pyfile.error = str(e) - - if self.m.core.debug: - print_exc() - self.writeDebugReport(pyfile) - - return - - finally: - if not retry: - pyfile.release() - self.active = False - self.m.core.files.save() - self.m.localThreads.remove(self) - exc_clear() - - if not retry: - pyfile.delete() diff --git a/pyload/manager/thread/Download.py b/pyload/manager/thread/Download.py new file mode 100644 index 000000000..c7d21a4ba --- /dev/null +++ b/pyload/manager/thread/Download.py @@ -0,0 +1,213 @@ +# -*- coding: utf-8 -*- +# @author: RaNaN + +from Queue import Queue +from threading import Thread +from os import listdir, stat +from os.path import join +from time import sleep, time, strftime, gmtime +from traceback import print_exc, format_exc +from pprint import pformat +from sys import exc_info, exc_clear +from copy import copy +from types import MethodType + +from pycurl import error + +from pyload.manager.thread.Plugin import PluginThread +from pyload.plugin.Plugin import Abort, Fail, Reconnect, Retry, SkipDownload + + +class DownloadThread(PluginThread): + """thread for downloading files from 'real' hoster plugins""" + + #-------------------------------------------------------------------------- + def __init__(self, manager): + """Constructor""" + PluginThread.__init__(self, manager) + + self.queue = Queue() #: job queue + self.active = False + + self.start() + + #-------------------------------------------------------------------------- + def run(self): + """run method""" + pyfile = None + + while True: + del pyfile + self.active = self.queue.get() + pyfile = self.active + + if self.active == "quit": + self.active = False + self.m.threads.remove(self) + return True + + try: + if not pyfile.hasPlugin(): + continue + #this pyfile was deleted while queueing + + pyfile.plugin.checkForSameFiles(starting=True) + self.m.log.info(_("Download starts: %s" % pyfile.name)) + + # start download + self.m.core.addonManager.downloadPreparing(pyfile) + pyfile.error = "" + pyfile.plugin.preprocessing(self) + + self.m.log.info(_("Download finished: %s") % pyfile.name) + self.m.core.addonManager.downloadFinished(pyfile) + self.m.core.files.checkPackageFinished(pyfile) + + except NotImplementedError: + self.m.log.error(_("Plugin %s is missing a function.") % pyfile.pluginname) + pyfile.setStatus("failed") + pyfile.error = "Plugin does not work" + self.clean(pyfile) + continue + + except Abort: + try: + self.m.log.info(_("Download aborted: %s") % pyfile.name) + except Exception: + pass + + pyfile.setStatus("aborted") + + if self.m.core.debug: + print_exc() + + self.clean(pyfile) + continue + + except Reconnect: + self.queue.put(pyfile) + #pyfile.req.clearCookies() + + while self.m.reconnecting.isSet(): + sleep(0.5) + + continue + + except Retry, e: + reason = e.args[0] + self.m.log.info(_("Download restarted: %(name)s | %(msg)s") % {"name": pyfile.name, "msg": reason}) + self.queue.put(pyfile) + continue + + except Fail, e: + msg = e.args[0] + + if msg == "offline": + pyfile.setStatus("offline") + self.m.log.warning(_("Download is offline: %s") % pyfile.name) + elif msg == "temp. offline": + pyfile.setStatus("temp. offline") + self.m.log.warning(_("Download is temporary offline: %s") % pyfile.name) + else: + pyfile.setStatus("failed") + self.m.log.warning(_("Download failed: %(name)s | %(msg)s") % {"name": pyfile.name, "msg": msg}) + pyfile.error = msg + + if self.m.core.debug: + print_exc() + + self.m.core.addonManager.downloadFailed(pyfile) + self.clean(pyfile) + continue + + except error, e: + if len(e.args) == 2: + code, msg = e.args + else: + code = 0 + msg = e.args + + self.m.log.debug("pycurl exception %s: %s" % (code, msg)) + + if code in (7, 18, 28, 52, 56): + self.m.log.warning(_("Couldn't connect to host or connection reset, waiting 1 minute and retry.")) + wait = time() + 60 + + pyfile.waitUntil = wait + pyfile.setStatus("waiting") + while time() < wait: + sleep(1) + if pyfile.abort: + break + + if pyfile.abort: + self.m.log.info(_("Download aborted: %s") % pyfile.name) + pyfile.setStatus("aborted") + + self.clean(pyfile) + else: + self.queue.put(pyfile) + + continue + + else: + pyfile.setStatus("failed") + self.m.log.error("pycurl error %s: %s" % (code, msg)) + if self.m.core.debug: + print_exc() + self.writeDebugReport(pyfile) + + self.m.core.addonManager.downloadFailed(pyfile) + + self.clean(pyfile) + continue + + except SkipDownload, e: + pyfile.setStatus("skipped") + + self.m.log.info( + _("Download skipped: %(name)s due to %(plugin)s") % {"name": pyfile.name, "plugin": e.message}) + + self.clean(pyfile) + + self.m.core.files.checkPackageFinished(pyfile) + + self.active = False + self.m.core.files.save() + + continue + + + except Exception, e: + pyfile.setStatus("failed") + self.m.log.warning(_("Download failed: %(name)s | %(msg)s") % {"name": pyfile.name, "msg": str(e)}) + pyfile.error = str(e) + + if self.m.core.debug: + print_exc() + self.writeDebugReport(pyfile) + + self.m.core.addonManager.downloadFailed(pyfile) + self.clean(pyfile) + continue + + finally: + self.m.core.files.save() + pyfile.checkIfProcessed() + exc_clear() + + #pyfile.plugin.req.clean() + + self.active = False + pyfile.finishIfDone() + self.m.core.files.save() + + + def put(self, job): + """assing job to thread""" + self.queue.put(job) + + + def stop(self): + """stops the thread""" + self.put("quit") diff --git a/pyload/manager/thread/DownloadThread.py b/pyload/manager/thread/DownloadThread.py deleted file mode 100644 index d876000da..000000000 --- a/pyload/manager/thread/DownloadThread.py +++ /dev/null @@ -1,213 +0,0 @@ -# -*- coding: utf-8 -*- -# @author: RaNaN - -from Queue import Queue -from threading import Thread -from os import listdir, stat -from os.path import join -from time import sleep, time, strftime, gmtime -from traceback import print_exc, format_exc -from pprint import pformat -from sys import exc_info, exc_clear -from copy import copy -from types import MethodType - -from pycurl import error - -from pyload.manager.thread.PluginThread import PluginThread -from pyload.plugins.Plugin import Abort, Fail, Reconnect, Retry, SkipDownload - - -class DownloadThread(PluginThread): - """thread for downloading files from 'real' hoster plugins""" - - #-------------------------------------------------------------------------- - def __init__(self, manager): - """Constructor""" - PluginThread.__init__(self, manager) - - self.queue = Queue() #: job queue - self.active = False - - self.start() - - #-------------------------------------------------------------------------- - def run(self): - """run method""" - pyfile = None - - while True: - del pyfile - self.active = self.queue.get() - pyfile = self.active - - if self.active == "quit": - self.active = False - self.m.threads.remove(self) - return True - - try: - if not pyfile.hasPlugin(): - continue - #this pyfile was deleted while queueing - - pyfile.plugin.checkForSameFiles(starting=True) - self.m.log.info(_("Download starts: %s" % pyfile.name)) - - # start download - self.m.core.addonManager.downloadPreparing(pyfile) - pyfile.error = "" - pyfile.plugin.preprocessing(self) - - self.m.log.info(_("Download finished: %s") % pyfile.name) - self.m.core.addonManager.downloadFinished(pyfile) - self.m.core.files.checkPackageFinished(pyfile) - - except NotImplementedError: - self.m.log.error(_("Plugin %s is missing a function.") % pyfile.pluginname) - pyfile.setStatus("failed") - pyfile.error = "Plugin does not work" - self.clean(pyfile) - continue - - except Abort: - try: - self.m.log.info(_("Download aborted: %s") % pyfile.name) - except Exception: - pass - - pyfile.setStatus("aborted") - - if self.m.core.debug: - print_exc() - - self.clean(pyfile) - continue - - except Reconnect: - self.queue.put(pyfile) - #pyfile.req.clearCookies() - - while self.m.reconnecting.isSet(): - sleep(0.5) - - continue - - except Retry, e: - reason = e.args[0] - self.m.log.info(_("Download restarted: %(name)s | %(msg)s") % {"name": pyfile.name, "msg": reason}) - self.queue.put(pyfile) - continue - - except Fail, e: - msg = e.args[0] - - if msg == "offline": - pyfile.setStatus("offline") - self.m.log.warning(_("Download is offline: %s") % pyfile.name) - elif msg == "temp. offline": - pyfile.setStatus("temp. offline") - self.m.log.warning(_("Download is temporary offline: %s") % pyfile.name) - else: - pyfile.setStatus("failed") - self.m.log.warning(_("Download failed: %(name)s | %(msg)s") % {"name": pyfile.name, "msg": msg}) - pyfile.error = msg - - if self.m.core.debug: - print_exc() - - self.m.core.addonManager.downloadFailed(pyfile) - self.clean(pyfile) - continue - - except error, e: - if len(e.args) == 2: - code, msg = e.args - else: - code = 0 - msg = e.args - - self.m.log.debug("pycurl exception %s: %s" % (code, msg)) - - if code in (7, 18, 28, 52, 56): - self.m.log.warning(_("Couldn't connect to host or connection reset, waiting 1 minute and retry.")) - wait = time() + 60 - - pyfile.waitUntil = wait - pyfile.setStatus("waiting") - while time() < wait: - sleep(1) - if pyfile.abort: - break - - if pyfile.abort: - self.m.log.info(_("Download aborted: %s") % pyfile.name) - pyfile.setStatus("aborted") - - self.clean(pyfile) - else: - self.queue.put(pyfile) - - continue - - else: - pyfile.setStatus("failed") - self.m.log.error("pycurl error %s: %s" % (code, msg)) - if self.m.core.debug: - print_exc() - self.writeDebugReport(pyfile) - - self.m.core.addonManager.downloadFailed(pyfile) - - self.clean(pyfile) - continue - - except SkipDownload, e: - pyfile.setStatus("skipped") - - self.m.log.info( - _("Download skipped: %(name)s due to %(plugin)s") % {"name": pyfile.name, "plugin": e.message}) - - self.clean(pyfile) - - self.m.core.files.checkPackageFinished(pyfile) - - self.active = False - self.m.core.files.save() - - continue - - - except Exception, e: - pyfile.setStatus("failed") - self.m.log.warning(_("Download failed: %(name)s | %(msg)s") % {"name": pyfile.name, "msg": str(e)}) - pyfile.error = str(e) - - if self.m.core.debug: - print_exc() - self.writeDebugReport(pyfile) - - self.m.core.addonManager.downloadFailed(pyfile) - self.clean(pyfile) - continue - - finally: - self.m.core.files.save() - pyfile.checkIfProcessed() - exc_clear() - - #pyfile.plugin.req.clean() - - self.active = False - pyfile.finishIfDone() - self.m.core.files.save() - - - def put(self, job): - """assing job to thread""" - self.queue.put(job) - - - def stop(self): - """stops the thread""" - self.put("quit") diff --git a/pyload/manager/thread/Info.py b/pyload/manager/thread/Info.py new file mode 100644 index 000000000..4526a07ed --- /dev/null +++ b/pyload/manager/thread/Info.py @@ -0,0 +1,225 @@ +# -*- coding: utf-8 -*- +# @author: RaNaN + +from Queue import Queue +from threading import Thread +from os import listdir, stat +from os.path import join +from time import sleep, time, strftime, gmtime +from traceback import print_exc, format_exc +from pprint import pformat +from sys import exc_info, exc_clear +from copy import copy +from types import MethodType + +from pycurl import error + +from pyload.datatype.File import PyFile +from pyload.manager.thread.Plugin import PluginThread +from pyload.api import OnlineStatus + + +class InfoThread(PluginThread): + + def __init__(self, manager, data, pid=-1, rid=-1, add=False): + """Constructor""" + PluginThread.__init__(self, manager) + + self.data = data + self.pid = pid # package id + # [ .. (name, plugin) .. ] + + self.rid = rid #result id + self.add = add #add packages instead of return result + + self.cache = [] #accumulated data + + self.start() + + def run(self): + """run method""" + + plugins = {} + container = [] + + for url, plugintype, pluginname in data: + try: + plugins[plugintype][pluginname].append(url) + except Exception: + plugins[plugintype][pluginname] = [url] + + # filter out container plugins + for name in self.m.core.pluginManager.containerPlugins: + if name in plugins: + container.extend([(name, url) for url in plugins[name]]) + + del plugins[name] + + #directly write to database + if self.pid > -1: + for plugintype, pluginname, urls in plugins.iteritems(): + plugin = self.m.core.pluginManager.getPlugin(plugintype, pluginname, True) + if hasattr(plugin, "getInfo"): + self.fetchForPlugin(pluginname, plugin, urls, self.updateDB) + self.m.core.files.save() + + elif self.add: + for plugintype, pluginname, urls in plugins.iteritems(): + plugin = self.m.core.pluginManager.getPlugin(plugintype, pluginname, True) + if hasattr(plugin, "getInfo"): + self.fetchForPlugin(pluginname, plugin, urls, self.updateCache, True) + + else: + #generate default result + result = [(url, 0, 3, url) for url in urls] + + self.updateCache(pluginname, result) + + packs = parseNames([(name, url) for name, x, y, url in self.cache]) + + self.m.log.debug("Fetched and generated %d packages" % len(packs)) + + for k, v in packs: + self.m.core.api.addPackage(k, v) + + #empty cache + del self.cache[:] + + else: #post the results + + + for name, url in container: + #attach container content + try: + data = self.decryptContainer(name, url) + except Exception: + print_exc() + self.m.log.error("Could not decrypt container.") + data = [] + + for url, plugintype, pluginname in data: + try: + plugins[plugintype][pluginname].append(url) + except Exception: + plugins[plugintype][pluginname] = [url] + + self.m.infoResults[self.rid] = {} + + for plugintype, pluginname, urls in plugins.iteritems(): + plugin = self.m.core.pluginManager.getPlugin(plugintype, pluginname, True) + if hasattr(plugin, "getInfo"): + self.fetchForPlugin(pluginname, plugin, urls, self.updateResult, True) + + #force to process cache + if self.cache: + self.updateResult(pluginname, [], True) + + else: + #generate default result + result = [(url, 0, 3, url) for url in urls] + + self.updateResult(pluginname, result, True) + + self.m.infoResults[self.rid]["ALL_INFO_FETCHED"] = {} + + self.m.timestamp = time() + 5 * 60 + + + def updateDB(self, plugin, result): + self.m.core.files.updateFileInfo(result, self.pid) + + def updateResult(self, plugin, result, force=False): + #parse package name and generate result + #accumulate results + + self.cache.extend(result) + + if len(self.cache) >= 20 or force: + #used for package generating + tmp = [(name, (url, OnlineStatus(name, plugin, "unknown", status, int(size)))) + for name, size, status, url in self.cache] + + data = parseNames(tmp) + result = {} + for k, v in data.iteritems(): + for url, status in v: + status.packagename = k + result[url] = status + + self.m.setInfoResults(self.rid, result) + + self.cache = [] + + def updateCache(self, plugin, result): + self.cache.extend(result) + + def fetchForPlugin(self, pluginname, plugin, urls, cb, err=None): + try: + result = [] #result loaded from cache + process = [] #urls to process + for url in urls: + if url in self.m.infoCache: + result.append(self.m.infoCache[url]) + else: + process.append(url) + + if result: + self.m.log.debug("Fetched %d values from cache for %s" % (len(result), pluginname)) + cb(pluginname, result) + + if process: + self.m.log.debug("Run Info Fetching for %s" % pluginname) + for result in plugin.getInfo(process): + #result = [ .. (name, size, status, url) .. ] + if not type(result) == list: + result = [result] + + for res in result: + self.m.infoCache[res[3]] = res #: why don't assign res dict directly? + + cb(pluginname, result) + + self.m.log.debug("Finished Info Fetching for %s" % pluginname) + except Exception, e: + self.m.log.warning(_("Info Fetching for %(name)s failed | %(err)s") % + {"name": pluginname, "err": str(e)}) + if self.m.core.debug: + print_exc() + + # generate default results + if err: + result = [(url, 0, 3, url) for url in urls] + cb(pluginname, result) + + + def decryptContainer(self, plugin, url): + data = [] + # only works on container plugins + + self.m.log.debug("Pre decrypting %s with %s" % (url, plugin)) + + # dummy pyfile + pyfile = PyFile(self.m.core.files, -1, url, url, 0, 0, "", plugin, -1, -1) + + pyfile.initPlugin() + + # little plugin lifecycle + try: + pyfile.plugin.setup() + pyfile.plugin.loadToDisk() + pyfile.plugin.decrypt(pyfile) + pyfile.plugin.deleteTmp() + + for pack in pyfile.plugin.packages: + pyfile.plugin.urls.extend(pack[1]) + + data = self.m.core.pluginManager.parseUrls(pyfile.plugin.urls) + + self.m.log.debug("Got %d links." % len(data)) + + except Exception, e: + self.m.log.debug("Pre decrypting error: %s" % str(e)) + finally: + pyfile.release() + + return data diff --git a/pyload/manager/thread/InfoThread.py b/pyload/manager/thread/InfoThread.py deleted file mode 100644 index 99bf97fc8..000000000 --- a/pyload/manager/thread/InfoThread.py +++ /dev/null @@ -1,225 +0,0 @@ -# -*- coding: utf-8 -*- -# @author: RaNaN - -from Queue import Queue -from threading import Thread -from os import listdir, stat -from os.path import join -from time import sleep, time, strftime, gmtime -from traceback import print_exc, format_exc -from pprint import pformat -from sys import exc_info, exc_clear -from copy import copy -from types import MethodType - -from pycurl import error - -from pyload.datatype.PyFile import PyFile -from pyload.manager.thread.PluginThread import PluginThread -from pyload.api import OnlineStatus - - -class InfoThread(PluginThread): - - def __init__(self, manager, data, pid=-1, rid=-1, add=False): - """Constructor""" - PluginThread.__init__(self, manager) - - self.data = data - self.pid = pid # package id - # [ .. (name, plugin) .. ] - - self.rid = rid #result id - self.add = add #add packages instead of return result - - self.cache = [] #accumulated data - - self.start() - - def run(self): - """run method""" - - plugins = {} - container = [] - - for url, plugintype, pluginname in data: - try: - plugins[plugintype][pluginname].append(url) - except Exception: - plugins[plugintype][pluginname] = [url] - - # filter out container plugins - for name in self.m.core.pluginManager.containerPlugins: - if name in plugins: - container.extend([(name, url) for url in plugins[name]]) - - del plugins[name] - - #directly write to database - if self.pid > -1: - for plugintype, pluginname, urls in plugins.iteritems(): - plugin = self.m.core.pluginManager.getPlugin(plugintype, pluginname, True) - if hasattr(plugin, "getInfo"): - self.fetchForPlugin(pluginname, plugin, urls, self.updateDB) - self.m.core.files.save() - - elif self.add: - for plugintype, pluginname, urls in plugins.iteritems(): - plugin = self.m.core.pluginManager.getPlugin(plugintype, pluginname, True) - if hasattr(plugin, "getInfo"): - self.fetchForPlugin(pluginname, plugin, urls, self.updateCache, True) - - else: - #generate default result - result = [(url, 0, 3, url) for url in urls] - - self.updateCache(pluginname, result) - - packs = parseNames([(name, url) for name, x, y, url in self.cache]) - - self.m.log.debug("Fetched and generated %d packages" % len(packs)) - - for k, v in packs: - self.m.core.api.addPackage(k, v) - - #empty cache - del self.cache[:] - - else: #post the results - - - for name, url in container: - #attach container content - try: - data = self.decryptContainer(name, url) - except Exception: - print_exc() - self.m.log.error("Could not decrypt container.") - data = [] - - for url, plugintype, pluginname in data: - try: - plugins[plugintype][pluginname].append(url) - except Exception: - plugins[plugintype][pluginname] = [url] - - self.m.infoResults[self.rid] = {} - - for plugintype, pluginname, urls in plugins.iteritems(): - plugin = self.m.core.pluginManager.getPlugin(plugintype, pluginname, True) - if hasattr(plugin, "getInfo"): - self.fetchForPlugin(pluginname, plugin, urls, self.updateResult, True) - - #force to process cache - if self.cache: - self.updateResult(pluginname, [], True) - - else: - #generate default result - result = [(url, 0, 3, url) for url in urls] - - self.updateResult(pluginname, result, True) - - self.m.infoResults[self.rid]["ALL_INFO_FETCHED"] = {} - - self.m.timestamp = time() + 5 * 60 - - - def updateDB(self, plugin, result): - self.m.core.files.updateFileInfo(result, self.pid) - - def updateResult(self, plugin, result, force=False): - #parse package name and generate result - #accumulate results - - self.cache.extend(result) - - if len(self.cache) >= 20 or force: - #used for package generating - tmp = [(name, (url, OnlineStatus(name, plugin, "unknown", status, int(size)))) - for name, size, status, url in self.cache] - - data = parseNames(tmp) - result = {} - for k, v in data.iteritems(): - for url, status in v: - status.packagename = k - result[url] = status - - self.m.setInfoResults(self.rid, result) - - self.cache = [] - - def updateCache(self, plugin, result): - self.cache.extend(result) - - def fetchForPlugin(self, pluginname, plugin, urls, cb, err=None): - try: - result = [] #result loaded from cache - process = [] #urls to process - for url in urls: - if url in self.m.infoCache: - result.append(self.m.infoCache[url]) - else: - process.append(url) - - if result: - self.m.log.debug("Fetched %d values from cache for %s" % (len(result), pluginname)) - cb(pluginname, result) - - if process: - self.m.log.debug("Run Info Fetching for %s" % pluginname) - for result in plugin.getInfo(process): - #result = [ .. (name, size, status, url) .. ] - if not type(result) == list: - result = [result] - - for res in result: - self.m.infoCache[res[3]] = res #: why don't assign res dict directly? - - cb(pluginname, result) - - self.m.log.debug("Finished Info Fetching for %s" % pluginname) - except Exception, e: - self.m.log.warning(_("Info Fetching for %(name)s failed | %(err)s") % - {"name": pluginname, "err": str(e)}) - if self.m.core.debug: - print_exc() - - # generate default results - if err: - result = [(url, 0, 3, url) for url in urls] - cb(pluginname, result) - - - def decryptContainer(self, plugin, url): - data = [] - # only works on container plugins - - self.m.log.debug("Pre decrypting %s with %s" % (url, plugin)) - - # dummy pyfile - pyfile = PyFile(self.m.core.files, -1, url, url, 0, 0, "", plugin, -1, -1) - - pyfile.initPlugin() - - # little plugin lifecycle - try: - pyfile.plugin.setup() - pyfile.plugin.loadToDisk() - pyfile.plugin.decrypt(pyfile) - pyfile.plugin.deleteTmp() - - for pack in pyfile.plugin.packages: - pyfile.plugin.urls.extend(pack[1]) - - data = self.m.core.pluginManager.parseUrls(pyfile.plugin.urls) - - self.m.log.debug("Got %d links." % len(data)) - - except Exception, e: - self.m.log.debug("Pre decrypting error: %s" % str(e)) - finally: - pyfile.release() - - return data diff --git a/pyload/manager/thread/Plugin.py b/pyload/manager/thread/Plugin.py new file mode 100644 index 000000000..70ee747a8 --- /dev/null +++ b/pyload/manager/thread/Plugin.py @@ -0,0 +1,130 @@ +# -*- coding: utf-8 -*- +# @author: RaNaN + +from Queue import Queue +from threading import Thread +from os import listdir, stat +from os.path import join +from time import sleep, time, strftime, gmtime +from traceback import print_exc, format_exc +from pprint import pformat +from sys import exc_info, exc_clear +from copy import copy +from types import MethodType + +from pycurl import error + +from pyload.datatype.File import PyFile +from pyload.plugin.Plugin import Abort, Fail, Reconnect, Retry, SkipDownload +from pyload.utils.packagetools import parseNames +from pyload.utils import safe_join +from pyload.api import OnlineStatus + +class PluginThread(Thread): + """abstract base class for thread types""" + + #-------------------------------------------------------------------------- + def __init__(self, manager): + """Constructor""" + Thread.__init__(self) + self.setDaemon(True) + self.m = manager #thread manager + + + def writeDebugReport(self, pyfile): + """ writes a + :return: + """ + + dump_name = "debug_%s_%s.zip" % (pyfile.pluginname, strftime("%d-%m-%Y_%H-%M-%S")) + dump = self.getDebugDump(pyfile) + + try: + import zipfile + + zip = zipfile.ZipFile(dump_name, "w") + + for f in listdir(join("tmp", pyfile.pluginname)): + try: + # avoid encoding errors + zip.write(join("tmp", pyfile.pluginname, f), safe_join(pyfile.pluginname, f)) + except Exception: + pass + + info = zipfile.ZipInfo(safe_join(pyfile.pluginname, "debug_Report.txt"), gmtime()) + info.external_attr = 0644 << 16L # change permissions + + zip.writestr(info, dump) + zip.close() + + if not stat(dump_name).st_size: + raise Exception("Empty Zipfile") + + except Exception, e: + self.m.log.debug("Error creating zip file: %s" % e) + + dump_name = dump_name.replace(".zip", ".txt") + f = open(dump_name, "wb") + f.write(dump) + f.close() + + self.m.core.log.info("Debug Report written to %s" % dump_name) + + def getDebugDump(self, pyfile): + dump = "pyLoad %s Debug Report of %s %s \n\nTRACEBACK:\n %s \n\nFRAMESTACK:\n" % ( + self.m.core.api.getServerVersion(), pyfile.pluginname, pyfile.plugin.__version, format_exc()) + + tb = exc_info()[2] + stack = [] + while tb: + stack.append(tb.tb_frame) + tb = tb.tb_next + + for frame in stack[1:]: + dump += "\nFrame %s in %s at line %s\n" % (frame.f_code.co_name, + frame.f_code.co_filename, + frame.f_lineno) + + for key, value in frame.f_locals.items(): + dump += "\t%20s = " % key + try: + dump += pformat(value) + "\n" + except Exception, e: + dump += " " + str(e) + "\n" + + del frame + + del stack #delete it just to be sure... + + dump += "\n\nPLUGIN OBJECT DUMP: \n\n" + + for name in dir(pyfile.plugin): + attr = getattr(pyfile.plugin, name) + if not name.endswith("__") and type(attr) != MethodType: + dump += "\t%20s = " % name + try: + dump += pformat(attr) + "\n" + except Exception, e: + dump += " " + str(e) + "\n" + + dump += "\nPYFILE OBJECT DUMP: \n\n" + + for name in dir(pyfile): + attr = getattr(pyfile, name) + if not name.endswith("__") and type(attr) != MethodType: + dump += "\t%20s = " % name + try: + dump += pformat(attr) + "\n" + except Exception, e: + dump += " " + str(e) + "\n" + + if pyfile.pluginname in self.m.core.config.plugin: + dump += "\n\nCONFIG: \n\n" + dump += pformat(self.m.core.config.plugin[pyfile.pluginname]) + "\n" + + return dump + + def clean(self, pyfile): + """ set thread unactive and release pyfile """ + self.active = False + pyfile.release() diff --git a/pyload/manager/thread/PluginThread.py b/pyload/manager/thread/PluginThread.py deleted file mode 100644 index 3cdae122f..000000000 --- a/pyload/manager/thread/PluginThread.py +++ /dev/null @@ -1,130 +0,0 @@ -# -*- coding: utf-8 -*- -# @author: RaNaN - -from Queue import Queue -from threading import Thread -from os import listdir, stat -from os.path import join -from time import sleep, time, strftime, gmtime -from traceback import print_exc, format_exc -from pprint import pformat -from sys import exc_info, exc_clear -from copy import copy -from types import MethodType - -from pycurl import error - -from pyload.datatype.PyFile import PyFile -from pyload.plugins.Plugin import Abort, Fail, Reconnect, Retry, SkipDownload -from pyload.utils.packagetools import parseNames -from pyload.utils import safe_join -from pyload.api import OnlineStatus - -class PluginThread(Thread): - """abstract base class for thread types""" - - #-------------------------------------------------------------------------- - def __init__(self, manager): - """Constructor""" - Thread.__init__(self) - self.setDaemon(True) - self.m = manager #thread manager - - - def writeDebugReport(self, pyfile): - """ writes a - :return: - """ - - dump_name = "debug_%s_%s.zip" % (pyfile.pluginname, strftime("%d-%m-%Y_%H-%M-%S")) - dump = self.getDebugDump(pyfile) - - try: - import zipfile - - zip = zipfile.ZipFile(dump_name, "w") - - for f in listdir(join("tmp", pyfile.pluginname)): - try: - # avoid encoding errors - zip.write(join("tmp", pyfile.pluginname, f), safe_join(pyfile.pluginname, f)) - except Exception: - pass - - info = zipfile.ZipInfo(safe_join(pyfile.pluginname, "debug_Report.txt"), gmtime()) - info.external_attr = 0644 << 16L # change permissions - - zip.writestr(info, dump) - zip.close() - - if not stat(dump_name).st_size: - raise Exception("Empty Zipfile") - - except Exception, e: - self.m.log.debug("Error creating zip file: %s" % e) - - dump_name = dump_name.replace(".zip", ".txt") - f = open(dump_name, "wb") - f.write(dump) - f.close() - - self.m.core.log.info("Debug Report written to %s" % dump_name) - - def getDebugDump(self, pyfile): - dump = "pyLoad %s Debug Report of %s %s \n\nTRACEBACK:\n %s \n\nFRAMESTACK:\n" % ( - self.m.core.api.getServerVersion(), pyfile.pluginname, pyfile.plugin.__version, format_exc()) - - tb = exc_info()[2] - stack = [] - while tb: - stack.append(tb.tb_frame) - tb = tb.tb_next - - for frame in stack[1:]: - dump += "\nFrame %s in %s at line %s\n" % (frame.f_code.co_name, - frame.f_code.co_filename, - frame.f_lineno) - - for key, value in frame.f_locals.items(): - dump += "\t%20s = " % key - try: - dump += pformat(value) + "\n" - except Exception, e: - dump += " " + str(e) + "\n" - - del frame - - del stack #delete it just to be sure... - - dump += "\n\nPLUGIN OBJECT DUMP: \n\n" - - for name in dir(pyfile.plugin): - attr = getattr(pyfile.plugin, name) - if not name.endswith("__") and type(attr) != MethodType: - dump += "\t%20s = " % name - try: - dump += pformat(attr) + "\n" - except Exception, e: - dump += " " + str(e) + "\n" - - dump += "\nPYFILE OBJECT DUMP: \n\n" - - for name in dir(pyfile): - attr = getattr(pyfile, name) - if not name.endswith("__") and type(attr) != MethodType: - dump += "\t%20s = " % name - try: - dump += pformat(attr) + "\n" - except Exception, e: - dump += " " + str(e) + "\n" - - if pyfile.pluginname in self.m.core.config.plugin: - dump += "\n\nCONFIG: \n\n" - dump += pformat(self.m.core.config.plugin[pyfile.pluginname]) + "\n" - - return dump - - def clean(self, pyfile): - """ set thread unactive and release pyfile """ - self.active = False - pyfile.release() diff --git a/pyload/manager/thread/Server.py b/pyload/manager/thread/Server.py new file mode 100644 index 000000000..f3f174e74 --- /dev/null +++ b/pyload/manager/thread/Server.py @@ -0,0 +1,111 @@ +# -*- coding: utf-8 -*- + +from __future__ import with_statement + +from os.path import exists + +import os +import threading +import logging + +core = None +setup = None +log = logging.getLogger("log") + +class WebServer(threading.Thread): + def __init__(self, pycore): + global core + threading.Thread.__init__(self) + self.core = pycore + core = pycore + self.running = True + self.server = pycore.config['webinterface']['server'] + self.https = pycore.config['webinterface']['https'] + self.cert = pycore.config["ssl"]["cert"] + self.key = pycore.config["ssl"]["key"] + self.host = pycore.config['webinterface']['host'] + self.port = pycore.config['webinterface']['port'] + + self.setDaemon(True) + + def run(self): + import pyload.webui as webinterface + global webinterface + + reset = False + + if self.https and (not exists(self.cert) or not exists(self.key)): + log.warning(_("SSL certificates not found.")) + self.https = False + + if self.server in ("lighttpd", "nginx"): + log.warning(_("Sorry, we dropped support for starting %s directly within pyLoad") % self.server) + log.warning(_("You can use the threaded server which offers good performance and ssl,")) + log.warning(_("of course you can still use your existing %s with pyLoads fastcgi server") % self.server) + log.warning(_("sample configs are located in the pyload/web/servers directory")) + reset = True + elif self.server == "fastcgi": + try: + import flup + except Exception: + log.warning(_("Can't use %(server)s, python-flup is not installed!") % { + "server": self.server}) + reset = True + + if reset or self.server == "lightweight": + if os.name != "nt": + try: + import bjoern + except Exception, e: + log.error(_("Error importing lightweight server: %s") % e) + log.warning(_("You need to download and compile bjoern, https://github.com/jonashaag/bjoern")) + log.warning(_("Copy the boern.so to the lib folder or use setup.py install")) + log.warning(_("Of course you need to be familiar with linux and know how to compile software")) + self.server = "builtin" + else: + self.core.log.info(_("Server set to threaded, due to known performance problems on windows.")) + self.core.config['webinterface']['server'] = "threaded" + self.server = "threaded" + + if self.server == "threaded": + self.start_threaded() + elif self.server == "fastcgi": + self.start_fcgi() + elif self.server == "lightweight": + self.start_lightweight() + else: + self.start_builtin() + + def start_builtin(self): + + if self.https: + log.warning(_("This server offers no SSL, please consider using threaded instead")) + + self.core.log.info(_("Starting builtin webserver: %(host)s:%(port)d") % {"host": self.host, "port": self.port}) + webinterface.run_simple(host=self.host, port=self.port) + + def start_threaded(self): + if self.https: + self.core.log.info(_("Starting threaded SSL webserver: %(host)s:%(port)d") % {"host": self.host, "port": self.port}) + else: + self.cert = "" + self.key = "" + self.core.log.info(_("Starting threaded webserver: %(host)s:%(port)d") % {"host": self.host, "port": self.port}) + + webinterface.run_threaded(host=self.host, port=self.port, cert=self.cert, key=self.key) + + def start_fcgi(self): + + self.core.log.info(_("Starting fastcgi server: %(host)s:%(port)d") % {"host": self.host, "port": self.port}) + webinterface.run_fcgi(host=self.host, port=self.port) + + + def start_lightweight(self): + if self.https: + log.warning(_("This server offers no SSL, please consider using threaded instead")) + + self.core.log.info(_("Starting lightweight webserver (bjoern): %(host)s:%(port)d") % {"host": self.host, "port": self.port}) + webinterface.run_lightweight(host=self.host, port=self.port) + + def quit(self): + self.running = False diff --git a/pyload/manager/thread/ServerThread.py b/pyload/manager/thread/ServerThread.py deleted file mode 100644 index a8b95cd56..000000000 --- a/pyload/manager/thread/ServerThread.py +++ /dev/null @@ -1,111 +0,0 @@ -# -*- coding: utf-8 -*- - -from __future__ import with_statement - -from os.path import exists - -import os -import threading -import logging - -core = None -setup = None -log = logging.getLogger("log") - -class WebServer(threading.Thread): - def __init__(self, pycore): - global core - threading.Thread.__init__(self) - self.core = pycore - core = pycore - self.running = True - self.server = pycore.config['webinterface']['server'] - self.https = pycore.config['webinterface']['https'] - self.cert = pycore.config["ssl"]["cert"] - self.key = pycore.config["ssl"]["key"] - self.host = pycore.config['webinterface']['host'] - self.port = pycore.config['webinterface']['port'] - - self.setDaemon(True) - - def run(self): - import pyload.webui as webinterface - global webinterface - - reset = False - - if self.https and (not exists(self.cert) or not exists(self.key)): - log.warning(_("SSL certificates not found.")) - self.https = False - - if self.server in ("lighttpd", "nginx"): - log.warning(_("Sorry, we dropped support for starting %s directly within pyLoad") % self.server) - log.warning(_("You can use the threaded server which offers good performance and ssl,")) - log.warning(_("of course you can still use your existing %s with pyLoads fastcgi server") % self.server) - log.warning(_("sample configs are located in the pyload/web/servers directory")) - reset = True - elif self.server == "fastcgi": - try: - import flup - except Exception: - log.warning(_("Can't use %(server)s, python-flup is not installed!") % { - "server": self.server}) - reset = True - - if reset or self.server == "lightweight": - if os.name != "nt": - try: - import bjoern - except Exception, e: - log.error(_("Error importing lightweight server: %s") % e) - log.warning(_("You need to download and compile bjoern, https://github.com/jonashaag/bjoern")) - log.warning(_("Copy the boern.so to pyload/lib folder or use setup.py install")) - log.warning(_("Of course you need to be familiar with linux and know how to compile software")) - self.server = "builtin" - else: - self.core.log.info(_("Server set to threaded, due to known performance problems on windows.")) - self.core.config['webinterface']['server'] = "threaded" - self.server = "threaded" - - if self.server == "threaded": - self.start_threaded() - elif self.server == "fastcgi": - self.start_fcgi() - elif self.server == "lightweight": - self.start_lightweight() - else: - self.start_builtin() - - def start_builtin(self): - - if self.https: - log.warning(_("This server offers no SSL, please consider using threaded instead")) - - self.core.log.info(_("Starting builtin webserver: %(host)s:%(port)d") % {"host": self.host, "port": self.port}) - webinterface.run_simple(host=self.host, port=self.port) - - def start_threaded(self): - if self.https: - self.core.log.info(_("Starting threaded SSL webserver: %(host)s:%(port)d") % {"host": self.host, "port": self.port}) - else: - self.cert = "" - self.key = "" - self.core.log.info(_("Starting threaded webserver: %(host)s:%(port)d") % {"host": self.host, "port": self.port}) - - webinterface.run_threaded(host=self.host, port=self.port, cert=self.cert, key=self.key) - - def start_fcgi(self): - - self.core.log.info(_("Starting fastcgi server: %(host)s:%(port)d") % {"host": self.host, "port": self.port}) - webinterface.run_fcgi(host=self.host, port=self.port) - - - def start_lightweight(self): - if self.https: - log.warning(_("This server offers no SSL, please consider using threaded instead")) - - self.core.log.info(_("Starting lightweight webserver (bjoern): %(host)s:%(port)d") % {"host": self.host, "port": self.port}) - webinterface.run_lightweight(host=self.host, port=self.port) - - def quit(self): - self.running = False diff --git a/pyload/network/HTTPDownload.py b/pyload/network/HTTPDownload.py index 65c893ad7..3b2bf26ca 100644 --- a/pyload/network/HTTPDownload.py +++ b/pyload/network/HTTPDownload.py @@ -12,9 +12,10 @@ import pycurl from pyload.network.HTTPChunk import ChunkInfo, HTTPChunk from pyload.network.HTTPRequest import BadHeader -from pyload.plugins.Plugin import Abort +from pyload.plugin.Plugin import Abort from pyload.utils import safe_join, fs_encode + class HTTPDownload(object): """ loads a url http + ftp """ diff --git a/pyload/network/HTTPRequest.py b/pyload/network/HTTPRequest.py index 2f49fbe91..eac03a365 100644 --- a/pyload/network/HTTPRequest.py +++ b/pyload/network/HTTPRequest.py @@ -11,7 +11,7 @@ from httplib import responses from logging import getLogger from cStringIO import StringIO -from pyload.plugins.Plugin import Abort, Fail +from pyload.plugin.Plugin import Abort, Fail from pyload.utils import encode diff --git a/pyload/network/XDCCRequest.py b/pyload/network/XDCCRequest.py index 7ac8165db..c49f418c4 100644 --- a/pyload/network/XDCCRequest.py +++ b/pyload/network/XDCCRequest.py @@ -12,7 +12,7 @@ from time import time import struct from select import select -from pyload.plugins.Plugin import Abort +from pyload.plugin.Plugin import Abort class XDCCRequest(object): diff --git a/pyload/plugin/Account.py b/pyload/plugin/Account.py new file mode 100644 index 000000000..b14615d3a --- /dev/null +++ b/pyload/plugin/Account.py @@ -0,0 +1,307 @@ +# -*- coding: utf-8 -*- + +from random import choice +from time import time +from traceback import print_exc +from threading import RLock + +from pyload.plugin.Plugin import Base +from pyload.utils import compare_time, parseFileSize, lock + + +class WrongPassword(Exception): + pass + + +class Account(Base): + """ + Base class for every Account plugin. + Just overwrite `login` and cookies will be stored and account becomes accessible in\ + associated hoster plugin. Plugin should also provide `loadAccountInfo` + """ + __name = "Account" + __type = "account" + __version = "0.03" + + __description = """Base account plugin""" + __license = "GPLv3" + __authors = [("mkaay", "mkaay@mkaay.de")] + + + #: after that time (in minutes) pyload will relogin the account + login_timeout = 10 * 60 + #: after that time (in minutes) account data will be reloaded + info_threshold = 10 * 60 + + + def __init__(self, manager, accounts): + Base.__init__(self, manager.core) + + self.manager = manager + self.accounts = {} + self.infos = {} #: cache for account information + self.lock = RLock() + self.timestamps = {} + + self.init() + + self.setAccounts(accounts) + + + def init(self): + pass + + + def login(self, user, data, req): + """login into account, the cookies will be saved so user can be recognized + + :param user: loginname + :param data: data dictionary + :param req: `Request` instance + """ + pass + + + @lock + def _login(self, user, data): + # set timestamp for login + self.timestamps[user] = time() + + req = self.getAccountRequest(user) + try: + self.login(user, data, req) + except WrongPassword: + self.logWarning( + _("Could not login with account %(user)s | %(msg)s") % {"user": user, + "msg": _("Wrong Password")}) + success = data['valid'] = False + except Exception, e: + self.logWarning( + _("Could not login with account %(user)s | %(msg)s") % {"user": user, + "msg": e}) + success = data['valid'] = False + if self.core.debug: + print_exc() + else: + success = True + finally: + if req: + req.close() + return success + + + def relogin(self, user): + req = self.getAccountRequest(user) + if req: + req.cj.clear() + req.close() + if user in self.infos: + del self.infos[user] #delete old information + + return self._login(user, self.accounts[user]) + + + def setAccounts(self, accounts): + self.accounts = accounts + for user, data in self.accounts.iteritems(): + self._login(user, data) + self.infos[user] = {} + + + def updateAccounts(self, user, password=None, options={}): + """ updates account and return true if anything changed """ + + if user in self.accounts: + self.accounts[user]['valid'] = True #do not remove or accounts will not login + if password: + self.accounts[user]['password'] = password + self.relogin(user) + return True + if options: + before = self.accounts[user]['options'] + self.accounts[user]['options'].update(options) + return self.accounts[user]['options'] != before + else: + self.accounts[user] = {"password": password, "options": options, "valid": True} + self._login(user, self.accounts[user]) + return True + + + def removeAccount(self, user): + if user in self.accounts: + del self.accounts[user] + if user in self.infos: + del self.infos[user] + if user in self.timestamps: + del self.timestamps[user] + + + @lock + def getAccountInfo(self, name, force=False): + """retrieve account infos for an user, do **not** overwrite this method!\\ + just use it to retrieve infos in hoster plugins. see `loadAccountInfo` + + :param name: username + :param force: reloads cached account information + :return: dictionary with information + """ + data = Account.loadAccountInfo(self, name) + + if force or name not in self.infos: + self.logDebug("Get Account Info for %s" % name) + req = self.getAccountRequest(name) + + try: + infos = self.loadAccountInfo(name, req) + if not type(infos) == dict: + raise Exception("Wrong return format") + except Exception, e: + infos = {"error": str(e)} + print_exc() + + if req: + req.close() + + self.logDebug("Account Info: %s" % infos) + + infos['timestamp'] = time() + self.infos[name] = infos + elif "timestamp" in self.infos[name] and self.infos[name][ + "timestamp"] + self.info_threshold * 60 < time(): + self.logDebug("Reached timeout for account data") + self.scheduleRefresh(name) + + data.update(self.infos[name]) + return data + + + def isPremium(self, user): + info = self.getAccountInfo(user) + return info['premium'] + + + def loadAccountInfo(self, name, req=None): + """this should be overwritten in account plugin,\ + and retrieving account information for user + + :param name: + :param req: `Request` instance + :return: + """ + return {"validuntil" : None, #: -1 for unlimited + "login" : name, + # "password" : self.accounts[name]['password'], #: commented due security reason + "options" : self.accounts[name]['options'], + "valid" : self.accounts[name]['valid'], + "trafficleft": None, #: in bytes, -1 for unlimited + "maxtraffic" : None, + "premium" : None, + "timestamp" : 0, #: time this info was retrieved + "type" : self.__name} + + + def getAllAccounts(self, force=False): + return [self.getAccountInfo(user, force) for user, data in self.accounts.iteritems()] + + + def getAccountRequest(self, user=None): + if not user: + user, data = self.selectAccount() + if not user: + return None + + req = self.core.requestFactory.getRequest(self.__name, user) + return req + + + def getAccountCookies(self, user=None): + if not user: + user, data = self.selectAccount() + if not user: + return None + + cj = self.core.requestFactory.getCookieJar(self.__name, user) + return cj + + + def getAccountData(self, user): + return self.accounts[user] + + + def selectAccount(self): + """ returns an valid account name and data""" + usable = [] + for user, data in self.accounts.iteritems(): + if not data['valid']: continue + + if "time" in data['options'] and data['options']['time']: + time_data = "" + try: + time_data = data['options']['time'][0] + start, end = time_data.split("-") + if not compare_time(start.split(":"), end.split(":")): + continue + except Exception: + self.logWarning(_("Your Time %s has wrong format, use: 1:22-3:44") % time_data) + + if user in self.infos: + if "validuntil" in self.infos[user]: + if self.infos[user]['validuntil'] > 0 and time() > self.infos[user]['validuntil']: + continue + if "trafficleft" in self.infos[user]: + if self.infos[user]['trafficleft'] == 0: + continue + + usable.append((user, data)) + + if not usable: return None, None + return choice(usable) + + + def canUse(self): + return False if self.selectAccount() == (None, None) else True + + + def parseTraffic(self, value, unit=None): #: return bytes + if not unit and not isinstance(value, basestring): + unit = "KB" + return parseFileSize(value, unit) + + + def wrongPassword(self): + raise WrongPassword + + + def empty(self, user): + if user in self.infos: + self.logWarning(_("Account %s has not enough traffic, checking again in 30min") % user) + + self.infos[user].update({"trafficleft": 0}) + self.scheduleRefresh(user, 30 * 60) + + + def expired(self, user): + if user in self.infos: + self.logWarning(_("Account %s is expired, checking again in 1h") % user) + + self.infos[user].update({"validuntil": time() - 1}) + self.scheduleRefresh(user, 60 * 60) + + + def scheduleRefresh(self, user, time=0, force=True): + """ add task to refresh account info to sheduler """ + self.logDebug("Scheduled Account refresh for %s in %s seconds." % (user, time)) + self.core.scheduler.addJob(time, self.getAccountInfo, [user, force]) + + + @lock + def checkLogin(self, user): + """ checks if user is still logged in """ + if user in self.timestamps: + if self.login_timeout > 0 and self.timestamps[user] + self.login_timeout * 60 < time(): + self.logDebug("Reached login timeout for %s" % user) + return self.relogin(user) + else: + return True + else: + return False diff --git a/pyload/plugin/Addon.py b/pyload/plugin/Addon.py new file mode 100644 index 000000000..bf8151027 --- /dev/null +++ b/pyload/plugin/Addon.py @@ -0,0 +1,185 @@ +# -*- coding: utf-8 -*- + +from traceback import print_exc + +from pyload.plugin.Plugin import Base +from pyload.utils import has_method + + +class Expose(object): + """ used for decoration to declare rpc services """ + + def __new__(cls, f, *args, **kwargs): + addonManager.addRPC(f.__module__, f.func_name, f.func_doc) + return f + + +def threaded(fn): + + def run(*args,**kwargs): + addonManager.startThread(fn, *args, **kwargs) + + return run + + +class Addon(Base): + """ + Base class for addon plugins. + """ + __name = "Addon" + __type = "addon" + __version = "0.03" + + __config = [] #: [("name", "type", "desc", "default")] + + __description = """Base addon/hook plugin""" + __license = "GPLv3" + __authors = [("mkaay", "mkaay@mkaay.de"), + ("RaNaN", "RaNaN@pyload.org")] + + + #: automatically register event listeners for functions, attribute will be deleted dont use it yourself + event_map = {} + + # Deprecated alternative to event_map + #: List of events the plugin can handle, name the functions exactly like eventname. + event_list = [] #@NOTE: dont make duplicate entries in event_map + + + def __init__(self, core, manager): + Base.__init__(self, core) + + #: Provide information in dict here, usable by API `getInfo` + self.info = {} + + #: Callback of periodical job task, used by AddonManager + self.cb = None + self.interval = 60 + + #: `AddonManager` + self.manager = manager + + #register events + if self.event_map: + for event, funcs in self.event_map.iteritems(): + if type(funcs) in (list, tuple): + for f in funcs: + self.manager.addEvent(event, getattr(self,f)) + else: + self.manager.addEvent(event, getattr(self,funcs)) + + #delete for various reasons + self.event_map = None + + if self.event_list: + for f in self.event_list: + self.manager.addEvent(f, getattr(self,f)) + + self.event_list = None + + self.setup() + + # self.initPeriodical() + + + def initPeriodical(self, delay=0, threaded=False): + self.cb = self.core.scheduler.addJob(delay, self._periodical, args=[threaded], threaded=threaded) + + + def _periodical(self, threaded): + if self.interval < 0: + self.cb = None + return + + try: + self.periodical() + + except Exception, e: + self.logError(_("Error executing addon: %s") % e) + if self.core.debug: + print_exc() + + self.cb = self.core.scheduler.addJob(self.interval, self._periodical, threaded=threaded) + + + def __repr__(self): + return "" % self.__name + + + def setup(self): + """ more init stuff if needed """ + pass + + + def deactivate(self): + """ called when addon was deactivated """ + if has_method(self.__class__, "unload"): + self.unload() + + def unload(self): # Deprecated, use method deactivate() instead + pass + + + def isActivated(self): + """ checks if addon is activated""" + return self.core.config.getPlugin(self.__name, "activated") + + + # Event methods - overwrite these if needed + def activate(self): + """ called when addon was activated """ + if has_method(self.__class__, "coreReady"): + self.coreReady() + + def coreReady(self): # Deprecated, use method activate() instead + pass + + + def exit(self): + """ called by core.shutdown just before pyLoad exit """ + if has_method(self.__class__, "coreExiting"): + self.coreExiting() + + def coreExiting(self): # Deprecated, use method exit() instead + pass + + + def downloadPreparing(self, pyfile): + pass + + + def downloadFinished(self, pyfile): + pass + + + def downloadFailed(self, pyfile): + pass + + + def packageFinished(self, pypack): + pass + + + def beforeReconnecting(self, ip): + pass + + + def afterReconnecting(self, ip): + pass + + + def periodical(self): + pass + + + def captchaTask(self, task): + """ new captcha task for the plugin, it MUST set the handler and timeout or will be ignored """ + pass + + + def captchaCorrect(self, task): + pass + + + def captchaInvalid(self, task): + pass diff --git a/pyload/plugin/Captcha.py b/pyload/plugin/Captcha.py new file mode 100644 index 000000000..1b3f34e33 --- /dev/null +++ b/pyload/plugin/Captcha.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- + +import re + +from pyload.plugin.Plugin import Plugin + + +class Captcha(Plugin): + __name = "Captcha" + __type = "captcha" + __version = "0.14" + + __description = """Base captcha service plugin""" + __license = "GPLv3" + __authors = [("pyLoad Team", "admin@pyload.org")] + + + KEY_PATTERN = None + + key = None #: last key detected + + + def __init__(self, plugin): + self.plugin = plugin + + + def detect_key(self, html=None): + if not html: + if hasattr(self.plugin, "html") and self.plugin.html: + html = self.plugin.html + else: + errmsg = _("%s html not found") % self.__name + self.plugin.error(errmsg) + raise TypeError(errmsg) + + m = re.search(self.KEY_PATTERN, html) + if m: + self.key = m.group("KEY") + self.plugin.logDebug("%s key: %s" % (self.__name, self.key)) + return self.key + else: + self.plugin.logDebug("%s key not found" % self.__name) + return None + + + def challenge(self, key=None): + raise NotImplementedError + + + def result(self, server, challenge): + raise NotImplementedError diff --git a/pyload/plugin/Container.py b/pyload/plugin/Container.py new file mode 100644 index 000000000..e2e0f2248 --- /dev/null +++ b/pyload/plugin/Container.py @@ -0,0 +1,66 @@ +# -*- coding: utf-8 -*- + +from __future__ import with_statement + +import re + +from os import remove +from os.path import basename, exists + +from pyload.plugin.internal.Crypter import Crypter +from pyload.utils import safe_join + + +class Container(Crypter): + __name = "Container" + __type = "container" + __version = "0.01" + + __pattern = r'^unmatchable$' + __config = [] #: [("name", "type", "desc", "default")] + + __description = """Base container decrypter plugin""" + __license = "GPLv3" + __authors = [("mkaay", "mkaay@mkaay.de")] + + + def preprocessing(self, thread): + """prepare""" + + self.setup() + self.thread = thread + + self.loadToDisk() + + self.decrypt(self.pyfile) + self.deleteTmp() + + self.createPackages() + + + def loadToDisk(self): + """loads container to disk if its stored remotely and overwrite url, + or check existent on several places at disk""" + + if self.pyfile.url.startswith("http"): + self.pyfile.name = re.findall("([^\/=]+)", self.pyfile.url)[-1] + content = self.load(self.pyfile.url) + self.pyfile.url = safe_join(self.core.config['general']['download_folder'], self.pyfile.name) + try: + with open(self.pyfile.url, "wb") as f: + f.write(content) + except IOError, e: + self.fail(str(e)) + + else: + self.pyfile.name = basename(self.pyfile.url) + if not exists(self.pyfile.url): + if exists(safe_join(pypath, self.pyfile.url)): + self.pyfile.url = safe_join(pypath, self.pyfile.url) + else: + self.fail(_("File not exists")) + + + def deleteTmp(self): + if self.pyfile.name.startswith("tmp_"): + remove(self.pyfile.url) diff --git a/pyload/plugin/Crypter.py b/pyload/plugin/Crypter.py new file mode 100644 index 000000000..aa9966ab4 --- /dev/null +++ b/pyload/plugin/Crypter.py @@ -0,0 +1,107 @@ +# -*- coding: utf-8 -*- + +from urlparse import urlparse + +from pyload.plugin.Plugin import Plugin +from pyload.utils import decode, safe_filename + + +class Crypter(Plugin): + __name = "Crypter" + __type = "crypter" + __version = "0.05" + + __pattern = r'^unmatchable$' + __config = [("use_subfolder", "bool", "Save package to subfolder", True), #: Overrides core.config['general']['folder_per_package'] + ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] + + __description = """Base decrypter plugin""" + __license = "GPLv3" + __authors = [("Walter Purcaro", "vuolter@gmail.com")] + + + html = None #: last html loaded + + + def __init__(self, pyfile): + #: Put all packages here. It's a list of tuples like: ( name, [list of links], folder ) + self.packages = [] + + #: List of urls, pyLoad will generate packagenames + self.urls = [] + + Plugin.__init__(self, pyfile) + + + def process(self, pyfile): + """ main method """ + + self.decrypt(pyfile) + + if self.urls: + self.generatePackages() + + elif not self.packages: + self.error(_("No link extracted"), "decrypt") + + self.createPackages() + + + def decrypt(self, pyfile): + raise NotImplementedError + + + def generatePackages(self): + """ generate new packages from self.urls """ + + packages = map(lambda name, links: (name, links, None), self.core.api.generatePackages(self.urls).iteritems()) + self.packages.extend(packages) + + + def createPackages(self): + """ create new packages from self.packages """ + + package_folder = self.pyfile.package().folder + package_password = self.pyfile.package().password + package_queue = self.pyfile.package().queue + + folder_per_package = self.core.config['general']['folder_per_package'] + try: + use_subfolder = self.getConfig('use_subfolder') + except Exception: + use_subfolder = folder_per_package + try: + subfolder_per_package = self.getConfig('subfolder_per_package') + except Exception: + subfolder_per_package = True + + for pack in self.packages: + name, links, folder = pack + + self.logDebug("Parsed package: %s" % name, + "%d links" % len(links), + "Saved to folder: %s" % folder if folder else "Saved to download folder") + + links = map(decode, links) + + pid = self.core.api.addPackage(name, links, package_queue) + + if package_password: + self.core.api.setPackageData(pid, {"password": package_password}) + + setFolder = lambda x: self.core.api.setPackageData(pid, {"folder": x or ""}) #: Workaround to do not break API addPackage method + + if use_subfolder: + if not subfolder_per_package: + setFolder(package_folder) + self.logDebug("Set package %(name)s folder to: %(folder)s" % {"name": name, "folder": folder}) + + elif not folder_per_package or name != folder: + if not folder: + folder = urlparse(name).path.split("/")[-1] + + setFolder(safe_filename(folder)) + self.logDebug("Set package %(name)s folder to: %(folder)s" % {"name": name, "folder": folder}) + + elif folder_per_package: + setFolder(None) diff --git a/pyload/plugin/Hoster.py b/pyload/plugin/Hoster.py new file mode 100644 index 000000000..df778c72f --- /dev/null +++ b/pyload/plugin/Hoster.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.Plugin import Plugin + + +def getInfo(self): + #result = [ .. (name, size, status, url) .. ] + return + + +class Hoster(Plugin): + __name = "Hoster" + __type = "hoster" + __version = "0.02" + + __pattern = r'^unmatchable$' + __config = [] #: [("name", "type", "desc", "default")] + + __description = """Base hoster plugin""" + __license = "GPLv3" + __authors = [("mkaay", "mkaay@mkaay.de")] diff --git a/pyload/plugin/OCR.py b/pyload/plugin/OCR.py new file mode 100644 index 000000000..9e8d49d70 --- /dev/null +++ b/pyload/plugin/OCR.py @@ -0,0 +1,315 @@ +# -*- coding: utf-8 -*- + +from __future__ import with_statement + +try: + from PIL import Image, GifImagePlugin, JpegImagePlugin, PngImagePlugin, TiffImagePlugin +except ImportError: + import Image, GifImagePlugin, JpegImagePlugin, PngImagePlugin, TiffImagePlugin + +import logging +import subprocess + +from os.path import abspath, join + + +class OCR(object): + __name = "OCR" + __type = "ocr" + __version = "0.10" + + __description = """Base OCR plugin""" + __license = "GPLv3" + __authors = [("pyLoad Team", "admin@pyload.org")] + + + def __init__(self): + self.logger = logging.getLogger("log") + + + def load_image(self, image): + self.image = Image.open(image) + self.pixels = self.image.load() + self.result_captcha = '' + + + def unload(self): + """delete all tmp images""" + pass + + + def threshold(self, value): + self.image = self.image.point(lambda a: a * value + 10) + + + def run(self, command): + """Run a command""" + + popen = subprocess.Popen(command, bufsize=-1, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + popen.wait() + output = popen.stdout.read() + " | " + popen.stderr.read() + popen.stdout.close() + popen.stderr.close() + self.logger.debug("Tesseract ReturnCode %s Output: %s" % (popen.returncode, output)) + + + def run_tesser(self, subset=False, digits=True, lowercase=True, uppercase=True): + #tmpTif = tempfile.NamedTemporaryFile(suffix=".tif") + try: + tmpTif = open(join("tmp", "tmpTif_%s.tif" % self.__name), "wb") + tmpTif.close() + + #tmpTxt = tempfile.NamedTemporaryFile(suffix=".txt") + tmpTxt = open(join("tmp", "tmpTxt_%s.txt" % self.__name), "wb") + tmpTxt.close() + + except IOError, e: + self.logError(e) + return + + self.logger.debug("save tiff") + self.image.save(tmpTif.name, 'TIFF') + + if os.name == "nt": + tessparams = [join(pypath, "tesseract", "tesseract.exe")] + else: + tessparams = ['tesseract'] + + tessparams.extend([abspath(tmpTif.name), abspath(tmpTxt.name).replace(".txt", "")] ) + + if subset and (digits or lowercase or uppercase): + #tmpSub = tempfile.NamedTemporaryFile(suffix=".subset") + with open(join("tmp", "tmpSub_%s.subset" % self.__name), "wb") as tmpSub: + tmpSub.write("tessedit_char_whitelist ") + + if digits: + tmpSub.write("0123456789") + if lowercase: + tmpSub.write("abcdefghijklmnopqrstuvwxyz") + if uppercase: + tmpSub.write("ABCDEFGHIJKLMNOPQRSTUVWXYZ") + + tmpSub.write("\n") + tessparams.append("nobatch") + tessparams.append(abspath(tmpSub.name)) + + self.logger.debug("run tesseract") + self.run(tessparams) + self.logger.debug("read txt") + + try: + with open(tmpTxt.name, 'r') as f: + self.result_captcha = f.read().replace("\n", "") + except Exception: + self.result_captcha = "" + + self.logger.debug(self.result_captcha) + try: + os.remove(tmpTif.name) + os.remove(tmpTxt.name) + if subset and (digits or lowercase or uppercase): + os.remove(tmpSub.name) + except Exception: + pass + + + def get_captcha(self, name): + raise NotImplementedError + + + def to_greyscale(self): + if self.image.mode != 'L': + self.image = self.image.convert('L') + + self.pixels = self.image.load() + + + def eval_black_white(self, limit): + self.pixels = self.image.load() + w, h = self.image.size + for x in xrange(w): + for y in xrange(h): + if self.pixels[x, y] > limit: + self.pixels[x, y] = 255 + else: + self.pixels[x, y] = 0 + + + def clean(self, allowed): + pixels = self.pixels + + w, h = self.image.size + + for x in xrange(w): + for y in xrange(h): + if pixels[x, y] == 255: + continue + # No point in processing white pixels since we only want to remove black pixel + count = 0 + + try: + if pixels[x - 1, y - 1] != 255: + count += 1 + if pixels[x - 1, y] != 255: + count += 1 + if pixels[x - 1, y + 1] != 255: + count += 1 + if pixels[x, y + 1] != 255: + count += 1 + if pixels[x + 1, y + 1] != 255: + count += 1 + if pixels[x + 1, y] != 255: + count += 1 + if pixels[x + 1, y - 1] != 255: + count += 1 + if pixels[x, y - 1] != 255: + count += 1 + except Exception: + pass + + # not enough neighbors are dark pixels so mark this pixel + # to be changed to white + if count < allowed: + pixels[x, y] = 1 + + # second pass: this time set all 1's to 255 (white) + for x in xrange(w): + for y in xrange(h): + if pixels[x, y] == 1: + pixels[x, y] = 255 + + self.pixels = pixels + + + def derotate_by_average(self): + """rotate by checking each angle and guess most suitable""" + + w, h = self.image.size + pixels = self.pixels + + for x in xrange(w): + for y in xrange(h): + if pixels[x, y] == 0: + pixels[x, y] = 155 + + highest = {} + counts = {} + + for angle in xrange(-45, 45): + + tmpimage = self.image.rotate(angle) + + pixels = tmpimage.load() + + w, h = self.image.size + + for x in xrange(w): + for y in xrange(h): + if pixels[x, y] == 0: + pixels[x, y] = 255 + + count = {} + + for x in xrange(w): + count[x] = 0 + for y in xrange(h): + if pixels[x, y] == 155: + count[x] += 1 + + sum = 0 + cnt = 0 + + for x in count.values(): + if x != 0: + sum += x + cnt += 1 + + avg = sum / cnt + counts[angle] = cnt + highest[angle] = 0 + for x in count.values(): + if x > highest[angle]: + highest[angle] = x + + highest[angle] = highest[angle] - avg + + hkey = 0 + hvalue = 0 + + for key, value in highest.iteritems(): + if value > hvalue: + hkey = key + hvalue = value + + self.image = self.image.rotate(hkey) + pixels = self.image.load() + + for x in xrange(w): + for y in xrange(h): + if pixels[x, y] == 0: + pixels[x, y] = 255 + + if pixels[x, y] == 155: + pixels[x, y] = 0 + + self.pixels = pixels + + + def split_captcha_letters(self): + captcha = self.image + started = False + letters = [] + width, height = captcha.size + bottomY, topY = 0, height + pixels = captcha.load() + + for x in xrange(width): + black_pixel_in_col = False + for y in xrange(height): + if pixels[x, y] != 255: + if not started: + started = True + firstX = x + lastX = x + + if y > bottomY: + bottomY = y + if y < topY: + topY = y + if x > lastX: + lastX = x + + black_pixel_in_col = True + + if black_pixel_in_col is False and started is True: + rect = (firstX, topY, lastX, bottomY) + new_captcha = captcha.crop(rect) + + w, h = new_captcha.size + if w > 5 and h > 5: + letters.append(new_captcha) + + started = False + bottomY, topY = 0, height + + return letters + + + def correct(self, values, var=None): + if var: + result = var + else: + result = self.result_captcha + + for key, item in values.iteritems(): + + if key.__class__ == str: + result = result.replace(key, item) + else: + for expr in key: + result = result.replace(expr, item) + + if var: + return result + else: + self.result_captcha = result diff --git a/pyload/plugin/Plugin.py b/pyload/plugin/Plugin.py new file mode 100644 index 000000000..07797e8c6 --- /dev/null +++ b/pyload/plugin/Plugin.py @@ -0,0 +1,753 @@ +# -*- coding: utf-8 -*- + +from __future__ import with_statement + +from time import time, sleep +from random import randint + +import os +from os import remove, makedirs, chmod, stat +from os.path import exists, join + +if os.name != "nt": + from os import chown + from pwd import getpwnam + from grp import getgrnam + +from itertools import islice +from traceback import print_exc +from urlparse import urlparse + +from pyload.utils import fs_decode, fs_encode, safe_filename, safe_join + + +def chunks(iterable, size): + it = iter(iterable) + item = list(islice(it, size)) + while item: + yield item + item = list(islice(it, size)) + + +class Abort(Exception): + """ raised when aborted """ + + +class Fail(Exception): + """ raised when failed """ + + +class Reconnect(Exception): + """ raised when reconnected """ + + +class Retry(Exception): + """ raised when start again from beginning """ + + +class SkipDownload(Exception): + """ raised when download should be skipped """ + + +class Base(object): + """ + A Base class with log/config/db methods *all* plugin types can use + """ + + def __init__(self, core): + #: Core instance + self.core = core + + + def _log(self, type, args): + msg = " | ".join([encode(a).strip() for a in args if a]) + logger = getattr(self.core.log, type) + logger("%s: %s" % (self.__name, msg or _("%s MARK" % type.upper()))) + + + def logDebug(self, *args): + if self.core.debug: + return self._log("debug", args) + + + def logInfo(self, *args): + return self._log("info", args) + + + def logWarning(self, *args): + return self._log("warning", args) + + + def logError(self, *args): + return self._log("error", args) + + + def logCritical(self, *args): + return self._log("critical", args) + + + #: Deprecated method + def setConf(self, option, value): + """ see `setConfig` """ + self.setConfig(option, value) + + + def setConfig(self, option, value): + """ Set config value for current plugin + + :param option: + :param value: + :return: + """ + self.core.config.setPlugin(self.__name, option, value) + + + #: Deprecated method + def getConf(self, option): + """ see `getConfig` """ + return self.getConfig(option) + + + def getConfig(self, option): + """ Returns config value for current plugin + + :param option: + :return: + """ + return self.core.config.getPlugin(self.__name, option) + + + def setStorage(self, key, value): + """ Saves a value persistently to the database """ + self.core.db.setStorage(self.__name, key, value) + + + def store(self, key, value): + """ same as `setStorage` """ + self.core.db.setStorage(self.__name, key, value) + + + def getStorage(self, key=None, default=None): + """ Retrieves saved value or dict of all saved entries if key is None """ + if key: + return self.core.db.getStorage(self.__name, key) or default + return self.core.db.getStorage(self.__name, key) + + + def retrieve(self, *args, **kwargs): + """ same as `getStorage` """ + return self.getStorage(*args, **kwargs) + + + def delStorage(self, key): + """ Delete entry in db """ + self.core.db.delStorage(self.__name, key) + + +class Plugin(Base): + """ + Base plugin for hoster/crypter. + Overwrite `process` / `decrypt` in your subclassed plugin. + """ + __name = "Plugin" + __type = "hoster" + __version = "0.07" + + __pattern = r'^unmatchable$' + __config = [] #: [("name", "type", "desc", "default")] + + __description = """Base plugin""" + __license = "GPLv3" + __authors = [("RaNaN", "RaNaN@pyload.org"), + ("spoob", "spoob@pyload.org"), + ("mkaay", "mkaay@mkaay.de")] + + + info = {} #: file info dict + + + def __init__(self, pyfile): + Base.__init__(self, pyfile.m.core) + + #: engage wan reconnection + self.wantReconnect = False + + #: enable simultaneous processing of multiple downloads + self.multiDL = True + self.limitDL = 0 + + #: chunk limit + self.chunkLimit = 1 + self.resumeDownload = False + + #: time() + wait in seconds + self.waitUntil = 0 + self.waiting = False + + #: captcha reader instance + self.ocr = None + + #: account handler instance, see :py:class:`Account` + self.account = pyfile.m.core.accountManager.getAccountPlugin(self.__name) + + #: premium status + self.premium = False + #: username/login + self.user = None + + if self.account and not self.account.canUse(): + self.account = None + + if self.account: + self.user, data = self.account.selectAccount() + #: Browser instance, see `network.Browser` + self.req = self.account.getAccountRequest(self.user) + self.chunkLimit = -1 # chunk limit, -1 for unlimited + #: enables resume (will be ignored if server dont accept chunks) + self.resumeDownload = True + self.multiDL = True #every hoster with account should provide multiple downloads + #: premium status + self.premium = self.account.isPremium(self.user) + else: + self.req = pyfile.m.core.requestFactory.getRequest(self.__name) + + #: associated pyfile instance, see `PyFile` + self.pyfile = pyfile + + self.thread = None # holds thread in future + + #: location where the last call to download was saved + self.lastDownload = "" + #: re match of the last call to `checkDownload` + self.lastCheck = None + + #: js engine, see `JsEngine` + self.js = self.core.js + + #: captcha task + self.cTask = None + + self.html = None #@TODO: Move to hoster class in 0.4.10 + self.retries = 0 + + self.init() + + + def getChunkCount(self): + if self.chunkLimit <= 0: + return self.core.config['download']['chunks'] + return min(self.core.config['download']['chunks'], self.chunkLimit) + + + def __call__(self): + return self.__name + + + def init(self): + """initialize the plugin (in addition to `__init__`)""" + pass + + + def setup(self): + """ setup for enviroment and other things, called before downloading (possibly more than one time)""" + pass + + + def preprocessing(self, thread): + """ handles important things to do before starting """ + self.thread = thread + + if self.account: + self.account.checkLogin(self.user) + else: + self.req.clearCookies() + + self.setup() + + self.pyfile.setStatus("starting") + + return self.process(self.pyfile) + + + def process(self, pyfile): + """the 'main' method of every plugin, you **have to** overwrite it""" + raise NotImplementedError + + + def resetAccount(self): + """ dont use account and retry download """ + self.account = None + self.req = self.core.requestFactory.getRequest(self.__name) + self.retry() + + + def checksum(self, local_file=None): + """ + return codes: + 0 - checksum ok + 1 - checksum wrong + 5 - can't get checksum + 10 - not implemented + 20 - unknown error + """ + #@TODO checksum check addon + + return True, 10 + + + def setReconnect(self, reconnect): + reconnect = bool(reconnect) + self.logDebug("Set wantReconnect to: %s (previous: %s)" % (reconnect, self.wantReconnect)) + self.wantReconnect = reconnect + + + def setWait(self, seconds, reconnect=None): + """Set a specific wait time later used with `wait` + + :param seconds: wait time in seconds + :param reconnect: True if a reconnect would avoid wait time + """ + wait_time = int(seconds) + 1 + wait_until = time() + wait_time + + self.logDebug("Set waitUntil to: %f (previous: %f)" % (wait_until, self.pyfile.waitUntil), + "Wait: %d seconds" % wait_time) + + self.pyfile.waitUntil = wait_until + + if reconnect is not None: + self.setReconnect(reconnect) + + + def wait(self, seconds=None, reconnect=None): + """ waits the time previously set """ + + pyfile = self.pyfile + + if seconds is not None: + self.setWait(seconds) + + if reconnect is not None: + self.setReconnect(reconnect) + + self.waiting = True + + status = pyfile.status + pyfile.setStatus("waiting") + + self.logInfo(_("Wait: %d seconds") % (pyfile.waitUntil - time()), + _("Reconnect: %s") % self.wantReconnect) + + if self.account: + self.logDebug("Ignore reconnection due account logged") + + while pyfile.waitUntil > time(): + if pyfile.abort: + self.abort() + + sleep(1) + else: + while pyfile.waitUntil > time(): + self.thread.m.reconnecting.wait(2) + + if pyfile.abort: + self.abort() + + if self.thread.m.reconnecting.isSet(): + self.waiting = False + self.wantReconnect = False + raise Reconnect + + sleep(1) + + self.waiting = False + + pyfile.status = status + + + def fail(self, reason): + """ fail and give reason """ + raise Fail(reason) + + + def abort(self, reason=""): + """ abort and give reason """ + if reason: + self.pyfile.error = str(reason) + raise Abort + + + def error(self, reason="", type=""): + if not reason and not type: + type = "unknown" + + msg = _("%s error") % _(type.strip().capitalize()) if type else _("Error") + msg += ": " + reason.strip() if reason else "" + msg += _(" | Plugin may be out of date") + + raise Fail(msg) + + + def offline(self, reason=""): + """ fail and indicate file is offline """ + if reason: + self.pyfile.error = str(reason) + raise Fail("offline") + + + def tempOffline(self, reason=""): + """ fail and indicates file ist temporary offline, the core may take consequences """ + if reason: + self.pyfile.error = str(reason) + raise Fail("temp. offline") + + + def retry(self, max_tries=5, wait_time=1, reason=""): + """Retries and begin again from the beginning + + :param max_tries: number of maximum retries + :param wait_time: time to wait in seconds + :param reason: reason for retrying, will be passed to fail if max_tries reached + """ + if 0 < max_tries <= self.retries: + self.error(reason or _("Max retries reached"), "retry") + + self.wait(wait_time, False) + + self.retries += 1 + raise Retry(reason) + + + def invalidCaptcha(self): + self.logError(_("Invalid captcha")) + if self.cTask: + self.cTask.invalid() + + + def correctCaptcha(self): + self.logInfo(_("Correct captcha")) + if self.cTask: + self.cTask.correct() + + + def decryptCaptcha(self, url, get={}, post={}, cookies=False, forceUser=False, imgtype='jpg', + result_type='textual', timeout=290): + """ Loads a captcha and decrypts it with ocr, plugin, user input + + :param url: url of captcha image + :param get: get part for request + :param post: post part for request + :param cookies: True if cookies should be enabled + :param forceUser: if True, ocr is not used + :param imgtype: Type of the Image + :param result_type: 'textual' if text is written on the captcha\ + or 'positional' for captcha where the user have to click\ + on a specific region on the captcha + + :return: result of decrypting + """ + + img = self.load(url, get=get, post=post, cookies=cookies) + + id = ("%.2f" % time())[-6:].replace(".", "") + + with open(join("tmp", "tmpCaptcha_%s_%s.%s" % (self.__name, id, imgtype)), "wb") as tmpCaptcha: + tmpCaptcha.write(img) + + has_plugin = self.__name in self.core.pluginManager.ocrPlugins + + if self.core.captcha: + Ocr = self.core.pluginManager.loadClass("ocr", self.__name) + else: + Ocr = None + + if Ocr and not forceUser: + sleep(randint(3000, 5000) / 1000.0) + if self.pyfile.abort: + self.abort() + + ocr = Ocr() + result = ocr.get_captcha(tmpCaptcha.name) + else: + captchaManager = self.core.captchaManager + task = captchaManager.newTask(img, imgtype, tmpCaptcha.name, result_type) + self.cTask = task + captchaManager.handleCaptcha(task, timeout) + + while task.isWaiting(): + if self.pyfile.abort: + captchaManager.removeTask(task) + self.abort() + sleep(1) + + captchaManager.removeTask(task) + + if task.error and has_plugin: #ignore default error message since the user could use OCR + self.fail(_("Pil and tesseract not installed and no Client connected for captcha decrypting")) + elif task.error: + self.fail(task.error) + elif not task.result: + self.fail(_("No captcha result obtained in appropiate time by any of the plugins")) + + result = task.result + self.logDebug("Received captcha result: %s" % result) + + if not self.core.debug: + try: + remove(tmpCaptcha.name) + except Exception: + pass + + return result + + + def load(self, url, get={}, post={}, ref=True, cookies=True, just_header=False, decode=False, follow_location=True, save_cookies=True): + """Load content at url and returns it + + :param url: + :param get: + :param post: + :param ref: + :param cookies: + :param just_header: If True only the header will be retrieved and returned as dict + :param decode: Wether to decode the output according to http header, should be True in most cases + :param follow_location: If True follow location else not + :param save_cookies: If True saves received cookies else discard them + :return: Loaded content + """ + if self.pyfile.abort: + self.abort() + + if not url: + self.fail(_("No url given")) + + url = encode(url).strip() #@NOTE: utf8 vs decode -> please use decode attribute in all future plugins + + if self.core.debug: + self.logDebug("Load url: " + url, *["%s=%s" % (key, val) for key, val in locals().iteritems() if key not in ("self", "url")]) + + res = self.req.load(url, get, post, ref, cookies, just_header, decode=decode, follow_location=follow_location, save_cookies=save_cookies) + + if decode: + res = encode(res) + + if self.core.debug: + from inspect import currentframe + + frame = currentframe() + framefile = safe_join("tmp", self.__name, "%s_line%s.dump.html" % (frame.f_back.f_code.co_name, frame.f_back.f_lineno)) + try: + if not exists(join("tmp", self.__name)): + makedirs(join("tmp", self.__name)) + + with open(framefile, "wb") as f: + del frame #: delete the frame or it wont be cleaned + f.write(res) + except IOError, e: + self.logError(e) + + if just_header: + #parse header + header = {"code": self.req.code} + for line in res.splitlines(): + line = line.strip() + if not line or ":" not in line: continue + + key, none, value = line.partition(":") + key = key.strip().lower() + value = value.strip() + + if key in header: + if type(header[key]) == list: + header[key].append(value) + else: + header[key] = [header[key], value] + else: + header[key] = value + res = header + + return res + + + def download(self, url, get={}, post={}, ref=True, cookies=True, disposition=False): + """Downloads the content at url to download folder + + :param url: + :param get: + :param post: + :param ref: + :param cookies: + :param disposition: if True and server provides content-disposition header\ + the filename will be changed if needed + :return: The location where the file was saved + """ + if self.pyfile.abort: + self.abort() + + if not url: + self.fail(_("No url given")) + + url = encode(url).strip() + + if self.core.debug: + self.logDebug("Download url: " + url, *["%s=%s" % (key, val) for key, val in locals().iteritems() if key not in ("self", "url")]) + + self.checkForSameFiles() + + self.pyfile.setStatus("downloading") + + download_folder = self.core.config['general']['download_folder'] + + location = safe_join(download_folder, self.pyfile.package().folder) + + if not exists(location): + try: + makedirs(location, int(self.core.config['permission']['folder'], 8)) + + if self.core.config['permission']['change_dl'] and os.name != "nt": + uid = getpwnam(self.core.config['permission']['user'])[2] + gid = getgrnam(self.core.config['permission']['group'])[2] + chown(location, uid, gid) + + except Exception, e: + self.fail(e) + + # convert back to unicode + location = fs_decode(location) + name = safe_filename(self.pyfile.name) + + filename = join(location, name) + + self.core.addonManager.dispatchEvent("download-start", self.pyfile, url, filename) + + try: + newname = self.req.httpDownload(url, filename, get=get, post=post, ref=ref, cookies=cookies, + chunks=self.getChunkCount(), resume=self.resumeDownload, + progressNotify=self.pyfile.setProgress, disposition=disposition) + finally: + self.pyfile.size = self.req.size + + if newname: + newname = urlparse(newname).path.split("/")[-1] + + if disposition and newname != name: + self.logInfo(_("%(name)s saved as %(newname)s") % {"name": name, "newname": newname}) + self.pyfile.name = newname + filename = join(location, newname) + + fs_filename = fs_encode(filename) + + if self.core.config['permission']['change_file']: + try: + chmod(fs_filename, int(self.core.config['permission']['file'], 8)) + except Exception, e: + self.logWarning(_("Setting file mode failed"), e) + + if self.core.config['permission']['change_dl'] and os.name != "nt": + try: + uid = getpwnam(self.core.config['permission']['user'])[2] + gid = getgrnam(self.core.config['permission']['group'])[2] + chown(fs_filename, uid, gid) + + except Exception, e: + self.logWarning(_("Setting User and Group failed"), e) + + self.lastDownload = filename + return self.lastDownload + + + def checkDownload(self, rules, api_size=0, max_size=50000, delete=True, read_size=0): + """ checks the content of the last downloaded file, re match is saved to `lastCheck` + + :param rules: dict with names and rules to match (compiled regexp or strings) + :param api_size: expected file size + :param max_size: if the file is larger then it wont be checked + :param delete: delete if matched + :param read_size: amount of bytes to read from files larger then max_size + :return: dictionary key of the first rule that matched + """ + lastDownload = fs_encode(self.lastDownload) + if not exists(lastDownload): + return None + + size = stat(lastDownload) + size = size.st_size + + if api_size and api_size <= size: return None + elif size > max_size and not read_size: return None + self.logDebug("Download Check triggered") + + with open(lastDownload, "rb") as f: + content = f.read(read_size if read_size else -1) + + #produces encoding errors, better log to other file in the future? + #self.logDebug("Content: %s" % content) + for name, rule in rules.iteritems(): + if isinstance(rule, basestring): + if rule in content: + if delete: + remove(lastDownload) + return name + elif hasattr(rule, "search"): + m = rule.search(content) + if m: + if delete: + remove(lastDownload) + self.lastCheck = m + return name + + + def getPassword(self): + """ get the password the user provided in the package""" + password = self.pyfile.package().password + if not password: return "" + return password + + + def checkForSameFiles(self, starting=False): + """ checks if same file was/is downloaded within same package + + :param starting: indicates that the current download is going to start + :raises SkipDownload: + """ + + pack = self.pyfile.package() + + for pyfile in self.core.files.cache.values(): + if pyfile != self.pyfile and pyfile.name == self.pyfile.name and pyfile.package().folder == pack.folder: + if pyfile.status in (0, 12): #finished or downloading + raise SkipDownload(pyfile.pluginname) + elif pyfile.status in ( + 5, 7) and starting: #a download is waiting/starting and was appenrently started before + raise SkipDownload(pyfile.pluginname) + + download_folder = self.core.config['general']['download_folder'] + location = safe_join(download_folder, pack.folder, self.pyfile.name) + + if starting and self.core.config['download']['skip_existing'] and exists(location): + size = os.stat(location).st_size + if size >= self.pyfile.size: + raise SkipDownload("File exists") + + pyfile = self.core.db.findDuplicates(self.pyfile.id, self.pyfile.package().folder, self.pyfile.name) + if pyfile: + if exists(location): + raise SkipDownload(pyfile[0]) + + self.logDebug("File %s not skipped, because it does not exists." % self.pyfile.name) + + + def clean(self): + """ clean everything and remove references """ + if hasattr(self, "pyfile"): + del self.pyfile + + if hasattr(self, "req"): + self.req.close() + del self.req + + if hasattr(self, "thread"): + del self.thread + + if hasattr(self, "html"): + del self.html diff --git a/pyload/plugin/__init__.py b/pyload/plugin/__init__.py new file mode 100644 index 000000000..40a96afc6 --- /dev/null +++ b/pyload/plugin/__init__.py @@ -0,0 +1 @@ +# -*- coding: utf-8 -*- diff --git a/pyload/plugin/account/AlldebridCom.py b/pyload/plugin/account/AlldebridCom.py new file mode 100644 index 000000000..14b1755ca --- /dev/null +++ b/pyload/plugin/account/AlldebridCom.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- + +import re +import xml.dom.minidom as dom + +from time import time +from urllib import urlencode + +from BeautifulSoup import BeautifulSoup + +from pyload.plugin.Account import Account + + +class AlldebridCom(Account): + __name = "AlldebridCom" + __type = "account" + __version = "0.22" + + __description = """AllDebrid.com account plugin""" + __license = "GPLv3" + __authors = [("Andy Voigt", "spamsales@online.de")] + + + def loadAccountInfo(self, user, req): + data = self.getAccountData(user) + page = req.load("http://www.alldebrid.com/account/") + soup = BeautifulSoup(page) + #Try to parse expiration date directly from the control panel page (better accuracy) + try: + time_text = soup.find('div', attrs={'class': 'remaining_time_text'}).strong.string + self.logDebug("Account expires in: %s" % time_text) + p = re.compile('\d+') + exp_data = p.findall(time_text) + exp_time = time() + int(exp_data[0]) * 24 * 60 * 60 + int( + exp_data[1]) * 60 * 60 + (int(exp_data[2]) - 1) * 60 + #Get expiration date from API + except Exception: + data = self.getAccountData(user) + page = req.load("http://www.alldebrid.com/api.php", + get={'action': "info_user", 'login': user, 'pw': data['password']}) + self.logDebug(page) + xml = dom.parseString(page) + exp_time = time() + int(xml.getElementsByTagName("date")[0].childNodes[0].nodeValue) * 24 * 60 * 60 + account_info = {"validuntil": exp_time, "trafficleft": -1} + return account_info + + + def login(self, user, data, req): + urlparams = urlencode({'action': 'login', 'login_login': user, 'login_password': data['password']}) + page = req.load("http://www.alldebrid.com/register/?%s" % urlparams) + + if "This login doesn't exist" in page: + self.wrongPassword() + + if "The password is not valid" in page: + self.wrongPassword() + + if "Invalid captcha" in page: + self.wrongPassword() diff --git a/pyload/plugin/account/BayfilesCom.py b/pyload/plugin/account/BayfilesCom.py new file mode 100644 index 000000000..5ca04c86b --- /dev/null +++ b/pyload/plugin/account/BayfilesCom.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- + +from time import time + +from pyload.plugin.Account import Account +from pyload.utils import json_loads + + +class BayfilesCom(Account): + __name = "BayfilesCom" + __type = "account" + __version = "0.03" + + __description = """Bayfiles.com account plugin""" + __license = "GPLv3" + __authors = [("zoidberg", "zoidberg@mujmail.cz")] + + + def loadAccountInfo(self, user, req): + for _i in xrange(2): + res = json_loads(req.load("http://api.bayfiles.com/v1/account/info")) + self.logDebug(res) + if not res['error']: + break + self.logWarning(res['error']) + self.relogin(user) + + return {"premium": bool(res['premium']), "trafficleft": -1, + "validuntil": res['expires'] if res['expires'] >= int(time()) else -1} + + + def login(self, user, data, req): + res = json_loads(req.load("http://api.bayfiles.com/v1/account/login/%s/%s" % (user, data['password']))) + self.logDebug(res) + if res['error']: + self.logError(res['error']) + self.wrongPassword() diff --git a/pyload/plugin/account/BillionuploadsCom.py b/pyload/plugin/account/BillionuploadsCom.py new file mode 100644 index 000000000..982a2cc34 --- /dev/null +++ b/pyload/plugin/account/BillionuploadsCom.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.internal.XFSAccount import XFSAccount + + +class BillionuploadsCom(XFSAccount): + __name = "BillionuploadsCom" + __type = "account" + __version = "0.02" + + __description = """Billionuploads.com account plugin""" + __license = "GPLv3" + __authors = [("Walter Purcaro", "vuolter@gmail.com")] + + + HOSTER_DOMAIN = "billionuploads.com" diff --git a/pyload/plugin/account/BitshareCom.py b/pyload/plugin/account/BitshareCom.py new file mode 100644 index 000000000..591fe7f89 --- /dev/null +++ b/pyload/plugin/account/BitshareCom.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.Account import Account + + +class BitshareCom(Account): + __name = "BitshareCom" + __type = "account" + __version = "0.12" + + __description = """Bitshare account plugin""" + __license = "GPLv3" + __authors = [("Paul King", "")] + + + def loadAccountInfo(self, user, req): + page = req.load("http://bitshare.com/mysettings.html") + + if "\"http://bitshare.com/myupgrade.html\">Free" in page: + return {"validuntil": -1, "trafficleft": -1, "premium": False} + + if not '' in page: + self.logWarning(_("Activate direct Download in your Bitshare Account")) + + return {"validuntil": -1, "trafficleft": -1, "premium": True} + + + def login(self, user, data, req): + page = req.load("http://bitshare.com/login.html", + post={"user": user, "password": data['password'], "submit": "Login"}, cookies=True) + if "login" in req.lastEffectiveURL: + self.wrongPassword() diff --git a/pyload/plugin/account/CatShareNet.py b/pyload/plugin/account/CatShareNet.py new file mode 100644 index 000000000..8fe3d05cf --- /dev/null +++ b/pyload/plugin/account/CatShareNet.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- + +import re + +from time import mktime, strptime + +from pyload.plugin.Account import Account + + +class CatShareNet(Account): + __name = "CatShareNet" + __type = "account" + __version = "0.01" + + __description = """CatShareNet account plugin""" + __license = "GPLv3" + __authors = [("prOq", "")] + + + PREMIUM_PATTERN = r'class="nav-collapse collapse pull-right">[\s\w<>=-."/:]*\sz.\s*
  • .*\s*(.*?)[\s\w<>/]*href="/logout"' + VALID_UNTIL_PATTERN = r'
    [\s\w<>=-":;]*.*?(.*?)' + + + def loadAccountInfo(self, user, req): + premium = False + validuntil = -1 + + html = req.load("http://catshare.net/", decode=True) + + try: + m = re.search(self.PREMIUM_PATTERN, html) + if "Premium" in m.group(1): + premium = True + except Exception: + pass + + try: + m = re.search(self.VALID_UNTIL_PATTERN, html) + expiredate = m.group(1) + if "-" not in expiredate: + validuntil = mktime(strptime(expiredate, "%d.%m.%Y")) + except Exception: + pass + + return {'premium': premium, 'trafficleft': -1, 'validuntil': validuntil} + + + def login(self, user, data, req): + html = req.load("http://catshare.net/login", + post={'user_email': user, + 'user_password': data['password'], + 'remindPassword': 0, + 'user[submit]': "Login"}) + + if not 'Wyloguj' in html: + self.wrongPassword() diff --git a/pyload/plugin/account/CramitIn.py b/pyload/plugin/account/CramitIn.py new file mode 100644 index 000000000..ccd291776 --- /dev/null +++ b/pyload/plugin/account/CramitIn.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.internal.XFSAccount import XFSAccount + + +class CramitIn(XFSAccount): + __name = "CramitIn" + __type = "account" + __version = "0.03" + + __description = """Cramit.in account plugin""" + __license = "GPLv3" + __authors = [("zoidberg", "zoidberg@mujmail.cz")] + + + HOSTER_DOMAIN = "cramit.in" diff --git a/pyload/plugin/account/CzshareCom.py b/pyload/plugin/account/CzshareCom.py new file mode 100644 index 000000000..f11d4efd4 --- /dev/null +++ b/pyload/plugin/account/CzshareCom.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- + +from time import mktime, strptime +import re + +from pyload.plugin.Account import Account + + +class CzshareCom(Account): + __name = "CzshareCom" + __type = "account" + __version = "0.14" + + __description = """Czshare.com account plugin, now Sdilej.cz""" + __license = "GPLv3" + __authors = [("zoidberg", "zoidberg@mujmail.cz"), + ("stickell", "l.stickell@yahoo.it")] + + + CREDIT_LEFT_PATTERN = r'\s*([\d ,]+) (KiB|MiB|GiB)\s*([^<]*)\s*' + + + def loadAccountInfo(self, user, req): + html = req.load("http://sdilej.cz/prehled_kreditu/") + + m = re.search(self.CREDIT_LEFT_PATTERN, html) + if m is None: + return {"validuntil": 0, "trafficleft": 0} + else: + credits = float(m.group(1).replace(' ', '').replace(',', '.')) + credits = credits * 1024 ** {'KiB': 0, 'MiB': 1, 'GiB': 2}[m.group(2)] + validuntil = mktime(strptime(m.group(3), '%d.%m.%y %H:%M')) + return {"validuntil": validuntil, "trafficleft": credits} + + + def login(self, user, data, req): + html = req.load('https://sdilej.cz/index.php', post={ + "Prihlasit": "Prihlasit", + "login-password": data['password'], + "login-name": user + }) + + if '", html).group(1) + + validuntil = int(mktime(strptime(validuntil, "%Y-%m-%d %H:%M:%S"))) + + return {"validuntil": validuntil, "trafficleft": -1} + + + def login(self, user, data, req): + html = req.load("https://dfiles.eu/de/login.php", get={"return": "/de/gold/payment.php"}, + post={"login": user, "password": data['password']}) + if r'
    Sie haben eine falsche Benutzername-Passwort-Kombination verwendet.
    ' in html: + self.wrongPassword() diff --git a/pyload/plugin/account/DropboxCom.py b/pyload/plugin/account/DropboxCom.py new file mode 100644 index 000000000..2c4c36c4a --- /dev/null +++ b/pyload/plugin/account/DropboxCom.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- + +import re + +from pyload.plugin.internal.SimpleHoster import SimpleHoster, create_getInfo + + +class DropboxCom(SimpleHoster): + __name = "DropboxCom" + __type = "hoster" + __version = "0.03" + + __pattern = r'https?://(?:www\.)?dropbox\.com/.+' + + __description = """Dropbox.com hoster plugin""" + __license = "GPLv3" + __authors = [("zapp-brannigan", "fuerst.reinje@web.de")] + + + NAME_PATTERN = r'Dropbox - (?P<N>.+?)<' + SIZE_PATTERN = r' ·  (?P<S>[\d.,]+) (?P<U>[\w^_]+)' + + OFFLINE_PATTERN = r'<title>Dropbox - (404|Shared link error)<' + + COOKIES = [("dropbox.com", "lang", "en")] + + + def setup(self): + self.multiDL = True + self.chunkLimit = 1 + self.resumeDownload = True + + + def handleFree(self): + self.download(self.pyfile.url, get={'dl': "1"}) + + check = self.checkDownload({'html': re.compile("html")}) + if check == "html": + self.error(_("Downloaded file is an html page")) + + +getInfo = create_getInfo(DropboxCom) diff --git a/pyload/plugin/account/EasybytezCom.py b/pyload/plugin/account/EasybytezCom.py new file mode 100644 index 000000000..c1f641669 --- /dev/null +++ b/pyload/plugin/account/EasybytezCom.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +import re + +from pyload.plugin.internal.XFSAccount import XFSAccount + + +class EasybytezCom(XFSAccount): + __name = "EasybytezCom" + __type = "account" + __version = "0.12" + + __description = """EasyBytez.com account plugin""" + __license = "GPLv3" + __authors = [("zoidberg", "zoidberg@mujmail.cz"), + ("guidobelix", "guidobelix@hotmail.it")] + + + HOSTER_DOMAIN = "easybytez.com" diff --git a/pyload/plugin/account/EuroshareEu.py b/pyload/plugin/account/EuroshareEu.py new file mode 100644 index 000000000..9e948816c --- /dev/null +++ b/pyload/plugin/account/EuroshareEu.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- + +from time import mktime, strptime +import re + +from pyload.plugin.Account import Account + + +class EuroshareEu(Account): + __name = "EuroshareEu" + __type = "account" + __version = "0.01" + + __description = """Euroshare.eu account plugin""" + __license = "GPLv3" + __authors = [("zoidberg", "zoidberg@mujmail.cz")] + + + def loadAccountInfo(self, user, req): + self.relogin(user) + html = req.load("http://euroshare.eu/customer-zone/settings/") + + m = re.search('id="input_expire_date" value="(\d+\.\d+\.\d+ \d+:\d+)"', html) + if m is None: + premium, validuntil = False, -1 + else: + premium = True + validuntil = mktime(strptime(m.group(1), "%d.%m.%Y %H:%M")) + + return {"validuntil": validuntil, "trafficleft": -1, "premium": premium} + + + def login(self, user, data, req): + html = req.load('http://euroshare.eu/customer-zone/login/', post={ + "trvale": "1", + "login": user, + "password": data['password'] + }, decode=True) + + if u">Nesprávne prihlasovacie meno alebo heslo" in html: + self.wrongPassword() diff --git a/pyload/plugin/account/FastixRu.py b/pyload/plugin/account/FastixRu.py new file mode 100644 index 000000000..b2ef7f685 --- /dev/null +++ b/pyload/plugin/account/FastixRu.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.Account import Account +from pyload.utils import json_loads + + +class FastixRu(Account): + __name = "FastixRu" + __type = "account" + __version = "0.02" + + __description = """Fastix account plugin""" + __license = "GPLv3" + __authors = [("Massimo Rosamilia", "max@spiritix.eu")] + + + def loadAccountInfo(self, user, req): + data = self.getAccountData(user) + page = json_loads(req.load("http://fastix.ru/api_v2/", get={'apikey': data['api'], 'sub': "getaccountdetails"})) + + points = page['points'] + kb = float(points) * 1024 ** 2 / 1000 + + if points > 0: + account_info = {"validuntil": -1, "trafficleft": kb} + else: + account_info = {"validuntil": None, "trafficleft": None, "premium": False} + return account_info + + + def login(self, user, data, req): + page = req.load("http://fastix.ru/api_v2/", + get={'sub': "get_apikey", 'email': user, 'password': data['password']}) + api = json_loads(page) + api = api['apikey'] + data['api'] = api + if "error_code" in page: + self.wrongPassword() diff --git a/pyload/plugin/account/FastshareCz.py b/pyload/plugin/account/FastshareCz.py new file mode 100644 index 000000000..4ce94be5e --- /dev/null +++ b/pyload/plugin/account/FastshareCz.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- + +import re + +from pyload.plugin.Account import Account +from pyload.utils import parseFileSize + + +class FastshareCz(Account): + __name = "FastshareCz" + __type = "account" + __version = "0.05" + + __description = """Fastshare.cz account plugin""" + __license = "GPLv3" + __authors = [("zoidberg", "zoidberg@mujmail.cz"), + ("stickell", "l.stickell@yahoo.it")] + + + CREDIT_PATTERN = r'My account\s*\((.+?)\)' + + + def loadAccountInfo(self, user, req): + validuntil = None + trafficleft = None + premium = None + + html = req.load("http://www.fastshare.cz/user", decode=True) + + m = re.search(self.CREDIT_PATTERN, html) + if m: + trafficleft = self.parseTraffic(m.group(1)) + + if trafficleft: + premium = True + validuntil = -1 + else: + premium = False + + return {"validuntil": validuntil, "trafficleft": trafficleft, "premium": premium} + + + def login(self, user, data, req): + req.cj.setCookie("fastshare.cz", "lang", "en") + + req.load('http://www.fastshare.cz/login') # Do not remove or it will not login + + html = req.load("http://www.fastshare.cz/sql.php", + post={'login': user, 'heslo': data['password']}, + decode=True) + + if ">Wrong username or password" in html: + self.wrongPassword() diff --git a/pyload/plugin/account/File4safeCom.py b/pyload/plugin/account/File4safeCom.py new file mode 100644 index 000000000..d7004b463 --- /dev/null +++ b/pyload/plugin/account/File4safeCom.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.internal.XFSAccount import XFSAccount + + +class File4safeCom(XFSAccount): + __name = "File4safeCom" + __type = "account" + __version = "0.04" + + __description = """File4safe.com account plugin""" + __license = "GPLv3" + __authors = [("stickell", "l.stickell@yahoo.it")] + + + HOSTER_DOMAIN = "file4safe.com" + + LOGIN_FAIL_PATTERN = r'input_login' diff --git a/pyload/plugin/account/FileParadoxIn.py b/pyload/plugin/account/FileParadoxIn.py new file mode 100644 index 000000000..0e103c4e7 --- /dev/null +++ b/pyload/plugin/account/FileParadoxIn.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.internal.XFSAccount import XFSAccount + + +class FileParadoxIn(XFSAccount): + __name = "FileParadoxIn" + __type = "account" + __version = "0.02" + + __description = """FileParadox.in account plugin""" + __license = "GPLv3" + __authors = [("Walter Purcaro", "vuolter@gmail.com")] + + + HOSTER_DOMAIN = "fileparadox.in" diff --git a/pyload/plugin/account/FilecloudIo.py b/pyload/plugin/account/FilecloudIo.py new file mode 100644 index 000000000..c6638bb1f --- /dev/null +++ b/pyload/plugin/account/FilecloudIo.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.Account import Account +from pyload.utils import json_loads + + +class FilecloudIo(Account): + __name = "FilecloudIo" + __type = "account" + __version = "0.02" + + __description = """FilecloudIo account plugin""" + __license = "GPLv3" + __authors = [("zoidberg", "zoidberg@mujmail.cz"), + ("stickell", "l.stickell@yahoo.it")] + + + def loadAccountInfo(self, user, req): + # It looks like the first API request always fails, so we retry 5 times, it should work on the second try + for _i in xrange(5): + rep = req.load("https://secure.filecloud.io/api-fetch_apikey.api", + post={"username": user, "password": self.accounts[user]['password']}) + rep = json_loads(rep) + if rep['status'] == 'ok': + break + elif rep['status'] == 'error' and rep['message'] == 'no such user or wrong password': + self.logError(_("Wrong username or password")) + return {"valid": False, "premium": False} + else: + return {"premium": False} + + akey = rep['akey'] + self.accounts[user]['akey'] = akey # Saved for hoster plugin + rep = req.load("http://api.filecloud.io/api-fetch_account_details.api", + post={"akey": akey}) + rep = json_loads(rep) + + if rep['is_premium'] == 1: + return {"validuntil": int(rep['premium_until']), "trafficleft": -1} + else: + return {"premium": False} + + + def login(self, user, data, req): + req.cj.setCookie("secure.filecloud.io", "lang", "en") + html = req.load('https://secure.filecloud.io/user-login.html') + + if not hasattr(self, "form_data"): + self.form_data = {} + + self.form_data['username'] = user + self.form_data['password'] = data['password'] + + html = req.load('https://secure.filecloud.io/user-login_p.html', + post=self.form_data, + multipart=True) + + self.logged_in = True if "you have successfully logged in - filecloud.io" in html else False + self.form_data = {} diff --git a/pyload/plugin/account/FilefactoryCom.py b/pyload/plugin/account/FilefactoryCom.py new file mode 100644 index 000000000..d79875423 --- /dev/null +++ b/pyload/plugin/account/FilefactoryCom.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- + +import re +from time import mktime, strptime + +from pycurl import REFERER + +from pyload.plugin.Account import Account + + +class FilefactoryCom(Account): + __name = "FilefactoryCom" + __type = "account" + __version = "0.14" + + __description = """Filefactory.com account plugin""" + __license = "GPLv3" + __authors = [("zoidberg", "zoidberg@mujmail.cz"), + ("stickell", "l.stickell@yahoo.it")] + + + VALID_UNTIL_PATTERN = r'Premium valid until: <strong>(?P<d>\d{1,2})\w{1,2} (?P<m>\w{3}), (?P<y>\d{4})</strong>' + + + def loadAccountInfo(self, user, req): + html = req.load("http://www.filefactory.com/account/") + + m = re.search(self.VALID_UNTIL_PATTERN, html) + if m: + premium = True + validuntil = re.sub(self.VALID_UNTIL_PATTERN, '\g<d> \g<m> \g<y>', m.group(0)) + validuntil = mktime(strptime(validuntil, "%d %b %Y")) + else: + premium = False + validuntil = -1 + + return {"premium": premium, "trafficleft": -1, "validuntil": validuntil} + + + def login(self, user, data, req): + req.http.c.setopt(REFERER, "http://www.filefactory.com/member/login.php") + + html = req.load("http://www.filefactory.com/member/signin.php", post={ + "loginEmail": user, + "loginPassword": data['password'], + "Submit": "Sign In"}) + + if req.lastEffectiveURL != "http://www.filefactory.com/account/": + self.wrongPassword() diff --git a/pyload/plugin/account/FilejungleCom.py b/pyload/plugin/account/FilejungleCom.py new file mode 100644 index 000000000..5de4a244d --- /dev/null +++ b/pyload/plugin/account/FilejungleCom.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- + +import re +from time import mktime, strptime + +from pyload.plugin.Account import Account + + +class FilejungleCom(Account): + __name = "FilejungleCom" + __type = "account" + __version = "0.11" + + __description = """Filejungle.com account plugin""" + __license = "GPLv3" + __authors = [("zoidberg", "zoidberg@mujmail.cz")] + + + login_timeout = 60 + + URL = "http://filejungle.com/" + TRAFFIC_LEFT_PATTERN = r'"/extend_premium\.php">Until (\d+ \w+ \d+)<br' + LOGIN_FAILED_PATTERN = r'<span htmlfor="loginUser(Name|Password)" generated="true" class="fail_info">' + + + def loadAccountInfo(self, user, req): + html = req.load(self.URL + "dashboard.php") + m = re.search(self.TRAFFIC_LEFT_PATTERN, html) + if m: + premium = True + validuntil = mktime(strptime(m.group(1), "%d %b %Y")) + else: + premium = False + validuntil = -1 + + return {"premium": premium, "trafficleft": -1, "validuntil": validuntil} + + + def login(self, user, data, req): + html = req.load(self.URL + "login.php", post={ + "loginUserName": user, + "loginUserPassword": data['password'], + "loginFormSubmit": "Login", + "recaptcha_challenge_field": "", + "recaptcha_response_field": "", + "recaptcha_shortencode_field": ""}) + + if re.search(self.LOGIN_FAILED_PATTERN, html): + self.wrongPassword() diff --git a/pyload/plugin/account/FileomCom.py b/pyload/plugin/account/FileomCom.py new file mode 100644 index 000000000..2868e49e6 --- /dev/null +++ b/pyload/plugin/account/FileomCom.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.internal.XFSAccount import XFSAccount + + +class FileomCom(XFSAccount): + __name = "FileomCom" + __type = "account" + __version = "0.02" + + __description = """Fileom.com account plugin""" + __license = "GPLv3" + __authors = [("Walter Purcaro", "vuolter@gmail.com")] + + + HOSTER_DOMAIN = "fileom.com" diff --git a/pyload/plugin/account/FilerNet.py b/pyload/plugin/account/FilerNet.py new file mode 100644 index 000000000..9420a6e8e --- /dev/null +++ b/pyload/plugin/account/FilerNet.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- + +import re +import time + +from pyload.plugin.Account import Account + + +class FilerNet(Account): + __name = "FilerNet" + __type = "account" + __version = "0.02" + + __description = """Filer.net account plugin""" + __license = "GPLv3" + __authors = [("stickell", "l.stickell@yahoo.it")] + + + TOKEN_PATTERN = r'_csrf_token" value="([^"]+)" />' + WALID_UNTIL_PATTERN = r'Der Premium-Zugang ist gültig bis (.+)\.\s*</td>' + TRAFFIC_PATTERN = r'Traffic</th>\s*<td>([^<]+)</td>' + FREE_PATTERN = r'Account Status</th>\s*<td>\s*Free' + + + def loadAccountInfo(self, user, req): + html = req.load("https://filer.net/profile") + + # Free user + if re.search(self.FREE_PATTERN, html): + return {"premium": False, "validuntil": None, "trafficleft": None} + + until = re.search(self.WALID_UNTIL_PATTERN, html) + traffic = re.search(self.TRAFFIC_PATTERN, html) + if until and traffic: + validuntil = int(time.mktime(time.strptime(until.group(1), "%d.%m.%Y %H:%M:%S"))) + trafficleft = self.parseTraffic(traffic.group(1)) + return {"premium": True, "validuntil": validuntil, "trafficleft": trafficleft} + else: + self.logError(_("Unable to retrieve account information")) + return {"premium": False, "validuntil": None, "trafficleft": None} + + + def login(self, user, data, req): + html = req.load("https://filer.net/login") + token = re.search(self.TOKEN_PATTERN, html).group(1) + html = req.load("https://filer.net/login_check", + post={"_username": user, "_password": data['password'], + "_remember_me": "on", "_csrf_token": token, "_target_path": "https://filer.net/"}) + if 'Logout' not in html: + self.wrongPassword() diff --git a/pyload/plugin/account/FilerioCom.py b/pyload/plugin/account/FilerioCom.py new file mode 100644 index 000000000..d222fa78b --- /dev/null +++ b/pyload/plugin/account/FilerioCom.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.internal.XFSAccount import XFSAccount + + +class FilerioCom(XFSAccount): + __name = "FilerioCom" + __type = "account" + __version = "0.03" + + __description = """FileRio.in account plugin""" + __license = "GPLv3" + __authors = [("zoidberg", "zoidberg@mujmail.cz")] + + + HOSTER_DOMAIN = "filerio.in" diff --git a/pyload/plugin/account/FilesMailRu.py b/pyload/plugin/account/FilesMailRu.py new file mode 100644 index 000000000..41433687f --- /dev/null +++ b/pyload/plugin/account/FilesMailRu.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.Account import Account + + +class FilesMailRu(Account): + __name = "FilesMailRu" + __type = "account" + __version = "0.10" + + __description = """Filesmail.ru account plugin""" + __license = "GPLv3" + __authors = [("RaNaN", "RaNaN@pyload.org")] + + + def loadAccountInfo(self, user, req): + return {"validuntil": None, "trafficleft": None} + + + def login(self, user, data, req): + user, domain = user.split("@") + + page = req.load("http://swa.mail.ru/cgi-bin/auth", None, + {"Domain": domain, "Login": user, "Password": data['password'], + "Page": "http://files.mail.ru/"}, cookies=True) + + if "Неверное имя пользователя или пароль" in page: # @TODO seems not to work + self.wrongPassword() diff --git a/pyload/plugin/account/FileserveCom.py b/pyload/plugin/account/FileserveCom.py new file mode 100644 index 000000000..d0ef0cd62 --- /dev/null +++ b/pyload/plugin/account/FileserveCom.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- + +from time import mktime, strptime + +from pyload.plugin.Account import Account +from pyload.utils import json_loads + + +class FileserveCom(Account): + __name = "FileserveCom" + __type = "account" + __version = "0.20" + + __description = """Fileserve.com account plugin""" + __license = "GPLv3" + __authors = [("mkaay", "mkaay@mkaay.de")] + + + def loadAccountInfo(self, user, req): + data = self.getAccountData(user) + + page = req.load("http://app.fileserve.com/api/login/", post={"username": user, "password": data['password'], + "submit": "Submit+Query"}) + res = json_loads(page) + + if res['type'] == "premium": + validuntil = mktime(strptime(res['expireTime'], "%Y-%m-%d %H:%M:%S")) + return {"trafficleft": res['traffic'], "validuntil": validuntil} + else: + return {"premium": False, "trafficleft": None, "validuntil": None} + + + def login(self, user, data, req): + page = req.load("http://app.fileserve.com/api/login/", post={"username": user, "password": data['password'], + "submit": "Submit+Query"}) + res = json_loads(page) + + if not res['type']: + self.wrongPassword() + + #login at fileserv page + req.load("http://www.fileserve.com/login.php", + post={"loginUserName": user, "loginUserPassword": data['password'], "autoLogin": "checked", + "loginFormSubmit": "Login"}) diff --git a/pyload/plugin/account/FourSharedCom.py b/pyload/plugin/account/FourSharedCom.py new file mode 100644 index 000000000..84c062e84 --- /dev/null +++ b/pyload/plugin/account/FourSharedCom.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.Account import Account +from pyload.utils import json_loads + + +class FourSharedCom(Account): + __name = "FourSharedCom" + __type = "account" + __version = "0.03" + + __description = """FourShared.com account plugin""" + __license = "GPLv3" + __authors = [("zoidberg", "zoidberg@mujmail.cz"), + ("stickell", "l.stickell@yahoo.it")] + + + def loadAccountInfo(self, user, req): + # Free mode only for now + return {"premium": False} + + + def login(self, user, data, req): + req.cj.setCookie("4shared.com", "4langcookie", "en") + res = req.load('http://www.4shared.com/web/login', + post={'login': user, + 'password': data['password'], + 'remember': "on", + '_remember': "on", + 'returnTo': "http://www.4shared.com/account/home.jsp"}) + + if 'Please log in to access your 4shared account' in res: + self.wrongPassword() diff --git a/pyload/plugin/account/FreakshareCom.py b/pyload/plugin/account/FreakshareCom.py new file mode 100644 index 000000000..76d094a8b --- /dev/null +++ b/pyload/plugin/account/FreakshareCom.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- + +import re + +from time import strptime, mktime + +from pyload.plugin.Account import Account + + +class FreakshareCom(Account): + __name = "FreakshareCom" + __type = "account" + __version = "0.11" + + __description = """Freakshare.com account plugin""" + __license = "GPLv3" + __authors = [("RaNaN", "RaNaN@pyload.org")] + + + def loadAccountInfo(self, user, req): + page = req.load("http://freakshare.com/") + + validuntil = r'ltig bis:</td>\s*<td><b>([\d.:-]+)</b></td>' + validuntil = re.search(validuntil, page, re.M) + validuntil = validuntil.group(1).strip() + validuntil = mktime(strptime(validuntil, "%d.%m.%Y - %H:%M")) + + traffic = r'Traffic verbleibend:</td>\s*<td>([^<]+)' + traffic = re.search(traffic, page, re.M) + traffic = traffic.group(1).strip() + traffic = self.parseTraffic(traffic) + + return {"validuntil": validuntil, "trafficleft": traffic} + + + def login(self, user, data, req): + req.load("http://freakshare.com/index.php?language=EN") + + page = req.load("http://freakshare.com/login.html", None, + {"submit": "Login", "user": user, "pass": data['password']}, cookies=True) + + if ">Wrong Username or Password" in page: + self.wrongPassword() diff --git a/pyload/plugin/account/FreeWayMe.py b/pyload/plugin/account/FreeWayMe.py new file mode 100644 index 000000000..90c504c70 --- /dev/null +++ b/pyload/plugin/account/FreeWayMe.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.Account import Account +from pyload.utils import json_loads + + +class FreeWayMe(Account): + __name = "FreeWayMe" + __type = "account" + __version = "0.11" + + __description = """FreeWayMe account plugin""" + __license = "GPLv3" + __authors = [("Nicolas Giese", "james@free-way.me")] + + + def loadAccountInfo(self, user, req): + status = self.getAccountStatus(user, req) + if not status: + return False + self.logDebug(status) + + account_info = {"validuntil": -1, "premium": False} + if status['premium'] == "Free": + account_info['trafficleft'] = int(status['guthaben']) * 1024 + elif status['premium'] == "Spender": + account_info['trafficleft'] = -1 + elif status['premium'] == "Flatrate": + account_info = {"validuntil": int(status['Flatrate']), + "trafficleft": -1, + "premium": True} + + return account_info + + + def getpw(self, user): + return self.accounts[user]['password'] + + + def login(self, user, data, req): + status = self.getAccountStatus(user, req) + + # Check if user and password are valid + if not status: + self.wrongPassword() + + + def getAccountStatus(self, user, req): + answer = req.load("https://www.free-way.me/ajax/jd.php", + get={"id": 4, "user": user, "pass": self.accounts[user]['password']}) + self.logDebug("Login: %s" % answer) + if answer == "Invalid login": + self.wrongPassword() + return False + return json_loads(answer) diff --git a/pyload/plugin/account/FshareVn.py b/pyload/plugin/account/FshareVn.py new file mode 100644 index 000000000..130892490 --- /dev/null +++ b/pyload/plugin/account/FshareVn.py @@ -0,0 +1,63 @@ +# -*- coding: utf-8 -*- + +from time import mktime, strptime +from pycurl import REFERER +import re + +from pyload.plugin.Account import Account + + +class FshareVn(Account): + __name = "FshareVn" + __type = "account" + __version = "0.07" + + __description = """Fshare.vn account plugin""" + __license = "GPLv3" + __authors = [("zoidberg", "zoidberg@mujmail.cz"), + ("stickell", "l.stickell@yahoo.it")] + + + VALID_UNTIL_PATTERN = ur'<dt>Thời hạn dùng:</dt>\s*<dd>([^<]+)</dd>' + LIFETIME_PATTERN = ur'<dt>Lần đăng nhập trước:</dt>\s*<dd>[^<]+</dd>' + TRAFFIC_LEFT_PATTERN = ur'<dt>Tổng Dung Lượng Tài Khoản</dt>\s*<dd[^>]*>([\d.]+) ([kKMG])B</dd>' + DIRECT_DOWNLOAD_PATTERN = ur'<input type="checkbox"\s*([^=>]*)[^>]*/>Kích hoạt download trực tiếp</dt>' + + + def loadAccountInfo(self, user, req): + html = req.load("http://www.fshare.vn/account_info.php", decode=True) + + if re.search(self.LIFETIME_PATTERN, html): + self.logDebug("Lifetime membership detected") + trafficleft = self.getTrafficLeft() + return {"validuntil": -1, "trafficleft": trafficleft, "premium": True} + + m = re.search(self.VALID_UNTIL_PATTERN, html) + if m: + premium = True + validuntil = mktime(strptime(m.group(1), '%I:%M:%S %p %d-%m-%Y')) + trafficleft = self.getTrafficLeft() + else: + premium = False + validuntil = None + trafficleft = None + + return {"validuntil": validuntil, "trafficleft": trafficleft, "premium": premium} + + + def login(self, user, data, req): + req.http.c.setopt(REFERER, "https://www.fshare.vn/login.php") + + html = req.load('https://www.fshare.vn/login.php', post={ + "login_password": data['password'], + "login_useremail": user, + "url_refe": "http://www.fshare.vn/index.php" + }, referer=True, decode=True) + + if not re.search(r'<img\s+alt="VIP"', html): + self.wrongPassword() + + + def getTrafficLeft(self): + m = re.search(self.TRAFFIC_LEFT_PATTERN, html) + return float(m.group(1)) * 1024 ** {'k': 0, 'K': 0, 'M': 1, 'G': 2}[m.group(2)] if m else 0 diff --git a/pyload/plugin/account/Ftp.py b/pyload/plugin/account/Ftp.py new file mode 100644 index 000000000..c7983b0c2 --- /dev/null +++ b/pyload/plugin/account/Ftp.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.Account import Account + + +class Ftp(Account): + __name = "Ftp" + __type = "account" + __version = "0.01" + + __description = """Ftp dummy account plugin""" + __license = "GPLv3" + __authors = [("zoidberg", "zoidberg@mujmail.cz")] + + + login_timeout = -1 #: Unlimited + info_threshold = -1 #: Unlimited diff --git a/pyload/plugin/account/HellshareCz.py b/pyload/plugin/account/HellshareCz.py new file mode 100644 index 000000000..08d45bdda --- /dev/null +++ b/pyload/plugin/account/HellshareCz.py @@ -0,0 +1,76 @@ +# -*- coding: utf-8 -*- + +import re +import time + +from pyload.plugin.Account import Account + + +class HellshareCz(Account): + __name = "HellshareCz" + __type = "account" + __version = "0.14" + + __description = """Hellshare.cz account plugin""" + __license = "GPLv3" + __authors = [("zoidberg", "zoidberg@mujmail.cz")] + + + CREDIT_LEFT_PATTERN = r'<div class="credit-link">\s*<table>\s*<tr>\s*<th>(\d+|\d\d\.\d\d\.)</th>' + + + def loadAccountInfo(self, user, req): + self.relogin(user) + html = req.load("http://www.hellshare.com/") + + m = re.search(self.CREDIT_LEFT_PATTERN, html) + if m is None: + trafficleft = None + validuntil = None + premium = False + else: + credit = m.group(1) + premium = True + try: + if "." in credit: + #Time-based account + vt = [int(x) for x in credit.split('.')[:2]] + lt = time.localtime() + year = lt.tm_year + int(vt[1] < lt.tm_mon or (vt[1] == lt.tm_mon and vt[0] < lt.tm_mday)) + validuntil = time.mktime(time.strptime("%s%d 23:59:59" % (credit, year), "%d.%m.%Y %H:%M:%S")) + trafficleft = -1 + else: + #Traffic-based account + trafficleft = int(credit) * 1024 + validuntil = -1 + except Exception, e: + self.logError(_("Unable to parse credit info"), e) + validuntil = -1 + trafficleft = -1 + + return {"validuntil": validuntil, "trafficleft": trafficleft, "premium": premium} + + + def login(self, user, data, req): + html = req.load('http://www.hellshare.com/') + if req.lastEffectiveURL != 'http://www.hellshare.com/': + #Switch to English + self.logDebug("Switch lang - URL: %s" % req.lastEffectiveURL) + json = req.load("%s?do=locRouter-show" % req.lastEffectiveURL) + hash = re.search(r"(\-\-[0-9a-f]+\-)", json).group(1) + self.logDebug("Switch lang - HASH: %s" % hash) + html = req.load('http://www.hellshare.com/%s/' % hash) + + if re.search(self.CREDIT_LEFT_PATTERN, html): + self.logDebug("Already logged in") + return + + html = req.load('http://www.hellshare.com/login?do=loginForm-submit', post={ + "login": "Log in", + "password": data['password'], + "username": user, + "perm_login": "on" + }) + + if "<p>You input a wrong user name or wrong password</p>" in html: + self.wrongPassword() diff --git a/pyload/plugin/account/Http.py b/pyload/plugin/account/Http.py new file mode 100644 index 000000000..aacdbf89f --- /dev/null +++ b/pyload/plugin/account/Http.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.Account import Account + + +class Http(Account): + __name = "Http" + __type = "account" + __version = "0.01" + + __description = """Http dummy account plugin""" + __license = "GPLv3" + __authors = [("zoidberg", "zoidberg@mujmail.cz")] + + + login_timeout = -1 #: Unlimited + info_threshold = -1 #: Unlimited diff --git a/pyload/plugin/account/HugefilesNet.py b/pyload/plugin/account/HugefilesNet.py new file mode 100644 index 000000000..b4cd6f8c4 --- /dev/null +++ b/pyload/plugin/account/HugefilesNet.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.internal.XFSAccount import XFSAccount + + +class HugefilesNet(XFSAccount): + __name = "HugefilesNet" + __type = "account" + __version = "0.02" + + __description = """Hugefiles.net account plugin""" + __license = "GPLv3" + __authors = [("Walter Purcaro", "vuolter@gmail.com")] + + + HOSTER_DOMAIN = "hugefiles.net" diff --git a/pyload/plugin/account/HundredEightyUploadCom.py b/pyload/plugin/account/HundredEightyUploadCom.py new file mode 100644 index 000000000..79af089ca --- /dev/null +++ b/pyload/plugin/account/HundredEightyUploadCom.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.internal.XFSAccount import XFSAccount + + +class HundredEightyUploadCom(XFSAccount): + __name = "HundredEightyUploadCom" + __type = "account" + __version = "0.02" + + __description = """180upload.com account plugin""" + __license = "GPLv3" + __authors = [("Walter Purcaro", "vuolter@gmail.com")] + + + HOSTER_DOMAIN = "180upload.com" diff --git a/pyload/plugin/account/JunocloudMe.py b/pyload/plugin/account/JunocloudMe.py new file mode 100644 index 000000000..75307c6dd --- /dev/null +++ b/pyload/plugin/account/JunocloudMe.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.internal.XFSAccount import XFSAccount + + +class JunocloudMe(XFSAccount): + __name = "JunocloudMe" + __type = "account" + __version = "0.02" + + __description = """Junocloud.me account plugin""" + __license = "GPLv3" + __authors = [("guidobelix", "guidobelix@hotmail.it")] + + + HOSTER_DOMAIN = "junocloud.me" diff --git a/pyload/plugin/account/Keep2shareCc.py b/pyload/plugin/account/Keep2shareCc.py new file mode 100644 index 000000000..1086d893f --- /dev/null +++ b/pyload/plugin/account/Keep2shareCc.py @@ -0,0 +1,69 @@ +# -*- coding: utf-8 -*- + +import re + +from time import gmtime, mktime, strptime + +from pyload.plugin.Account import Account + + +class Keep2shareCc(Account): + __name = "Keep2shareCc" + __type = "account" + __version = "0.02" + + __description = """Keep2share.cc account plugin""" + __license = "GPLv3" + __authors = [("aeronaut", "aeronaut@pianoguy.de")] + + + VALID_UNTIL_PATTERN = r'Premium expires: <b>(.+?)</b>' + TRAFFIC_LEFT_PATTERN = r'Available traffic \(today\):<b><a href="/user/statistic.html">(.+?)</a>' + + LOGIN_FAIL_PATTERN = r'Please fix the following input errors' + + + def loadAccountInfo(self, user, req): + validuntil = None + trafficleft = None + premium = None + + html = req.load("http://keep2share.cc/site/profile.html", decode=True) + + m = re.search(self.VALID_UNTIL_PATTERN, html) + if m: + expiredate = m.group(1).strip() + self.logDebug("Expire date: " + expiredate) + + try: + validuntil = mktime(strptime(expiredate, "%Y.%m.%d")) + + except Exception, e: + self.logError(e) + + else: + if validuntil > mktime(gmtime()): + premium = True + else: + premium = False + validuntil = None + + m = re.search(self.TRAFFIC_LEFT_PATTERN, html) + if m: + try: + trafficleft = self.parseTraffic(m.group(1)) + + except Exception, e: + self.logError(e) + + return {'validuntil': validuntil, 'trafficleft': trafficleft, 'premium': premium} + + + def login(self, user, data, req): + req.cj.setCookie("keep2share.cc", "lang", "en") + + html = req.load("http://keep2share.cc/login.html", + post={'LoginForm[username]': user, 'LoginForm[password]': data['password']}) + + if re.search(self.LOGIN_FAIL_PATTERN, html): + self.wrongPassword() diff --git a/pyload/plugin/account/LetitbitNet.py b/pyload/plugin/account/LetitbitNet.py new file mode 100644 index 000000000..b014268ae --- /dev/null +++ b/pyload/plugin/account/LetitbitNet.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.Account import Account +# from pyload.utils import json_loads, json_dumps + + +class LetitbitNet(Account): + __name = "LetitbitNet" + __type = "account" + __version = "0.01" + + __description = """Letitbit.net account plugin""" + __license = "GPLv3" + __authors = [("stickell", "l.stickell@yahoo.it")] + + + def loadAccountInfo(self, user, req): + ## DISABLED BECAUSE IT GET 'key exausted' EVEN IF VALID ## + # api_key = self.accounts[user]['password'] + # json_data = [api_key, ['key/info']] + # api_rep = req.load('http://api.letitbit.net/json', post={'r': json_dumps(json_data)}) + # self.logDebug("API Key Info: " + api_rep) + # api_rep = json_loads(api_rep) + # + # if api_rep['status'] == 'FAIL': + # self.logWarning(api_rep['data']) + # return {'valid': False, 'premium': False} + + return {"premium": True} + + + def login(self, user, data, req): + # API_KEY is the username and the PREMIUM_KEY is the password + self.logInfo(_("You must use your API KEY as username and the PREMIUM KEY as password")) diff --git a/pyload/plugin/account/LinestorageCom.py b/pyload/plugin/account/LinestorageCom.py new file mode 100644 index 000000000..353c1e811 --- /dev/null +++ b/pyload/plugin/account/LinestorageCom.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.internal.XFSAccount import XFSAccount + + +class LinestorageCom(XFSAccount): + __name = "LinestorageCom" + __type = "account" + __version = "0.02" + + __description = """Linestorage.com account plugin""" + __license = "GPLv3" + __authors = [("Walter Purcaro", "vuolter@gmail.com")] + + + HOSTER_DOMAIN = "linestorage.com" diff --git a/pyload/plugin/account/LinksnappyCom.py b/pyload/plugin/account/LinksnappyCom.py new file mode 100644 index 000000000..a510a59ea --- /dev/null +++ b/pyload/plugin/account/LinksnappyCom.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- + +from hashlib import md5 + +from pyload.plugin.Account import Account +from pyload.utils import json_loads + + +class LinksnappyCom(Account): + __name = "LinksnappyCom" + __type = "account" + __version = "0.02" + + __description = """Linksnappy.com account plugin""" + __license = "GPLv3" + __authors = [("stickell", "l.stickell@yahoo.it")] + + + def loadAccountInfo(self, user, req): + data = self.getAccountData(user) + r = req.load('http://gen.linksnappy.com/lseAPI.php', + get={'act': 'USERDETAILS', 'username': user, 'password': md5(data['password']).hexdigest()}) + self.logDebug("JSON data: " + r) + j = json_loads(r) + + if j['error']: + return {"premium": False} + + validuntil = j['return']['expire'] + if validuntil == 'lifetime': + validuntil = -1 + elif validuntil == 'expired': + return {"premium": False} + else: + validuntil = float(validuntil) + + if 'trafficleft' not in j['return'] or isinstance(j['return']['trafficleft'], str): + trafficleft = -1 + else: + trafficleft = int(j['return']['trafficleft']) * 1024 + + return {"premium": True, "validuntil": validuntil, "trafficleft": trafficleft} + + + def login(self, user, data, req): + r = req.load('http://gen.linksnappy.com/lseAPI.php', + get={'act': 'USERDETAILS', 'username': user, 'password': md5(data['password']).hexdigest()}) + + if 'Invalid Account Details' in r: + self.wrongPassword() diff --git a/pyload/plugin/account/LomafileCom.py b/pyload/plugin/account/LomafileCom.py new file mode 100644 index 000000000..c55c9538d --- /dev/null +++ b/pyload/plugin/account/LomafileCom.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.internal.XFSAccount import XFSAccount + + +class LomafileCom(XFSAccount): + __name = "LomafileCom" + __type = "account" + __version = "0.02" + + __description = """Lomafile.com account plugin""" + __license = "GPLv3" + __authors = [("guidobelix", "guidobelix@hotmail.it")] + + + HOSTER_DOMAIN = "lomafile.com" diff --git a/pyload/plugin/account/MegaDebridEu.py b/pyload/plugin/account/MegaDebridEu.py new file mode 100644 index 000000000..67af94541 --- /dev/null +++ b/pyload/plugin/account/MegaDebridEu.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.Account import Account +from pyload.utils import json_loads + + +class MegaDebridEu(Account): + __name = "MegaDebridEu" + __type = "account" + __version = "0.20" + + __description = """mega-debrid.eu account plugin""" + __license = "GPLv3" + __authors = [("D.Ducatel", "dducatel@je-geek.fr")] + + + # Define the base URL of MegaDebrid api + API_URL = "https://www.mega-debrid.eu/api.php" + + + def loadAccountInfo(self, user, req): + data = self.getAccountData(user) + jsonResponse = req.load(self.API_URL, + get={'action': 'connectUser', 'login': user, 'password': data['password']}) + res = json_loads(jsonResponse) + + if res['response_code'] == "ok": + return {"premium": True, "validuntil": float(res['vip_end']), "status": True} + else: + self.logError(res) + return {"status": False, "premium": False} + + + def login(self, user, data, req): + jsonResponse = req.load(self.API_URL, + get={'action': 'connectUser', 'login': user, 'password': data['password']}) + res = json_loads(jsonResponse) + if res['response_code'] != "ok": + self.wrongPassword() diff --git a/pyload/plugin/account/MegaRapidCz.py b/pyload/plugin/account/MegaRapidCz.py new file mode 100644 index 000000000..9e9f5cb02 --- /dev/null +++ b/pyload/plugin/account/MegaRapidCz.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- + +import re + +from time import mktime, strptime +from pyload.plugin.Account import Account + + +class MegaRapidCz(Account): + __name = "MegaRapidCz" + __type = "account" + __version = "0.34" + + __description = """MegaRapid.cz account plugin""" + __license = "GPLv3" + __authors = [("MikyWoW", "mikywow@seznam.cz"), + ("zoidberg", "zoidberg@mujmail.cz")] + + + login_timeout = 60 + + LIMITDL_PATTERN = ur'<td>Max. počet paralelních stahování: </td><td>(\d+)' + VALID_UNTIL_PATTERN = ur'<td>Paušální stahování aktivní. Vyprší </td><td><strong>(.*?)</strong>' + TRAFFIC_LEFT_PATTERN = r'<tr><td>Kredit</td><td>(.*?) GiB' + + + def loadAccountInfo(self, user, req): + html = req.load("http://megarapid.cz/mujucet/", decode=True) + + m = re.search(self.LIMITDL_PATTERN, html) + if m: + data = self.getAccountData(user) + data['options']['limitDL'] = [int(m.group(1))] + + m = re.search(self.VALID_UNTIL_PATTERN, html) + if m: + validuntil = mktime(strptime(m.group(1), "%d.%m.%Y - %H:%M")) + return {"premium": True, "trafficleft": -1, "validuntil": validuntil} + + m = re.search(self.TRAFFIC_LEFT_PATTERN, html) + if m: + trafficleft = float(m.group(1)) * (1 << 20) + return {"premium": True, "trafficleft": trafficleft, "validuntil": -1} + + return {"premium": False, "trafficleft": None, "validuntil": None} + + + def login(self, user, data, req): + htm = req.load("http://megarapid.cz/prihlaseni/") + if "Heslo:" in htm: + start = htm.index('id="inp_hash" name="hash" value="') + htm = htm[start + 33:] + hashes = htm[0:32] + htm = req.load("http://megarapid.cz/prihlaseni/", + post={"hash": hashes, + "login": user, + "pass1": data['password'], + "remember": 0, + "sbmt": u"Přihlásit"}) diff --git a/pyload/plugin/account/MegasharesCom.py b/pyload/plugin/account/MegasharesCom.py new file mode 100644 index 000000000..95df5ad2d --- /dev/null +++ b/pyload/plugin/account/MegasharesCom.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- + +import re +from time import mktime, strptime + +from pyload.plugin.Account import Account + + +class MegasharesCom(Account): + __name = "MegasharesCom" + __type = "account" + __version = "0.02" + + __description = """Megashares.com account plugin""" + __license = "GPLv3" + __authors = [("zoidberg", "zoidberg@mujmail.cz")] + + + VALID_UNTIL_PATTERN = r'<p class="premium_info_box">Period Ends: (\w{3} \d{1,2}, \d{4})</p>' + + + def loadAccountInfo(self, user, req): + #self.relogin(user) + html = req.load("http://d01.megashares.com/myms.php", decode=True) + + premium = False if '>Premium Upgrade<' in html else True + + validuntil = trafficleft = -1 + try: + timestr = re.search(self.VALID_UNTIL_PATTERN, html).group(1) + self.logDebug(timestr) + validuntil = mktime(strptime(timestr, "%b %d, %Y")) + except Exception, e: + self.logError(e) + + return {"validuntil": validuntil, "trafficleft": -1, "premium": premium} + + + def login(self, user, data, req): + html = req.load('http://d01.megashares.com/myms_login.php', post={ + "httpref": "", + "myms_login": "Login", + "mymslogin_name": user, + "mymspassword": data['password'] + }, decode=True) + + if not '<span class="b ml">%s</span>' % user in html: + self.wrongPassword() diff --git a/pyload/plugin/account/MovReelCom.py b/pyload/plugin/account/MovReelCom.py new file mode 100644 index 000000000..9eabd0a6d --- /dev/null +++ b/pyload/plugin/account/MovReelCom.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.internal.XFSAccount import XFSAccount + + +class MovReelCom(XFSAccount): + __name = "MovReelCom" + __type = "account" + __version = "0.03" + + __description = """Movreel.com account plugin""" + __license = "GPLv3" + __authors = [("t4skforce", "t4skforce1337[AT]gmail[DOT]com")] + + + login_timeout = 60 + info_threshold = 30 + + HOSTER_DOMAIN = "movreel.com" diff --git a/pyload/plugin/account/MultishareCz.py b/pyload/plugin/account/MultishareCz.py new file mode 100644 index 000000000..2f9b285b2 --- /dev/null +++ b/pyload/plugin/account/MultishareCz.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- + +import re + +from pyload.plugin.Account import Account + + +class MultishareCz(Account): + __name = "MultishareCz" + __type = "account" + __version = "0.03" + + __description = """Multishare.cz account plugin""" + __license = "GPLv3" + __authors = [("zoidberg", "zoidberg@mujmail.cz")] + + + TRAFFIC_LEFT_PATTERN = r'<span class="profil-zvyrazneni">Kredit:</span>\s*<strong>(?P<S>[\d.,]+) (?P<U>[\w^_]+)</strong>' + ACCOUNT_INFO_PATTERN = r'<input type="hidden" id="(u_ID|u_hash)" name="[^"]*" value="([^"]+)">' + + + def loadAccountInfo(self, user, req): + #self.relogin(user) + html = req.load("http://www.multishare.cz/profil/", decode=True) + + m = re.search(self.TRAFFIC_LEFT_PATTERN, html) + trafficleft = self.parseTraffic(m.group('S'), m.group('U')) if m else 0 + self.premium = True if trafficleft else False + + html = req.load("http://www.multishare.cz/", decode=True) + mms_info = dict(re.findall(self.ACCOUNT_INFO_PATTERN, html)) + + return dict(mms_info, **{"validuntil": -1, "trafficleft": trafficleft}) + + + def login(self, user, data, req): + html = req.load('http://www.multishare.cz/html/prihlaseni_process.php', post={ + "akce": "Přihlásit", + "heslo": data['password'], + "jmeno": user + }, decode=True) + + if '<div class="akce-chyba akce">' in html: + self.wrongPassword() diff --git a/pyload/plugin/account/MyfastfileCom.py b/pyload/plugin/account/MyfastfileCom.py new file mode 100644 index 000000000..4e85c1a34 --- /dev/null +++ b/pyload/plugin/account/MyfastfileCom.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- + +from time import time + +from pyload.plugin.Account import Account +from pyload.utils import json_loads + + +class MyfastfileCom(Account): + __name = "MyfastfileCom" + __type = "account" + __version = "0.02" + + __description = """Myfastfile.com account plugin""" + __license = "GPLv3" + __authors = [("stickell", "l.stickell@yahoo.it")] + + + def loadAccountInfo(self, user, req): + if 'days_left' in self.json_data: + validuntil = int(time() + self.json_data['days_left'] * 24 * 60 * 60) + return {"premium": True, "validuntil": validuntil, "trafficleft": -1} + else: + self.logError(_("Unable to get account information")) + + + def login(self, user, data, req): + # Password to use is the API-Password written in http://myfastfile.com/myaccount + html = req.load("http://myfastfile.com/api.php", + get={"user": user, "pass": data['password']}) + self.logDebug("JSON data: " + html) + self.json_data = json_loads(html) + if self.json_data['status'] != 'ok': + self.logError(_('Invalid login. The password to use is the API-Password you find in your "My Account" page')) + self.wrongPassword() diff --git a/pyload/plugin/account/NetloadIn.py b/pyload/plugin/account/NetloadIn.py new file mode 100644 index 000000000..4cfc205ca --- /dev/null +++ b/pyload/plugin/account/NetloadIn.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- + +import re +from time import time + +from pyload.plugin.Account import Account + + +class NetloadIn(Account): + __name = "NetloadIn" + __type = "account" + __version = "0.22" + + __description = """Netload.in account plugin""" + __license = "GPLv3" + __authors = [("RaNaN", "RaNaN@pyload.org"), + ("CryNickSystems", "webmaster@pcProfil.de")] + + + def loadAccountInfo(self, user, req): + page = req.load("http://netload.in/index.php", get={'id': 2, 'lang': "de"}) + left = r'>(\d+) (Tag|Tage), (\d+) Stunden<' + left = re.search(left, page) + if left: + validuntil = time() + int(left.group(1)) * 24 * 60 * 60 + int(left.group(3)) * 60 * 60 + trafficleft = -1 + premium = True + else: + validuntil = None + premium = False + trafficleft = None + return {"validuntil": validuntil, "trafficleft": trafficleft, "premium": premium} + + + def login(self, user, data, req): + page = req.load("http://netload.in/index.php", None, + {"txtuser": user, "txtpass": data['password'], "txtcheck": "login", "txtlogin": "Login"}, + cookies=True) + if "password or it might be invalid!" in page: + self.wrongPassword() diff --git a/pyload/plugin/account/NosuploadCom.py b/pyload/plugin/account/NosuploadCom.py new file mode 100644 index 000000000..10f9007a6 --- /dev/null +++ b/pyload/plugin/account/NosuploadCom.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.internal.XFSAccount import XFSAccount + + +class NosuploadCom(XFSAccount): + __name = "NosuploadCom" + __type = "account" + __version = "0.02" + + __description = """Nosupload.com account plugin""" + __license = "GPLv3" + __authors = [("Walter Purcaro", "vuolter@gmail.com")] + + + HOSTER_DOMAIN = "nosupload.com" diff --git a/pyload/plugin/account/NovafileCom.py b/pyload/plugin/account/NovafileCom.py new file mode 100644 index 000000000..8400cc267 --- /dev/null +++ b/pyload/plugin/account/NovafileCom.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.internal.XFSAccount import XFSAccount + + +class NovafileCom(XFSAccount): + __name = "NovafileCom" + __type = "account" + __version = "0.02" + + __description = """Novafile.com account plugin""" + __license = "GPLv3" + __authors = [("Walter Purcaro", "vuolter@gmail.com")] + + + HOSTER_DOMAIN = "novafile.com" diff --git a/pyload/plugin/account/NowVideoAt.py b/pyload/plugin/account/NowVideoAt.py new file mode 100644 index 000000000..84cec8974 --- /dev/null +++ b/pyload/plugin/account/NowVideoAt.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- + +import re + +from time import gmtime, mktime, strptime + +from pyload.plugin.Account import Account + + +class NowVideoAt(Account): + __name = "NowVideoAt" + __type = "account" + __version = "0.01" + + __description = """NowVideo.at account plugin""" + __license = "GPLv3" + __authors = [("Walter Purcaro", "vuolter@gmail.com")] + + + VALID_UNTIL_PATTERN = r'>Your premium membership expires on: (.+?)<' + + + def loadAccountInfo(self, user, req): + validuntil = None + trafficleft = -1 + premium = None + + html = req.load("http://www.nowvideo.at/premium.php") + + m = re.search(self.VALID_UNTIL_PATTERN, html) + if m: + expiredate = m.group(1).strip() + self.logDebug("Expire date: " + expiredate) + + try: + validuntil = mktime(strptime(expiredate, "%Y-%b-%d")) + + except Exception, e: + self.logError(e) + + else: + if validuntil > mktime(gmtime()): + premium = True + else: + premium = False + validuntil = -1 + + return {"validuntil": validuntil, "trafficleft": trafficleft, "premium": premium} + + + def login(self, user, data, req): + html = req.load("http://www.nowvideo.at/login.php", + post={'user': user, 'pass': data['password']}) + + if ">Invalid login details" is html: + self.wrongPassword() diff --git a/pyload/plugin/account/OboomCom.py b/pyload/plugin/account/OboomCom.py new file mode 100644 index 000000000..cfb4e3e7e --- /dev/null +++ b/pyload/plugin/account/OboomCom.py @@ -0,0 +1,62 @@ +# -*- coding: utf-8 -*- + +import time + +from beaker.crypto.pbkdf2 import PBKDF2 + +from pyload.utils import json_loads +from pyload.plugin.Account import Account + + +class OboomCom(Account): + __name = "OboomCom" + __type = "account" + __version = "0.21" + + __description = """Oboom.com account plugin""" + __license = "GPLv3" + __authors = [("stanley", "stanley.foerster@gmail.com")] + + + def loadAccountData(self, user, req): + passwd = self.getAccountData(user)['password'] + salt = passwd[::-1] + pbkdf2 = PBKDF2(passwd, salt, 1000).hexread(16) + result = json_loads(req.load("https://www.oboom.com/1/login", get={"auth": user, "pass": pbkdf2})) + if not result[0] == 200: + self.logWarning(_("Failed to log in: %s") % result[1]) + self.wrongPassword() + return result[1] + + + def loadAccountInfo(self, name, req): + accountData = self.loadAccountData(name, req) + + userData = accountData['user'] + + if userData['premium'] == "null": + premium = False + else: + premium = True + + if userData['premium_unix'] == "null": + validUntil = -1 + else: + validUntil = int(userData['premium_unix']) + + traffic = userData['traffic'] + + trafficLeft = traffic['current'] + maxTraffic = traffic['max'] + + session = accountData['session'] + + return {'premium' : premium, + 'validuntil' : validUntil, + 'trafficleft': trafficLeft / 1024, #@TODO: Remove / 1024 in 0.4.10 + 'maxtraffic' : maxTraffic / 1024, #@TODO: Remove / 1024 in 0.4.10 + 'session' : session} + + + def login(self, user, data, req): + self.loadAccountData(user, req) diff --git a/pyload/plugin/account/OneFichierCom.py b/pyload/plugin/account/OneFichierCom.py new file mode 100644 index 000000000..7ecd5769e --- /dev/null +++ b/pyload/plugin/account/OneFichierCom.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- + +import re + +from time import strptime, mktime + +from pycurl import REFERER + +from pyload.plugin.Account import Account + + +class OneFichierCom(Account): + __name = "OneFichierCom" + __type = "account" + __version = "0.11" + + __description = """1fichier.com account plugin""" + __license = "GPLv3" + __authors = [("Elrick69", "elrick69[AT]rocketmail[DOT]com"), + ("Walter Purcaro", "vuolter@gmail.com")] + + + VALID_UNTIL_PATTERN = r'Your Premium Status will end the (\d+/\d+/\d+)' + + + def loadAccountInfo(self, user, req): + validuntil = None + trafficleft = -1 + premium = None + + html = req.load("https://1fichier.com/console/abo.pl") + + m = re.search(self.VALID_UNTIL_PATTERN, html) + if m: + expiredate = m.group(1) + self.logDebug("Expire date: " + expiredate) + + try: + validuntil = mktime(strptime(expiredate, "%d/%m/%Y")) + except Exception, e: + self.logError(e) + else: + premium = True + + return {'validuntil': validuntil, 'trafficleft': trafficleft, 'premium': premium or False} + + + def login(self, user, data, req): + req.http.c.setopt(REFERER, "https://1fichier.com/login.pl?lg=en") + + html = req.load("https://1fichier.com/login.pl?lg=en", + post={'mail': user, 'pass': data['password'], 'It': "on", 'purge': "off", 'valider': "Send"}) + + if '>Invalid email address' in html or '>Invalid password' in html: + self.wrongPassword() diff --git a/pyload/plugin/account/OverLoadMe.py b/pyload/plugin/account/OverLoadMe.py new file mode 100644 index 000000000..55dbfd1bb --- /dev/null +++ b/pyload/plugin/account/OverLoadMe.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.Account import Account +from pyload.utils import json_loads + + +class OverLoadMe(Account): + __name = "OverLoadMe" + __type = "account" + __version = "0.01" + + __description = """Over-Load.me account plugin""" + __license = "GPLv3" + __authors = [("marley", "marley@over-load.me")] + + + def loadAccountInfo(self, user, req): + data = self.getAccountData(user) + page = req.load("https://api.over-load.me/account.php", get={"user": user, "auth": data['password']}).strip() + data = json_loads(page) + + # Check for premium + if data['membership'] == "Free": + return {"premium": False} + + account_info = {"validuntil": data['expirationunix'], "trafficleft": -1} + return account_info + + + def login(self, user, data, req): + jsondata = req.load("https://api.over-load.me/account.php", + get={"user": user, "auth": data['password']}).strip() + data = json_loads(jsondata) + + if data['err'] == 1: + self.wrongPassword() diff --git a/pyload/plugin/account/PremiumTo.py b/pyload/plugin/account/PremiumTo.py new file mode 100644 index 000000000..2fe95b135 --- /dev/null +++ b/pyload/plugin/account/PremiumTo.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.Account import Account + + +class PremiumTo(Account): + __name = "PremiumTo" + __type = "account" + __version = "0.04" + + __description = """Premium.to account plugin""" + __license = "GPLv3" + __authors = [("RaNaN", "RaNaN@pyload.org"), + ("zoidberg", "zoidberg@mujmail.cz"), + ("stickell", "l.stickell@yahoo.it")] + + + + def loadAccountInfo(self, user, req): + api_r = req.load("http://premium.to/api/straffic.php", + get={'username': self.username, 'password': self.password}) + traffic = sum(map(int, api_r.split(';'))) + + return {"trafficleft": int(traffic) / 1024, "validuntil": -1} #@TODO: Remove / 1024 in 0.4.10 + + + def login(self, user, data, req): + self.username = user + self.password = data['password'] + authcode = req.load("http://premium.to/api/getauthcode.php", + get={'username': user, 'password': self.password}).strip() + + if "wrong username" in authcode: + self.wrongPassword() diff --git a/pyload/plugin/account/PremiumizeMe.py b/pyload/plugin/account/PremiumizeMe.py new file mode 100644 index 000000000..9ad728bf7 --- /dev/null +++ b/pyload/plugin/account/PremiumizeMe.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.Account import Account + +from pyload.utils import json_loads + + +class PremiumizeMe(Account): + __name = "PremiumizeMe" + __type = "account" + __version = "0.11" + + __description = """Premiumize.me account plugin""" + __license = "GPLv3" + __authors = [("Florian Franzen", "FlorianFranzen@gmail.com")] + + + def loadAccountInfo(self, user, req): + # Get user data from premiumize.me + status = self.getAccountStatus(user, req) + self.logDebug(status) + + # Parse account info + account_info = {"validuntil": float(status['result']['expires']), + "trafficleft": max(0, status['result']['trafficleft_bytes'])} + + if status['result']['type'] == 'free': + account_info['premium'] = False + + return account_info + + + def login(self, user, data, req): + # Get user data from premiumize.me + status = self.getAccountStatus(user, req) + + # Check if user and password are valid + if status['status'] != 200: + self.wrongPassword() + + + def getAccountStatus(self, user, req): + # Use premiumize.me API v1 (see https://secure.premiumize.me/?show=api) + # to retrieve account info and return the parsed json answer + answer = req.load("https://api.premiumize.me/pm-api/v1.php", + get={'method' : "accountstatus", + 'params[login]': user, + 'params[pass]' : self.accounts[user]['password']}) + return json_loads(answer) diff --git a/pyload/plugin/account/QuickshareCz.py b/pyload/plugin/account/QuickshareCz.py new file mode 100644 index 000000000..216bf62f2 --- /dev/null +++ b/pyload/plugin/account/QuickshareCz.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- + +import re + +from pyload.plugin.Account import Account + + +class QuickshareCz(Account): + __name = "QuickshareCz" + __type = "account" + __version = "0.02" + + __description = """Quickshare.cz account plugin""" + __license = "GPLv3" + __authors = [("zoidberg", "zoidberg@mujmail.cz")] + + + TRAFFIC_LEFT_PATTERN = r'Stav kreditu: <strong>(.+?)</strong>' + + + def loadAccountInfo(self, user, req): + html = req.load("http://www.quickshare.cz/premium", decode=True) + + m = re.search(self.TRAFFIC_LEFT_PATTERN, html) + if m: + trafficleft = self.parseTraffic(m.group(1)) + premium = True if trafficleft else False + else: + trafficleft = None + premium = False + + return {"validuntil": -1, "trafficleft": trafficleft, "premium": premium} + + + def login(self, user, data, req): + html = req.load('http://www.quickshare.cz/html/prihlaseni_process.php', post={ + "akce": u'Přihlásit', + "heslo": data['password'], + "jmeno": user + }, decode=True) + + if u'>Takový uživatel neexistuje.<' in html or u'>Špatné heslo.<' in html: + self.wrongPassword() diff --git a/pyload/plugin/account/RPNetBiz.py b/pyload/plugin/account/RPNetBiz.py new file mode 100644 index 000000000..fe18e06c9 --- /dev/null +++ b/pyload/plugin/account/RPNetBiz.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.Account import Account +from pyload.utils import json_loads + + +class RPNetBiz(Account): + __name = "RPNetBiz" + __type = "account" + __version = "0.10" + + __description = """RPNet.biz account plugin""" + __license = "GPLv3" + __authors = [("Dman", "dmanugm@gmail.com")] + + + def loadAccountInfo(self, user, req): + # Get account information from rpnet.biz + res = self.getAccountStatus(user, req) + try: + if res['accountInfo']['isPremium']: + # Parse account info. Change the trafficleft later to support per host info. + account_info = {"validuntil": int(res['accountInfo']['premiumExpiry']), + "trafficleft": -1, "premium": True} + else: + account_info = {"validuntil": None, "trafficleft": None, "premium": False} + + except KeyError: + #handle wrong password exception + account_info = {"validuntil": None, "trafficleft": None, "premium": False} + + return account_info + + + def login(self, user, data, req): + # Get account information from rpnet.biz + res = self.getAccountStatus(user, req) + + # If we have an error in the res, we have wrong login information + if 'error' in res: + self.wrongPassword() + + + def getAccountStatus(self, user, req): + # Using the rpnet API, check if valid premium account + res = req.load("https://premium.rpnet.biz/client_api.php", + get={"username": user, "password": self.accounts[user]['password'], + "action": "showAccountInformation"}) + self.logDebug("JSON data: %s" % res) + + return json_loads(res) diff --git a/pyload/plugin/account/RapidfileshareNet.py b/pyload/plugin/account/RapidfileshareNet.py new file mode 100644 index 000000000..0b0ed210c --- /dev/null +++ b/pyload/plugin/account/RapidfileshareNet.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.internal.XFSAccount import XFSAccount + + +class RapidfileshareNet(XFSAccount): + __name = "RapidfileshareNet" + __type = "account" + __version = "0.05" + + __description = """Rapidfileshare.net account plugin""" + __license = "GPLv3" + __authors = [("guidobelix", "guidobelix@hotmail.it")] + + + HOSTER_DOMAIN = "rapidfileshare.net" + + TRAFFIC_LEFT_PATTERN = r'>Traffic available today:</TD><TD><label for="name">\s*(?P<S>[\d.,]+)\s*(?:(?P<U>[\w^_]+))?' diff --git a/pyload/plugin/account/RapidgatorNet.py b/pyload/plugin/account/RapidgatorNet.py new file mode 100644 index 000000000..66fe13f90 --- /dev/null +++ b/pyload/plugin/account/RapidgatorNet.py @@ -0,0 +1,58 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.Account import Account +from pyload.utils import json_loads + + +class RapidgatorNet(Account): + __name = "RapidgatorNet" + __type = "account" + __version = "0.04" + + __description = """Rapidgator.net account plugin""" + __license = "GPLv3" + __authors = [("zoidberg", "zoidberg@mujmail.cz")] + + + API_URL = 'http://rapidgator.net/api/user' + + + def loadAccountInfo(self, user, req): + try: + sid = self.getAccountData(user).get('SID') + assert sid + + json = req.load("%s/info?sid=%s" % (self.API_URL, sid)) + self.logDebug("API:USERINFO", json) + json = json_loads(json) + + if json['response_status'] == 200: + if "reset_in" in json['response']: + self.scheduleRefresh(user, json['response']['reset_in']) + + return {"validuntil": json['response']['expire_date'], + "trafficleft": int(json['response']['traffic_left']), + "premium": True} + else: + self.logError(json['response_details']) + except Exception, e: + self.logError(e) + + return {"validuntil": None, "trafficleft": None, "premium": False} + + + def login(self, user, data, req): + try: + json = req.load('%s/login' % self.API_URL, post={"username": user, "password": data['password']}) + self.logDebug("API:LOGIN", json) + json = json_loads(json) + + if json['response_status'] == 200: + data['SID'] = str(json['response']['session_id']) + return + else: + self.logError(json['response_details']) + except Exception, e: + self.logError(e) + + self.wrongPassword() diff --git a/pyload/plugin/account/RapiduNet.py b/pyload/plugin/account/RapiduNet.py new file mode 100644 index 000000000..dfb18d2c7 --- /dev/null +++ b/pyload/plugin/account/RapiduNet.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- + +import re + +from pyload.plugin.Account import Account +from pyload.utils import json_loads + + +class RapiduNet(Account): + __name = "RapiduNet" + __type = "account" + __version = "0.02" + + __description = """Rapidu.net account plugin""" + __license = "GPLv3" + __authors = [("prOq", "")] + + + PREMIUM_PATTERN = r'<a href="premium/" style="padding-left: 0px;">Account: <b>Premium</b></a>' + + + def loadAccountInfo(self, user, req): + info = {'validuntil': None, 'trafficleft': None, 'premium': False} + + req.load("https://rapidu.net/ajax.php", get={'a': "getChangeLang"}, post={"_go": "", "lang": "en"}) + html = req.load("https://rapidu.net/", decode=True) + + if re.search(self.PREMIUM_PATTERN, html): + info['premium'] = True + + return info + + + def login(self, user, data, req): + try: + json = json_loads(req.load("https://rapidu.net/ajax.php?a=getUserLogin", + post={'_go': "", + 'login': user, + 'pass': data['password'], + 'member': "1"})) + + self.logDebug(json) + + if not json['message'] == "success": + self.wrongPassword() + + except Exception, e: + self.logError(e) diff --git a/pyload/plugin/account/RarefileNet.py b/pyload/plugin/account/RarefileNet.py new file mode 100644 index 000000000..fc736bafc --- /dev/null +++ b/pyload/plugin/account/RarefileNet.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.internal.XFSAccount import XFSAccount + + +class RarefileNet(XFSAccount): + __name = "RarefileNet" + __type = "account" + __version = "0.04" + + __description = """RareFile.net account plugin""" + __license = "GPLv3" + __authors = [("zoidberg", "zoidberg@mujmail.cz")] + + + HOSTER_DOMAIN = "rarefile.net" diff --git a/pyload/plugin/account/RealdebridCom.py b/pyload/plugin/account/RealdebridCom.py new file mode 100644 index 000000000..c604fb108 --- /dev/null +++ b/pyload/plugin/account/RealdebridCom.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- + +import xml.dom.minidom as dom + +from pyload.plugin.Account import Account + + +class RealdebridCom(Account): + __name = "RealdebridCom" + __type = "account" + __version = "0.43" + + __description = """Real-Debrid.com account plugin""" + __license = "GPLv3" + __authors = [("Devirex Hazzard", "naibaf_11@yahoo.de")] + + + def loadAccountInfo(self, user, req): + if self.pin_code: + return {"premium": False} + page = req.load("https://real-debrid.com/api/account.php") + xml = dom.parseString(page) + account_info = {"validuntil": int(xml.getElementsByTagName("expiration")[0].childNodes[0].nodeValue), + "trafficleft": -1} + + return account_info + + + def login(self, user, data, req): + self.pin_code = False + page = req.load("https://real-debrid.com/ajax/login.php", get={"user": user, "pass": data['password']}) + if "Your login informations are incorrect" in page: + self.wrongPassword() + elif "PIN Code required" in page: + self.logWarning(_("PIN code required. Please login to https://real-debrid.com using the PIN or disable the double authentication in your control panel on https://real-debrid.com")) + self.pin_code = True diff --git a/pyload/plugin/account/RehostTo.py b/pyload/plugin/account/RehostTo.py new file mode 100644 index 000000000..956982186 --- /dev/null +++ b/pyload/plugin/account/RehostTo.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.Account import Account + + +class RehostTo(Account): + __name = "RehostTo" + __type = "account" + __version = "0.10" + + __description = """Rehost.to account plugin""" + __license = "GPLv3" + __authors = [("RaNaN", "RaNaN@pyload.org")] + + + def loadAccountInfo(self, user, req): + data = self.getAccountData(user) + page = req.load("http://rehost.to/api.php", + get={'cmd': "login", 'user': user, 'pass': data['password']}) + data = [x.split("=") for x in page.split(",")] + ses = data[0][1] + long_ses = data[1][1] + + page = req.load("http://rehost.to/api.php", + get={'cmd': "get_premium_credits", 'long_ses': long_ses}) + traffic, valid = page.split(",") + + account_info = {"trafficleft": int(traffic) * 1024, + "validuntil": int(valid), + "long_ses": long_ses, + "ses": ses} + + return account_info + + + def login(self, user, data, req): + page = req.load("http://rehost.to/api.php", + get={'cmd': "login", 'user': user, 'pass': data['password']}) + + if "Login failed." in page: + self.wrongPassword() diff --git a/pyload/plugin/account/RyushareCom.py b/pyload/plugin/account/RyushareCom.py new file mode 100644 index 000000000..d908e6442 --- /dev/null +++ b/pyload/plugin/account/RyushareCom.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.internal.XFSAccount import XFSAccount + + +class RyushareCom(XFSAccount): + __name = "RyushareCom" + __type = "account" + __version = "0.05" + + __description = """Ryushare.com account plugin""" + __license = "GPLv3" + __authors = [("zoidberg", "zoidberg@mujmail.cz"), + ("trance4us", "")] + + + HOSTER_DOMAIN = "ryushare.com" + + + def login(self, user, data, req): + req.lastURL = "http://ryushare.com/login.python" + html = req.load("http://ryushare.com/login.python", + post={"login": user, "password": data['password'], "op": "login"}) + if 'Incorrect Login or Password' in html or '>Error<' in html: + self.wrongPassword() diff --git a/pyload/plugin/account/SafesharingEu.py b/pyload/plugin/account/SafesharingEu.py new file mode 100644 index 000000000..eae8140fb --- /dev/null +++ b/pyload/plugin/account/SafesharingEu.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.internal.XFSAccount import XFSAccount + + +class SafesharingEu(XFSAccount): + __name = "SafesharingEu" + __type = "account" + __version = "0.02" + + __description = """Safesharing.eu account plugin""" + __license = "GPLv3" + __authors = [("guidobelix", "guidobelix@hotmail.it")] + + + HOSTER_DOMAIN = "safesharing.eu" diff --git a/pyload/plugin/account/SecureUploadEu.py b/pyload/plugin/account/SecureUploadEu.py new file mode 100644 index 000000000..b349e893f --- /dev/null +++ b/pyload/plugin/account/SecureUploadEu.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.internal.XFSAccount import XFSAccount + + +class SecureUploadEu(XFSAccount): + __name = "SecureUploadEu" + __type = "account" + __version = "0.02" + + __description = """SecureUpload.eu account plugin""" + __license = "GPLv3" + __authors = [("Walter Purcaro", "vuolter@gmail.com")] + + + HOSTER_DOMAIN = "secureupload.eu" diff --git a/pyload/plugin/account/SendmywayCom.py b/pyload/plugin/account/SendmywayCom.py new file mode 100644 index 000000000..add0b2183 --- /dev/null +++ b/pyload/plugin/account/SendmywayCom.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.internal.XFSAccount import XFSAccount + + +class SendmywayCom(XFSAccount): + __name = "SendmywayCom" + __type = "account" + __version = "0.02" + + __description = """Sendmyway.com account plugin""" + __license = "GPLv3" + __authors = [("Walter Purcaro", "vuolter@gmail.com")] + + + HOSTER_DOMAIN = "sendmyway.com" diff --git a/pyload/plugin/account/ShareonlineBiz.py b/pyload/plugin/account/ShareonlineBiz.py new file mode 100644 index 000000000..1b167a568 --- /dev/null +++ b/pyload/plugin/account/ShareonlineBiz.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.Account import Account + + +class ShareonlineBiz(Account): + __name = "ShareonlineBiz" + __type = "account" + __version = "0.24" + + __description = """Share-online.biz account plugin""" + __license = "GPLv3" + __authors = [("mkaay", "mkaay@mkaay.de"), + ("zoidberg", "zoidberg@mujmail.cz")] + + + def getUserAPI(self, user, req): + return req.load("http://api.share-online.biz/account.php", + {"username": user, "password": self.accounts[user]['password'], "act": "userDetails"}) + + + def loadAccountInfo(self, user, req): + html = self.getUserAPI(user, req) + + info = {} + for line in html.splitlines(): + if "=" in line: + key, value = line.split("=") + info[key] = value + self.logDebug(info) + + if "dl" in info and info['dl'].lower() != "not_available": + req.cj.setCookie("share-online.biz", "dl", info['dl']) + if "a" in info and info['a'].lower() != "not_available": + req.cj.setCookie("share-online.biz", "a", info['a']) + + return {"validuntil": int(info['expire_date']) if "expire_date" in info else -1, + "trafficleft": -1, + "premium": True if ("dl" in info or "a" in info) and (info['group'] != "Sammler") else False} + + + def login(self, user, data, req): + html = self.getUserAPI(user, req) + if "EXCEPTION" in html: + self.wrongPassword() diff --git a/pyload/plugin/account/SimplyPremiumCom.py b/pyload/plugin/account/SimplyPremiumCom.py new file mode 100644 index 000000000..af8fc0730 --- /dev/null +++ b/pyload/plugin/account/SimplyPremiumCom.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- + +from pyload.utils import json_loads +from pyload.plugin.Account import Account + + +class SimplyPremiumCom(Account): + __name = "SimplyPremiumCom" + __type = "account" + __version = "0.01" + + __description = """Simply-Premium.com account plugin""" + __license = "GPLv3" + __authors = [("EvolutionClip", "evolutionclip@live.de")] + + + def loadAccountInfo(self, user, req): + json_data = req.load('http://www.simply-premium.com/api/user.php?format=json') + self.logDebug("JSON data: " + json_data) + json_data = json_loads(json_data) + + if 'vip' in json_data['result'] and json_data['result']['vip'] == 0: + return {"premium": False} + + #Time package + validuntil = float(json_data['result']['timeend']) + #Traffic package + # {"trafficleft": int(traffic), "validuntil": -1} + #trafficleft = int(json_data['result']['traffic']) + + #return {"premium": True, "validuntil": validuntil, "trafficleft": trafficleft} + return {"premium": True, "validuntil": validuntil} + + + def login(self, user, data, req): + req.cj.setCookie("simply-premium.com", "lang", "EN") + + if data['password'] == '' or data['password'] == '0': + post_data = {"key": user} + else: + post_data = {"login_name": user, "login_pass": data['password']} + + html = req.load("http://www.simply-premium.com/login.php", post=post_data) + + if 'logout' not in html: + self.wrongPassword() diff --git a/pyload/plugin/account/SimplydebridCom.py b/pyload/plugin/account/SimplydebridCom.py new file mode 100644 index 000000000..24d0cb6bf --- /dev/null +++ b/pyload/plugin/account/SimplydebridCom.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- + +from time import mktime, strptime + +from pyload.plugin.Account import Account + + +class SimplydebridCom(Account): + __name = "SimplydebridCom" + __type = "account" + __version = "0.10" + + __description = """Simply-Debrid.com account plugin""" + __license = "GPLv3" + __authors = [("Kagenoshin", "kagenoshin@gmx.ch")] + + + def loadAccountInfo(self, user, req): + get_data = {'login': 2, 'u': self.loginname, 'p': self.password} + res = req.load("http://simply-debrid.com/api.php", get=get_data, decode=True) + data = [x.strip() for x in res.split(";")] + if str(data[0]) != "1": + return {"premium": False} + else: + return {"trafficleft": -1, "validuntil": mktime(strptime(str(data[2]), "%d/%m/%Y"))} + + + def login(self, user, data, req): + self.loginname = user + self.password = data['password'] + get_data = {'login': 1, 'u': self.loginname, 'p': self.password} + res = req.load("http://simply-debrid.com/api.php", get=get_data, decode=True) + if res != "02: loggin success": + self.wrongPassword() diff --git a/pyload/plugin/account/StahnuTo.py b/pyload/plugin/account/StahnuTo.py new file mode 100644 index 000000000..b3ca3891a --- /dev/null +++ b/pyload/plugin/account/StahnuTo.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- + +import re + +from pyload.plugin.Account import Account + + +class StahnuTo(Account): + __name = "StahnuTo" + __type = "account" + __version = "0.03" + + __description = """StahnuTo account plugin""" + __license = "GPLv3" + __authors = [("zoidberg", "zoidberg@mujmail.cz")] + + + def loadAccountInfo(self, user, req): + html = req.load("http://www.stahnu.to/") + + m = re.search(r'>VIP: (\d+.*)<', html) + trafficleft = self.parseTraffic(m.group(1)) * 1024 if m else 0 + + return {"premium": trafficleft > (512 * 1024), "trafficleft": trafficleft, "validuntil": -1} + + + def login(self, user, data, req): + html = req.load("http://www.stahnu.to/login.php", post={ + "username": user, + "password": data['password'], + "submit": "Login"}) + + if not '<a href="logout.php">' in html: + self.wrongPassword() diff --git a/pyload/plugin/account/StreamcloudEu.py b/pyload/plugin/account/StreamcloudEu.py new file mode 100644 index 000000000..f3eb6cce9 --- /dev/null +++ b/pyload/plugin/account/StreamcloudEu.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.internal.XFSAccount import XFSAccount + + +class StreamcloudEu(XFSAccount): + __name = "StreamcloudEu" + __type = "account" + __version = "0.02" + + __description = """Streamcloud.eu account plugin""" + __license = "GPLv3" + __authors = [("Walter Purcaro", "vuolter@gmail.com")] + + + HOSTER_DOMAIN = "streamcloud.eu" diff --git a/pyload/plugin/account/TurbobitNet.py b/pyload/plugin/account/TurbobitNet.py new file mode 100644 index 000000000..8237ed34e --- /dev/null +++ b/pyload/plugin/account/TurbobitNet.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- + +import re +from time import mktime, strptime + +from pyload.plugin.Account import Account + + +class TurbobitNet(Account): + __name = "TurbobitNet" + __type = "account" + __version = "0.01" + + __description = """TurbobitNet account plugin""" + __license = "GPLv3" + __authors = [("zoidberg", "zoidberg@mujmail.cz")] + + + def loadAccountInfo(self, user, req): + html = req.load("http://turbobit.net") + + m = re.search(r'<u>Turbo Access</u> to ([\d.]+)', html) + if m: + premium = True + validuntil = mktime(strptime(m.group(1), "%d.%m.%Y")) + else: + premium = False + validuntil = -1 + + return {"premium": premium, "trafficleft": -1, "validuntil": validuntil} + + + def login(self, user, data, req): + req.cj.setCookie("turbobit.net", "user_lang", "en") + + html = req.load("http://turbobit.net/user/login", post={ + "user[login]": user, + "user[pass]": data['password'], + "user[submit]": "Login"}) + + if not '<div class="menu-item user-name">' in html: + self.wrongPassword() diff --git a/pyload/plugin/account/TusfilesNet.py b/pyload/plugin/account/TusfilesNet.py new file mode 100644 index 000000000..b951f8add --- /dev/null +++ b/pyload/plugin/account/TusfilesNet.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- + +import re + +from time import mktime, strptime, gmtime + +from pyload.plugin.internal.XFSAccount import XFSAccount + + +class TusfilesNet(XFSAccount): + __name = "TusfilesNet" + __type = "account" + __version = "0.06" + + __description = """Tusfile.net account plugin""" + __license = "GPLv3" + __authors = [("guidobelix", "guidobelix@hotmail.it")] + + + HOSTER_DOMAIN = "tusfiles.net" + + VALID_UNTIL_PATTERN = r'<span class="label label-default">([^<]+)</span>' + TRAFFIC_LEFT_PATTERN = r'<td><img src="//www\.tusfiles\.net/i/icon/meter\.png" alt=""/></td>\n<td> (?P<S>[\d.,]+)' diff --git a/pyload/plugin/account/UlozTo.py b/pyload/plugin/account/UlozTo.py new file mode 100644 index 000000000..bba346874 --- /dev/null +++ b/pyload/plugin/account/UlozTo.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- + +import re + +from urlparse import urljoin + +from pyload.plugin.Account import Account + + +class UlozTo(Account): + __name = "UlozTo" + __type = "account" + __version = "0.07" + + __description = """Uloz.to account plugin""" + __license = "GPLv3" + __authors = [("zoidberg", "zoidberg@mujmail.cz"), + ("pulpe", "")] + + + TRAFFIC_LEFT_PATTERN = r'<li class="menu-kredit"><a href="/kredit" title="[^"]*?GB = ([\d.]+) MB"' + + + def loadAccountInfo(self, user, req): + self.phpsessid = req.cj.getCookie("ULOSESSID") #@NOTE: this cookie gets lost somehow after each request + + html = req.load("http://www.ulozto.net/", decode=True) + + req.cj.setCookie("ulozto.net", "ULOSESSID", self.phpsessid) + + m = re.search(self.TRAFFIC_LEFT_PATTERN, html) + trafficleft = int(float(m.group(1).replace(' ', '').replace(',', '.')) * 1000 * 1.048) if m else 0 + self.premium = True if trafficleft else False + + return {"validuntil": -1, "trafficleft": trafficleft} + + + def login(self, user, data, req): + login_page = req.load('http://www.ulozto.net/?do=web-login', decode=True) + action = re.findall('<form action="(.+?)"', login_page)[1].replace('&', '&') + token = re.search('_token_" value="(.+?)"', login_page).group(1) + + html = req.load(urljoin("http://www.ulozto.net/", action), + post={'_token_' : token, + 'do' : "loginForm-submit", + 'login' : u"Přihlásit", + 'password': data['password'], + 'username': user}, + decode=True) + + if '<div class="flash error">' in html: + self.wrongPassword() diff --git a/pyload/plugin/account/UnrestrictLi.py b/pyload/plugin/account/UnrestrictLi.py new file mode 100644 index 000000000..943943cac --- /dev/null +++ b/pyload/plugin/account/UnrestrictLi.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.Account import Account +from pyload.utils import json_loads + + +class UnrestrictLi(Account): + __name = "UnrestrictLi" + __type = "account" + __version = "0.03" + + __description = """Unrestrict.li account plugin""" + __license = "GPLv3" + __authors = [("stickell", "l.stickell@yahoo.it")] + + + def loadAccountInfo(self, user, req): + json_data = req.load('http://unrestrict.li/api/jdownloader/user.php?format=json') + self.logDebug("JSON data: " + json_data) + json_data = json_loads(json_data) + + if 'vip' in json_data['result'] and json_data['result']['vip'] == 0: + return {"premium": False} + + validuntil = json_data['result']['expires'] + trafficleft = int(json_data['result']['traffic']) + + return {"premium": True, "validuntil": validuntil, "trafficleft": trafficleft} + + + def login(self, user, data, req): + req.cj.setCookie("unrestrict.li", "lang", "EN") + html = req.load("https://unrestrict.li/sign_in") + + if 'solvemedia' in html: + self.logError(_("A Captcha is required. Go to http://unrestrict.li/sign_in and login, then retry")) + return + + post_data = {"username": user, "password": data['password'], + "remember_me": "remember", "signin": "Sign in"} + html = req.load("https://unrestrict.li/sign_in", post=post_data) + + if 'sign_out' not in html: + self.wrongPassword() diff --git a/pyload/plugin/account/UploadcCom.py b/pyload/plugin/account/UploadcCom.py new file mode 100644 index 000000000..01102168c --- /dev/null +++ b/pyload/plugin/account/UploadcCom.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.internal.XFSAccount import XFSAccount + + +class UploadcCom(XFSAccount): + __name = "UploadcCom" + __type = "account" + __version = "0.02" + + __description = """Uploadc.com account plugin""" + __license = "GPLv3" + __authors = [("Walter Purcaro", "vuolter@gmail.com")] + + + HOSTER_DOMAIN = "uploadc.com" diff --git a/pyload/plugin/account/UploadedTo.py b/pyload/plugin/account/UploadedTo.py new file mode 100644 index 000000000..f25da8995 --- /dev/null +++ b/pyload/plugin/account/UploadedTo.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- + +import re +from time import time + +from pyload.plugin.Account import Account + + +class UploadedTo(Account): + __name = "UploadedTo" + __type = "account" + __version = "0.27" + + __description = """Uploaded.to account plugin""" + __license = "GPLv3" + __authors = [("mkaay", "mkaay@mkaay.de")] + + + PREMIUM_PATTERN = r'<em>Premium</em>' + VALID_UNTIL_PATTERN = r'<td>Duration:</td>\s*<th>([^<]+)' + TRAFFIC_LEFT_PATTERN = r'<th colspan="2"><b class="cB">([^<]+)' + + + def loadAccountInfo(self, user, req): + validuntil = None + trafficleft = None + premium = None + + html = req.load("http://uploaded.net/me") + + premium = True if re.search(self.PREMIUM_PATTERN, html) else False + + m = re.search(self.VALID_UNTIL_PATTERN, html, re.M) + if m: + expiredate = m.group(1).strip() + + if expiredate == "unlimited": + validuntil = -1 + else: + m = re.findall(r'(\d+) (Week|weeks|day|hour)', expiredate) + if m: + validuntil = time() + for n, u in m: + validuntil += int(n) * 60 * 60 * {'Week': 168, 'weeks': 168, 'day': 24, 'hour': 1}[u] + + m = re.search(self.TRAFFIC_LEFT_PATTERN, html) + if m: + trafficleft = self.parseTraffic(m.group(1).replace('.', '')) + + return {'validuntil': validuntil, 'trafficleft': trafficleft, 'premium': premium} + + + def login(self, user, data, req): + req.cj.setCookie("uploaded.net", "lang", "en") + + page = req.load("http://uploaded.net/io/login", + post={'id': user, 'pw': data['password'], '_': ""}) + + if "User and password do not match" in page: + self.wrongPassword() diff --git a/pyload/plugin/account/UploadheroCom.py b/pyload/plugin/account/UploadheroCom.py new file mode 100644 index 000000000..fa7af288e --- /dev/null +++ b/pyload/plugin/account/UploadheroCom.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- + +import re +import datetime +import time + +from pyload.plugin.Account import Account + + +class UploadheroCom(Account): + __name = "UploadheroCom" + __type = "account" + __version = "0.20" + + __description = """Uploadhero.co account plugin""" + __license = "GPLv3" + __authors = [("mcmyst", "mcmyst@hotmail.fr")] + + + def loadAccountInfo(self, user, req): + premium_pattern = re.compile('Il vous reste <span class="bleu">(\d+)</span> jours premium') + + data = self.getAccountData(user) + page = req.load("http://uploadhero.co/my-account") + + if premium_pattern.search(page): + end_date = datetime.date.today() + datetime.timedelta(days=int(premium_pattern.search(page).group(1))) + end_date = time.mktime(future.timetuple()) + account_info = {"validuntil": end_date, "trafficleft": -1, "premium": True} + else: + account_info = {"validuntil": -1, "trafficleft": -1, "premium": False} + + return account_info + + + def login(self, user, data, req): + page = req.load("http://uploadhero.co/lib/connexion.php", + post={"pseudo_login": user, "password_login": data['password']}) + + if "mot de passe invalide" in page: + self.wrongPassword() diff --git a/pyload/plugin/account/UploadingCom.py b/pyload/plugin/account/UploadingCom.py new file mode 100644 index 000000000..7ac1e52ff --- /dev/null +++ b/pyload/plugin/account/UploadingCom.py @@ -0,0 +1,63 @@ +# -*- coding: utf-8 -*- + +import re + +from time import time, strptime, mktime + +from pyload.plugin.Account import Account +from pyload.plugin.internal.SimpleHoster import set_cookies + + +class UploadingCom(Account): + __name = "UploadingCom" + __type = "account" + __version = "0.11" + + __description = """Uploading.com account plugin""" + __license = "GPLv3" + __authors = [("mkaay", "mkaay@mkaay.de")] + + + PREMIUM_PATTERN = r'UPGRADE TO PREMIUM' + VALID_UNTIL_PATTERN = r'Valid Until:(.+?)<' + + + def loadAccountInfo(self, user, req): + validuntil = None + trafficleft = None + premium = None + + html = req.load("http://uploading.com/") + + premium = False if re.search(self.PREMIUM_PATTERN, html) else True + + m = re.search(self.VALID_UNTIL_PATTERN, html) + if m: + expiredate = m.group(1).strip() + self.logDebug("Expire date: " + expiredate) + + try: + validuntil = mktime(strptime(expiredate, "%b %d, %Y")) + + except Exception, e: + self.logError(e) + + else: + if validuntil > mktime(gmtime()): + premium = True + else: + premium = False + validuntil = None + + return {'validuntil': validuntil, 'trafficleft': trafficleft, 'premium': premium} + + + def login(self, user, data, req): + set_cookies([("uploading.com", "lang", "1"), + ("uploading.com", "language", "1"), + ("uploading.com", "setlang", "en"), + ("uploading.com", "_lang", "en")] + + req.load("http://uploading.com/") + req.load("http://uploading.com/general/login_form/?JsHttpRequest=%s-xml" % long(time() * 1000), + post={'email': user, 'password': data['password'], 'remember': "on"}) diff --git a/pyload/plugin/account/UptoboxCom.py b/pyload/plugin/account/UptoboxCom.py new file mode 100644 index 000000000..116721ebe --- /dev/null +++ b/pyload/plugin/account/UptoboxCom.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.internal.XFSAccount import XFSAccount + + +class UptoboxCom(XFSAccount): + __name = "UptoboxCom" + __type = "account" + __version = "0.07" + + __description = """DDLStorage.com account plugin""" + __license = "GPLv3" + __authors = [("zoidberg", "zoidberg@mujmail.cz")] + + + HOSTER_DOMAIN = "uptobox.com" + HOSTER_URL = "https://uptobox.com/" diff --git a/pyload/plugin/account/VidPlayNet.py b/pyload/plugin/account/VidPlayNet.py new file mode 100644 index 000000000..c5d4e0b5a --- /dev/null +++ b/pyload/plugin/account/VidPlayNet.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.internal.XFSAccount import XFSAccount + + +class VidPlayNet(XFSAccount): + __name = "VidPlayNet" + __type = "account" + __version = "0.02" + + __description = """VidPlay.net account plugin""" + __license = "GPLv3" + __authors = [("Walter Purcaro", "vuolter@gmail.com")] + + + HOSTER_DOMAIN = "vidplay.net" diff --git a/pyload/plugin/account/XFileSharingPro.py b/pyload/plugin/account/XFileSharingPro.py new file mode 100644 index 000000000..67679f2cc --- /dev/null +++ b/pyload/plugin/account/XFileSharingPro.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.internal.XFSAccount import XFSAccount + + +class XFileSharingPro(XFSAccount): + __name = "XFileSharingPro" + __type = "account" + __version = "0.05" + + __description = """XFileSharingPro multi-purpose account plugin""" + __license = "GPLv3" + __authors = [("Walter Purcaro", "vuolter@gmail.com")] + + + HOSTER_DOMAIN = None + + + def init(self): + if self.HOSTER_DOMAIN: + return super(XFileSharingPro, self).init() + + + def loadAccountInfo(self, user, req): + return super(XFileSharingPro if self.HOSTER_DOMAIN else XFSAccount, self).loadAccountInfo(user, req) + + + def login(self, user, data, req): + if self.HOSTER_DOMAIN: + return super(XFileSharingPro, self).login(user, data, req) diff --git a/pyload/plugin/account/YibaishiwuCom.py b/pyload/plugin/account/YibaishiwuCom.py new file mode 100644 index 000000000..6f149478e --- /dev/null +++ b/pyload/plugin/account/YibaishiwuCom.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- + +import re + +from pyload.plugin.Account import Account + + +class YibaishiwuCom(Account): + __name = "YibaishiwuCom" + __type = "account" + __version = "0.01" + + __description = """115.com account plugin""" + __license = "GPLv3" + __authors = [("zoidberg", "zoidberg@mujmail.cz")] + + + ACCOUNT_INFO_PATTERN = r'var USER_PERMISSION = {(.*?)}' + + + def loadAccountInfo(self, user, req): + #self.relogin(user) + html = req.load("http://115.com/", decode=True) + + m = re.search(self.ACCOUNT_INFO_PATTERN, html, re.S) + premium = True if (m and 'is_vip: 1' in m.group(1)) else False + validuntil = trafficleft = (-1 if m else 0) + return dict({"validuntil": validuntil, "trafficleft": trafficleft, "premium": premium}) + + + def login(self, user, data, req): + html = req.load('http://passport.115.com/?ac=login', post={ + "back": "http://www.115.com/", + "goto": "http://115.com/", + "login[account]": user, + "login[passwd]": data['password'] + }, decode=True) + + if not 'var USER_PERMISSION = {' in html: + self.wrongPassword() diff --git a/pyload/plugin/account/ZeveraCom.py b/pyload/plugin/account/ZeveraCom.py new file mode 100644 index 000000000..aab795e55 --- /dev/null +++ b/pyload/plugin/account/ZeveraCom.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- + +from time import mktime, strptime + +from pyload.plugin.Account import Account + + +class ZeveraCom(Account): + __name = "ZeveraCom" + __type = "account" + __version = "0.21" + + __description = """Zevera.com account plugin""" + __license = "GPLv3" + __authors = [("zoidberg", "zoidberg@mujmail.cz")] + + + def loadAccountInfo(self, user, req): + data = self.getAPIData(req) + if data == "No traffic": + account_info = {"trafficleft": 0, "validuntil": 0, "premium": False} + else: + account_info = { + "trafficleft": int(data['availabletodaytraffic']) * 1024, + "validuntil": mktime(strptime(data['endsubscriptiondate'], "%Y/%m/%d %H:%M:%S")), + "premium": True + } + return account_info + + + def login(self, user, data, req): + self.loginname = user + self.password = data['password'] + if self.getAPIData(req) == "No traffic": + self.wrongPassword() + + + def getAPIData(self, req, just_header=False, **kwargs): + get_data = { + 'cmd': 'accountinfo', + 'login': self.loginname, + 'pass': self.password + } + get_data.update(kwargs) + + res = req.load("http://www.zevera.com/jDownloader.ashx", get=get_data, + decode=True, just_header=just_header) + self.logDebug(res) + + if ':' in res: + if not just_header: + res = res.replace(',', '\n') + return dict((y.strip().lower(), z.strip()) for (y, z) in + [x.split(':', 1) for x in res.splitlines() if ':' in x]) + else: + return res diff --git a/pyload/plugin/account/__init__.py b/pyload/plugin/account/__init__.py new file mode 100644 index 000000000..40a96afc6 --- /dev/null +++ b/pyload/plugin/account/__init__.py @@ -0,0 +1 @@ +# -*- coding: utf-8 -*- diff --git a/pyload/plugin/addon/Checksum.py b/pyload/plugin/addon/Checksum.py new file mode 100644 index 000000000..f3f98d0f8 --- /dev/null +++ b/pyload/plugin/addon/Checksum.py @@ -0,0 +1,186 @@ +# -*- coding: utf-8 -*- + +from __future__ import with_statement + +import hashlib +import re +import zlib + +from os import remove +from os.path import getsize, isfile, splitext + +from pyload.plugin.Addon import Addon +from pyload.utils import safe_join, fs_encode + + +def computeChecksum(local_file, algorithm): + if algorithm in getattr(hashlib, "algorithms", ("md5", "sha1", "sha224", "sha256", "sha384", "sha512")): + h = getattr(hashlib, algorithm)() + + with open(local_file, 'rb') as f: + for chunk in iter(lambda: f.read(128 * h.block_size), ''): + h.update(chunk) + + return h.hexdigest() + + elif algorithm in ("adler32", "crc32"): + hf = getattr(zlib, algorithm) + last = 0 + + with open(local_file, 'rb') as f: + for chunk in iter(lambda: f.read(8192), ''): + last = hf(chunk, last) + + return "%x" % last + + else: + return None + + +class Checksum(Addon): + __name = "Checksum" + __type = "addon" + __version = "0.15" + + __config = [("activated" , "bool" , "Activated" , True ), + ("check_checksum", "bool" , "Check checksum? (If False only size will be verified)", True ), + ("check_action" , "fail;retry;nothing", "What to do if check fails?" , "retry"), + ("max_tries" , "int" , "Number of retries" , 2 ), + ("retry_action" , "fail;nothing" , "What to do if all retries fail?" , "fail" ), + ("wait_time" , "int" , "Time to wait before each retry (seconds)" , 1 )] + + __description = """Verify downloaded file size and checksum""" + __license = "GPLv3" + __authors = [("zoidberg", "zoidberg@mujmail.cz"), + ("Walter Purcaro", "vuolter@gmail.com"), + ("stickell", "l.stickell@yahoo.it")] + + + methods = {'sfv': 'crc32', 'crc': 'crc32', 'hash': 'md5'} + regexps = {'sfv': r'^(?P<name>[^;].+)\s+(?P<hash>[0-9A-Fa-f]{8})$', + 'md5': r'^(?P<name>[0-9A-Fa-f]{32}) (?P<file>.+)$', + 'crc': r'filename=(?P<name>.+)\nsize=(?P<size>\d+)\ncrc32=(?P<hash>[0-9A-Fa-f]{8})$', + 'default': r'^(?P<hash>[0-9A-Fa-f]+)\s+\*?(?P<name>.+)$'} + + + def activate(self): + if not self.getConfig("check_checksum"): + self.logInfo(_("Checksum validation is disabled in plugin configuration")) + + + def setup(self): + self.algorithms = sorted( + getattr(hashlib, "algorithms", ("md5", "sha1", "sha224", "sha256", "sha384", "sha512")), reverse=True) + self.algorithms.extend(["crc32", "adler32"]) + self.formats = self.algorithms + ["sfv", "crc", "hash"] + + + def downloadFinished(self, pyfile): + """ + Compute checksum for the downloaded file and compare it with the hash provided by the hoster. + pyfile.plugin.check_data should be a dictionary which can contain: + a) if known, the exact filesize in bytes (e.g. "size": 123456789) + b) hexadecimal hash string with algorithm name as key (e.g. "md5": "d76505d0869f9f928a17d42d66326307") + """ + if hasattr(pyfile.plugin, "check_data") and isinstance(pyfile.plugin.check_data, dict): + data = pyfile.plugin.check_data.copy() + + elif hasattr(pyfile.plugin, "api_data") and isinstance(pyfile.plugin.api_data, dict): + data = pyfile.plugin.api_data.copy() + + # elif hasattr(pyfile.plugin, "info") and isinstance(pyfile.plugin.info, dict): + # data = pyfile.plugin.info.copy() + + else: + return + + self.logDebug(data) + + if not pyfile.plugin.lastDownload: + self.checkFailed(pyfile, None, "No file downloaded") + + local_file = fs_encode(pyfile.plugin.lastDownload) + #download_folder = self.config['general']['download_folder'] + #local_file = fs_encode(safe_join(download_folder, pyfile.package().folder, pyfile.name)) + + if not isfile(local_file): + self.checkFailed(pyfile, None, "File does not exist") + + # validate file size + if "size" in data: + api_size = int(data['size']) + file_size = getsize(local_file) + if api_size != file_size: + self.logWarning(_("File %s has incorrect size: %d B (%d expected)") % (pyfile.name, file_size, api_size)) + self.checkFailed(pyfile, local_file, "Incorrect file size") + del data['size'] + + # validate checksum + if data and self.getConfig("check_checksum"): + if "checksum" in data: + data['md5'] = data['checksum'] + + for key in self.algorithms: + if key in data: + checksum = computeChecksum(local_file, key.replace("-", "").lower()) + if checksum: + if checksum == data[key].lower(): + self.logInfo(_('File integrity of "%s" verified by %s checksum (%s)') % + (pyfile.name, key.upper(), checksum)) + break + else: + self.logWarning(_("%s checksum for file %s does not match (%s != %s)") % + (key.upper(), pyfile.name, checksum, data[key])) + self.checkFailed(pyfile, local_file, "Checksums do not match") + else: + self.logWarning(_("Unsupported hashing algorithm"), key.upper()) + else: + self.logWarning(_("Unable to validate checksum for file: ") + pyfile.name) + + + def checkFailed(self, pyfile, local_file, msg): + check_action = self.getConfig("check_action") + if check_action == "retry": + max_tries = self.getConfig("max_tries") + retry_action = self.getConfig("retry_action") + if pyfile.plugin.retries < max_tries: + if local_file: + remove(local_file) + pyfile.plugin.retry(max_tries, self.getConfig("wait_time"), msg) + elif retry_action == "nothing": + return + elif check_action == "nothing": + return + pyfile.plugin.fail(reason=msg) + + + def packageFinished(self, pypack): + download_folder = safe_join(self.config['general']['download_folder'], pypack.folder, "") + + for link in pypack.getChildren().itervalues(): + file_type = splitext(link['name'])[1][1:].lower() + + if file_type not in self.formats: + continue + + hash_file = fs_encode(safe_join(download_folder, link['name'])) + if not isfile(hash_file): + self.logWarning(_("File not found"), link['name']) + continue + + with open(hash_file) as f: + text = f.read() + + for m in re.finditer(self.regexps.get(file_type, self.regexps['default']), text): + data = m.groupdict() + self.logDebug(link['name'], data) + + local_file = fs_encode(safe_join(download_folder, data['name'])) + algorithm = self.methods.get(file_type, file_type) + checksum = computeChecksum(local_file, algorithm) + if checksum == data['hash']: + self.logInfo(_('File integrity of "%s" verified by %s checksum (%s)') % + (data['name'], algorithm, checksum)) + else: + self.logWarning(_("%s checksum for file %s does not match (%s != %s)") % + (algorithm, data['name'], checksum, data['hash'])) diff --git a/pyload/plugin/addon/ClickAndLoad.py b/pyload/plugin/addon/ClickAndLoad.py new file mode 100644 index 000000000..8a05ca85e --- /dev/null +++ b/pyload/plugin/addon/ClickAndLoad.py @@ -0,0 +1,74 @@ +# -*- coding: utf-8 -*- + +from socket import socket, error +from threading import Thread + +from pyload.plugin.Addon import Addon + + +def forward(source, destination): + string = ' ' + while string: + string = source.recv(1024) + if string: + destination.sendall(string) + else: + #source.shutdown(socket.SHUT_RD) + destination.shutdown(socket.SHUT_WR) + + +class ClickAndLoad(Addon): + __name = "ClickAndLoad" + __type = "addon" + __version = "0.23" + + __config = [("activated", "bool", "Activated" , True ), + ("port" , "int" , "Port" , 9666 ), + ("extern" , "bool", "Allow external link adding", False)] + + __description = """Click'N'Load hook plugin""" + __license = "GPLv3" + __authors = [("RaNaN", "RaNaN@pyload.de"), + ("mkaay", "mkaay@mkaay.de"), + ("Walter Purcaro", "vuolter@gmail.com")] + + + def setup(self): + self.interval = 300 + + + def activate(self): + self.initPeriodical() + + + def periodical(self): + webip = "0.0.0.0" if self.getConfig("extern") else "127.0.0.1" + webport = self.config['webinterface']['port'] + cnlport = self.getConfig("port")) + + try: + s = socket() + s.bind((webip, cnlport)) + s.listen(5) + + client = s.accept()[0] + server = socket() + + server.connect(("127.0.0.1", webport)) + + except error, e: + if hasattr(e, "errno"): + errno = e.errno + else: + errno = e.args[0] + + if errno == 98: + self.logWarning(_("Port %d already in use") % cnlport) + else: + self.logDebug(e) + + else: + self.core.scheduler.removeJob(self.cb) + t = Thread(target=forward, args=[client, server]) + t.setDaemon(True) + t.start() diff --git a/pyload/plugin/addon/DeleteFinished.py b/pyload/plugin/addon/DeleteFinished.py new file mode 100644 index 000000000..045f58d61 --- /dev/null +++ b/pyload/plugin/addon/DeleteFinished.py @@ -0,0 +1,79 @@ +# -*- coding: utf-8 -*- + +from pyload.database import style +from pyload.plugin.Addon import Addon + + +class DeleteFinished(Addon): + __name = "DeleteFinished" + __type = "addon" + __version = "1.11" + + __config = [('interval' , 'int' , 'Delete every (hours)' , '72' ), + ('deloffline', 'bool', 'Delete packages with offline links', 'False')] + + __description = """Automatically delete all finished packages from queue""" + __license = "GPLv3" + __authors = [("Walter Purcaro", "vuolter@gmail.com")] + + + # event_list = ["pluginConfigChanged"] + + + ## overwritten methods ## + def periodical(self): + if not self.info['sleep']: + deloffline = self.getConfig('deloffline') + mode = '0,1,4' if deloffline else '0,4' + msg = _('delete all finished packages in queue list (%s packages with offline links)') + self.logInfo(msg % (_('including') if deloffline else _('excluding'))) + self.deleteFinished(mode) + self.info['sleep'] = True + self.addEvent('packageFinished', self.wakeup) + + + def pluginConfigChanged(self, plugin, name, value): + if name == "interval" and value != self.interval: + self.interval = value * 3600 + self.initPeriodical() + + + def deactivate(self): + self.removeEvent('packageFinished', self.wakeup) + + + def activate(self): + self.info = {'sleep': True} + interval = self.getConfig('interval') + self.pluginConfigChanged(self.__name, 'interval', interval) + self.addEvent('packageFinished', self.wakeup) + + + ## own methods ## + @style.queue + def deleteFinished(self, mode): + self.c.execute('DELETE FROM packages WHERE NOT EXISTS(SELECT 1 FROM links WHERE package=packages.id AND status NOT IN (%s))' % mode) + self.c.execute('DELETE FROM links WHERE NOT EXISTS(SELECT 1 FROM packages WHERE id=links.package)') + + + def wakeup(self, pypack): + self.removeEvent('packageFinished', self.wakeup) + self.info['sleep'] = False + + + ## event managing ## + def addEvent(self, event, func): + """Adds an event listener for event name""" + if event in self.m.events: + if func in self.m.events[event]: + self.logDebug("Function already registered", func) + else: + self.m.events[event].append(func) + else: + self.m.events[event] = [func] + + + def setup(self): + self.interval = 0 + self.m = self.manager + self.removeEvent = self.m.removeEvent diff --git a/pyload/plugin/addon/DownloadScheduler.py b/pyload/plugin/addon/DownloadScheduler.py new file mode 100644 index 000000000..7f05d89f4 --- /dev/null +++ b/pyload/plugin/addon/DownloadScheduler.py @@ -0,0 +1,77 @@ +# -*- coding: utf-8 -*- + +import re + +from time import localtime + +from pyload.plugin.Addon import Addon + + +class DownloadScheduler(Addon): + __name = "DownloadScheduler" + __type = "addon" + __version = "0.22" + + __config = [("timetable", "str" , "List time periods as hh:mm full or number(kB/s)" , "0:00 full, 7:00 250, 10:00 0, 17:00 150"), + ("abort" , "bool", "Abort active downloads when start period with speed 0", False )] + + __description = """Download Scheduler""" + __license = "GPLv3" + __authors = [("zoidberg", "zoidberg@mujmail.cz"), + ("stickell", "l.stickell@yahoo.it")] + + + def setup(self): + self.cb = None #: callback to scheduler job; will be by removed AddonManager when addon unloaded + + + def activate(self): + self.updateSchedule() + + + def updateSchedule(self, schedule=None): + if schedule is None: + schedule = self.getConfig("timetable") + + schedule = re.findall("(\d{1,2}):(\d{2})[\s]*(-?\d+)", + schedule.lower().replace("full", "-1").replace("none", "0")) + if not schedule: + self.logError(_("Invalid schedule")) + return + + t0 = localtime() + now = (t0.tm_hour, t0.tm_min, t0.tm_sec, "X") + schedule = sorted([(int(x[0]), int(x[1]), 0, int(x[2])) for x in schedule] + [now]) + + self.logDebug("Schedule", schedule) + + for i, v in enumerate(schedule): + if v[3] == "X": + last, next = schedule[i - 1], schedule[(i + 1) % len(schedule)] + self.logDebug("Now/Last/Next", now, last, next) + + self.setDownloadSpeed(last[3]) + + next_time = (((24 + next[0] - now[0]) * 60 + next[1] - now[1]) * 60 + next[2] - now[2]) % 86400 + self.core.scheduler.removeJob(self.cb) + self.cb = self.core.scheduler.addJob(next_time, self.updateSchedule, threaded=False) + + + def setDownloadSpeed(self, speed): + if speed == 0: + abort = self.getConfig("abort") + self.logInfo(_("Stopping download server. (Running downloads will %sbe aborted.)") % '' if abort else _('not ')) + self.core.api.pauseServer() + if abort: + self.core.api.stopAllDownloads() + else: + self.core.api.unpauseServer() + + if speed > 0: + self.logInfo(_("Setting download speed to %d kB/s") % speed) + self.core.api.setConfigValue("download", "limit_speed", 1) + self.core.api.setConfigValue("download", "max_speed", speed) + else: + self.logInfo(_("Setting download speed to FULL")) + self.core.api.setConfigValue("download", "limit_speed", 0) + self.core.api.setConfigValue("download", "max_speed", -1) diff --git a/pyload/plugin/addon/ExternalScripts.py b/pyload/plugin/addon/ExternalScripts.py new file mode 100644 index 000000000..030b44ae1 --- /dev/null +++ b/pyload/plugin/addon/ExternalScripts.py @@ -0,0 +1,145 @@ +# -*- coding: utf-8 -*- + +import subprocess + +from itertools import chain +from os import listdir, access, X_OK, makedirs +from os.path import join, exists, basename, abspath + +from pyload.plugin.Addon import Addon +from pyload.utils import safe_join + + +class ExternalScripts(Addon): + __name = "ExternalScripts" + __type = "addon" + __version = "0.25" + + __config = [("activated", "bool", "Activated", True)] + + __description = """Run external scripts""" + __license = "GPLv3" + __authors = [("mkaay", "mkaay@mkaay.de"), + ("RaNaN", "ranan@pyload.org"), + ("spoob", "spoob@pyload.org"), + ("Walter Purcaro", "vuolter@gmail.com")] + + + event_map = {'archive-extracted' : "archive_extracted", + 'package-extracted' : "package_extracted", + 'all_archives-extracted' : "all_archives_extracted", + 'all_archives-processed' : "all_archives_processed", + 'all_downloads-finished' : "allDownloadsFinished", + 'all_downloads-processed': "allDownloadsProcessed"} + + + def setup(self): + self.scripts = {} + + folders = ["download_preparing", "download_finished", "all_downloads_finished", "all_downloads_processed", + "before_reconnect", "after_reconnect", + "package_finished", "package_extracted", + "archive_extracted", "all_archives_extracted", "all_archives_processed", + # deprecated folders + "unrar_finished", "all_dls_finished", "all_dls_processed"] + + for folder in folders: + self.scripts[folder] = [] + + self.initPluginType(folder, join(pypath, 'scripts', folder)) + self.initPluginType(folder, join('scripts', folder)) + + for script_type, names in self.scripts.iteritems(): + if names: + self.logInfo(_("Installed scripts for"), script_type, ", ".join([basename(x) for x in names])) + + + def initPluginType(self, folder, path): + if not exists(path): + try: + makedirs(path) + except Exception: + self.logDebug("Script folder %s not created" % folder) + return + + for f in listdir(path): + if f.startswith("#") or f.startswith(".") or f.startswith("_") or f.endswith("~") or f.endswith(".swp"): + continue + + if not access(join(path, f), X_OK): + self.logWarning(_("Script not executable:") + " %s/%s" % (folder, f)) + + self.scripts[folder].append(join(path, f)) + + + def callScript(self, script, *args): + try: + cmd = [script] + [str(x) if not isinstance(x, basestring) else x for x in args] + self.logDebug("Executing", abspath(script), " ".join(cmd)) + #output goes to pyload + subprocess.Popen(cmd, bufsize=-1) + except Exception, e: + self.logError(_("Error in %(script)s: %(error)s") % {"script": basename(script), "error": e}) + + + def downloadPreparing(self, pyfile): + for script in self.scripts['download_preparing']: + self.callScript(script, pyfile.pluginname, pyfile.url, pyfile.id) + + + def downloadFinished(self, pyfile): + download_folder = self.config['general']['download_folder'] + for script in self.scripts['download_finished']: + filename = safe_join(download_folder, pyfile.package().folder, pyfile.name) + self.callScript(script, pyfile.pluginname, pyfile.url, pyfile.name, filename, pyfile.id) + + + def packageFinished(self, pypack): + download_folder = self.config['general']['download_folder'] + for script in self.scripts['package_finished']: + folder = safe_join(download_folder, pypack.folder) + self.callScript(script, pypack.name, folder, pypack.password, pypack.id) + + + def beforeReconnecting(self, ip): + for script in self.scripts['before_reconnect']: + self.callScript(script, ip) + + + def afterReconnecting(self, ip): + for script in self.scripts['after_reconnect']: + self.callScript(script, ip) + + + def archive_extracted(self, pyfile, folder, filename, files): + for script in self.scripts['archive_extracted']: + self.callScript(script, folder, filename, files) + for script in self.scripts['unrar_finished']: #: deprecated + self.callScript(script, folder, filename) + + + def package_extracted(self, pypack): + download_folder = self.config['general']['download_folder'] + for script in self.scripts['package_extracted']: + folder = safe_join(download_folder, pypack.folder) + self.callScript(script, pypack.name, folder, pypack.password, pypack.id) + + + def all_archives_extracted(self): + for script in self.scripts['all_archives_extracted']: + self.callScript(script) + + + def all_archives_processed(self): + for script in self.scripts['all_archives_processed']: + self.callScript(script) + + + def allDownloadsFinished(self): + for script in chain(self.scripts['all_downloads_finished'], self.scripts['all_dls_finished']): + self.callScript(script) + + + def allDownloadsProcessed(self): + for script in chain(self.scripts['all_downloads_processed'], self.scripts['all_dls_processed']): + self.callScript(script) diff --git a/pyload/plugin/addon/ExtractArchive.py b/pyload/plugin/addon/ExtractArchive.py new file mode 100644 index 000000000..478fb954e --- /dev/null +++ b/pyload/plugin/addon/ExtractArchive.py @@ -0,0 +1,363 @@ +# -*- coding: utf-8 -*- + +from __future__ import with_statement + +import os +import sys + +from copy import copy +from os import remove, chmod, makedirs +from os.path import exists, basename, isfile, isdir +from traceback import print_exc + +# monkey patch bug in python 2.6 and lower +# http://bugs.python.org/issue6122 , http://bugs.python.org/issue1236 , http://bugs.python.org/issue1731717 +if sys.version_info < (2, 7) and os.name != "nt": + import errno + from subprocess import Popen + + + def _eintr_retry_call(func, *args): + while True: + try: + return func(*args) + except OSError, e: + if e.errno == errno.EINTR: + continue + raise + + + # unsued timeout option for older python version + def wait(self, timeout=0): + """Wait for child process to terminate. Returns returncode + attribute.""" + if self.returncode is None: + try: + pid, sts = _eintr_retry_call(os.waitpid, self.pid, 0) + except OSError, e: + if e.errno != errno.ECHILD: + raise + # This happens if SIGCLD is set to be ignored or waiting + # for child processes has otherwise been disabled for our + # process. This child is dead, we can't get the status. + sts = 0 + self._handle_exitstatus(sts) + return self.returncode + + Popen.wait = wait + +if os.name != "nt": + from grp import getgrnam + from os import chown + from pwd import getpwnam + +from pyload.plugin.Addon import Addon, threaded, Expose +from pyload.plugin.internal.AbstractExtractor import ArchiveError, CRCError, WrongPassword +from pyload.utils import safe_join, fs_encode + + +class ExtractArchive(Addon): + __name = "ExtractArchive" + __type = "addon" + __version = "0.19" + + __config = [("activated" , "bool" , "Activated" , True ), + ("fullpath" , "bool" , "Extract full path" , True ), + ("overwrite" , "bool" , "Overwrite files" , True ), + ("passwordfile" , "file" , "password file" , "archive_password.txt"), + ("deletearchive", "bool" , "Delete archives when done" , False ), + ("subfolder" , "bool" , "Create subfolder for each package" , False ), + ("destination" , "folder", "Extract files to" , "" ), + ("excludefiles" , "str" , "Exclude files from unpacking (seperated by ;)", "" ), + ("recursive" , "bool" , "Extract archives in archvies" , True ), + ("queue" , "bool" , "Wait for all downloads to be finished" , True ), + ("renice" , "int" , "CPU Priority" , 0 )] + + __description = """Extract different kind of archives""" + __license = "GPLv3" + __authors = [("RaNaN", "ranan@pyload.org"), + ("AndroKev", ""), + ("Walter Purcaro", "vuolter@gmail.com")] + + + event_map = {'all_downloads-processed': "allDownloadsProcessed"} + + + def setup(self): + self.plugins = [] + self.passwords = [] + names = [] + + for p in ("UnRar", "UnZip"): + try: + module = self.core.pluginManager.loadModule("internal", p) + klass = getattr(module, p) + if klass.checkDeps(): + names.append(p) + self.plugins.append(klass) + + except OSError, e: + if e.errno == 2: + self.logInfo(_("No %s installed") % p) + else: + self.logWarning(_("Could not activate %s") % p, e) + if self.core.debug: + print_exc() + + except Exception, e: + self.logWarning(_("Could not activate %s") % p, e) + if self.core.debug: + print_exc() + + if names: + self.logInfo(_("Activated") + " " + " ".join(names)) + else: + self.logInfo(_("No Extract plugins activated")) + + # queue with package ids + self.queue = [] + + + @Expose + def extractPackage(self, id): + """ Extract package with given id""" + self.manager.startThread(self.extract, [id]) + + + def packageFinished(self, pypack): + pid = pypack.id + if self.getConfig("queue"): + self.logInfo(_("Package %s queued for later extracting") % pypack.name) + self.queue.append(pid) + else: + self.manager.startThread(self.extract, [pid]) + + + @threaded + def allDownloadsProcessed(self, thread): + local = copy(self.queue) + del self.queue[:] + if self.extract(local, thread): #: check only if all gone fine, no failed reporting for now + self.manager.dispatchEvent("all_archives-extracted") + self.manager.dispatchEvent("all_archives-processed") + + + def extract(self, ids, thread=None): + processed = [] + extracted = [] + failed = [] + + destination = self.getConfig("destination") + subfolder = self.getConfig("subfolder") + fullpath = self.getConfig("fullpath") + overwrite = self.getConfig("overwrite") + excludefiles = self.getConfig("excludefiles") + renice = self.getConfig("renice") + recursive = self.getConfig("recursive") + + # reload from txt file + self.reloadPasswords() + + # dl folder + dl = self.config['general']['download_folder'] + + #iterate packages -> plugins -> targets + for pid in ids: + p = self.core.files.getPackage(pid) + self.logInfo(_("Check package %s") % p.name) + if not p: + continue + + # determine output folder + out = safe_join(dl, p.folder, "") + + out = safe_join(dl, p.folder, self.getConfig("destination"), "") + if subfolder: + out = safe_join(out, fs_encode(p.folder)) + + if not exists(out): + makedirs(out) + + files_ids = [(safe_join(dl, p.folder, x['name']), x['id']) for x in p.getChildren().itervalues()] + matched = False + success = True + + # check as long there are unseen files + while files_ids: + new_files_ids = [] + + for plugin in self.plugins: + targets = plugin.getTargets(files_ids) + if targets: + self.logDebug("Targets for %s: %s" % (plugin.__name, targets)) + matched = True + for target, fid in targets: + if target in processed: + self.logDebug(basename(target), "skipped") + continue + + processed.append(target) # prevent extracting same file twice + + self.logInfo(basename(target), _("Extract to %s") % out) + try: + klass = plugin(self, target, out, fullpath, overwrite, excludefiles, renice) + klass.init() + password = p.password.strip().splitlines() + new_files = self._extract(klass, fid, password, thread) + except Exception, e: + self.logError(basename(target), e) + success = False + continue + + self.logDebug("Extracted", new_files) + self.setPermissions(new_files) + + for file in new_files: + if not exists(file): + self.logDebug("New file %s does not exists" % file) + continue + if recursive and isfile(file): + new_files_ids.append((file, fid)) # append as new target + + files_ids = new_files_ids # also check extracted files + + if matched: + if success: + extracted.append(pid) + self.manager.dispatchEvent("package-extracted", p) + else: + failed.append(pid) + self.manager.dispatchEvent("package-extract_failed", p) + else: + self.logInfo(_("No files found to extract")) + + return True if not failed else False + + + def _extract(self, plugin, fid, passwords, thread): + pyfile = self.core.files.getFile(fid) + deletearchive = self.getConfig("deletearchive") + + pyfile.setCustomStatus(_("extracting")) + thread.addActive(pyfile) # keep this file until everything is done + + try: + progress = lambda x: pyfile.setProgress(x) + success = False + + if not plugin.checkArchive(): + plugin.extract(progress) + success = True + else: + self.logInfo(basename(plugin.file), _("Password protected")) + self.logDebug("Passwords", passwords) + + pwlist = copy(self.getPasswords()) + # remove already supplied pws from list (only local) + for pw in passwords: + if pw in pwlist: + pwlist.remove(pw) + + for pw in passwords + pwlist: + try: + self.logDebug("Try password", pw) + if plugin.checkPassword(pw): + plugin.extract(progress, pw) + self.addPassword(pw) + success = True + break + except WrongPassword: + self.logDebug("Password was wrong") + + if not success: + raise Exception(_("Wrong password")) + + if self.core.debug: + self.logDebug("Would delete", ", ".join(plugin.getDeleteFiles())) + + if deletearchive: + files = plugin.getDeleteFiles() + self.logInfo(_("Deleting %s files") % len(files)) + for f in files: + if exists(f): + remove(f) + else: + self.logDebug("%s does not exists" % f) + + self.logInfo(basename(plugin.file), _("Extracting finished")) + + extracted_files = plugin.getExtractedFiles() + self.manager.dispatchEvent("archive-extracted", pyfile, plugin.out, plugin.file, extracted_files) + + return extracted_files + + except ArchiveError, e: + self.logError(basename(plugin.file), _("Archive Error"), e) + except CRCError: + self.logError(basename(plugin.file), _("CRC Mismatch")) + except Exception, e: + if self.core.debug: + print_exc() + self.logError(basename(plugin.file), _("Unknown Error"), e) + + self.manager.dispatchEvent("archive-extract_failed", pyfile) + raise Exception(_("Extract failed")) + + + @Expose + def getPasswords(self): + """ List of saved passwords """ + return self.passwords + + + def reloadPasswords(self): + passwordfile = self.getConfig("passwordfile") + + try: + passwords = [] + with open(passwordfile, "a+") as f: + for pw in f.read().splitlines(): + passwords.append(pw) + + except IOError, e: + self.logError(e) + + else: + self.passwords = passwords + + + @Expose + def addPassword(self, pw): + """ Adds a password to saved list""" + passwordfile = self.getConfig("passwordfile") + + if pw in self.passwords: + self.passwords.remove(pw) + + self.passwords.insert(0, pw) + + try: + with open(passwordfile, "wb") as f: + for pw in self.passwords: + f.write(pw + "\n") + except IOError, e: + self.logError(e) + + + def setPermissions(self, files): + for f in files: + if not exists(f): + continue + try: + if self.config['permission']['change_file']: + if isfile(f): + chmod(f, int(self.config['permission']['file'], 8)) + elif isdir(f): + chmod(f, int(self.config['permission']['folder'], 8)) + + if self.config['permission']['change_dl'] and os.name != "nt": + uid = getpwnam(self.config['permission']['user'])[2] + gid = getgrnam(self.config['permission']['group'])[2] + chown(f, uid, gid) + except Exception, e: + self.logWarning(_("Setting User and Group failed"), e) diff --git a/pyload/plugin/addon/HotFolder.py b/pyload/plugin/addon/HotFolder.py new file mode 100644 index 000000000..5eb15ab4f --- /dev/null +++ b/pyload/plugin/addon/HotFolder.py @@ -0,0 +1,70 @@ +# -*- coding: utf-8 -*- + +from __future__ import with_statement + +import time + +from os import listdir, makedirs +from os.path import exists, isfile, join +from shutil import move + +from pyload.plugin.Addon import Addon +from pyload.utils import fs_encode, safe_join + + +class HotFolder(Addon): + __name = "HotFolder" + __type = "addon" + __version = "0.12" + + __config = [("folder" , "str" , "Folder to observe" , "container"), + ("watch_file", "bool", "Observe link file" , False ), + ("keep" , "bool", "Keep added containers", True ), + ("file" , "str" , "Link file" , "links.txt")] + + __description = """Observe folder and file for changes and add container and links""" + __license = "GPLv3" + __authors = [("RaNaN", "RaNaN@pyload.de")] + + + def setup(self): + self.interval = 10 + + + def activate(self): + self.initPeriodical() + + + def periodical(self): + folder = fs_encode(self.getConfig("folder")) + + try: + if not exists(join(folder, "finished")): + makedirs(join(folder, "finished")) + + if self.getConfig("watch_file"): + with open(fs_encode(self.getConfig("file")), "a+") as f: + content = f.read().strip() + + if content: + name = "%s_%s.txt" % (self.getConfig("file"), time.strftime("%H-%M-%S_%d%b%Y")) + + with open(safe_join(folder, "finished", name), "wb") as f: + f.write(content) + + self.core.api.addPackage(f.name, [f.name], 1) + + for f in listdir(folder): + path = join(folder, f) + + if not isfile(path) or f.endswith("~") or f.startswith("#") or f.startswith("."): + continue + + newpath = join(folder, "finished", f if self.getConfig("keep") else "tmp_" + f) + move(path, newpath) + + self.logInfo(_("Added %s from HotFolder") % f) + self.core.api.addPackage(f, [newpath], 1) + + except IOError, e: + self.logError(e) diff --git a/pyload/plugin/addon/IRCInterface.py b/pyload/plugin/addon/IRCInterface.py new file mode 100644 index 000000000..3596b72ab --- /dev/null +++ b/pyload/plugin/addon/IRCInterface.py @@ -0,0 +1,431 @@ +# -*- coding: utf-8 -*- + +import re +import socket +import ssl +import time + +from pycurl import FORM_FILE +from select import select +from threading import Thread +from time import sleep +from traceback import print_exc + +from pyload.api import PackageDoesNotExists, FileDoesNotExists +from pyload.network.RequestFactory import getURL +from pyload.plugin.Addon import Addon +from pyload.utils import formatSize + + +class IRCInterface(Thread, Addon): + __name = "IRCInterface" + __type = "addon" + __version = "0.13" + + __config = [("host" , "str" , "IRC-Server Address" , "Enter your server here!"), + ("port" , "int" , "IRC-Server Port" , 6667 ), + ("ident" , "str" , "Clients ident" , "pyload-irc" ), + ("realname" , "str" , "Realname" , "pyload-irc" ), + ("ssl" , "bool", "Use SSL" , False ), + ("nick" , "str" , "Nickname the Client will take" , "pyLoad-IRC" ), + ("owner" , "str" , "Nickname the Client will accept commands from", "Enter your nick here!" ), + ("info_file", "bool", "Inform about every file finished" , False ), + ("info_pack", "bool", "Inform about every package finished" , True ), + ("captcha" , "bool", "Send captcha requests" , True )] + + __description = """Connect to irc and let owner perform different tasks""" + __license = "GPLv3" + __authors = [("Jeix", "Jeix@hasnomail.com")] + + + def __init__(self, core, manager): + Thread.__init__(self) + Addon.__init__(self, core, manager) + self.setDaemon(True) + + + def activate(self): + self.abort = False + self.more = [] + self.new_package = {} + + self.start() + + + def packageFinished(self, pypack): + try: + if self.getConfig("info_pack"): + self.response(_("Package finished: %s") % pypack.name) + except Exception: + pass + + + def downloadFinished(self, pyfile): + try: + if self.getConfig("info_file"): + self.response( + _("Download finished: %(name)s @ %(plugin)s ") % {"name": pyfile.name, "plugin": pyfile.pluginname}) + except Exception: + pass + + + def captchaTask(self, task): + if self.getConfig("captcha") and task.isTextual(): + task.handler.append(self) + task.setWaiting(60) + + page = getURL("http://www.freeimagehosting.net/upload.php", + post={"attached": (FORM_FILE, task.captchaFile)}, multipart=True) + + url = re.search(r"\[img\]([^\[]+)\[/img\]\[/url\]", page).group(1) + self.response(_("New Captcha Request: %s") % url) + self.response(_("Answer with 'c %s text on the captcha'") % task.id) + + + def run(self): + # connect to IRC etc. + self.sock = socket.socket() + host = self.getConfig("host") + self.sock.connect((host, self.getConfig("port"))) + + if self.getConfig("ssl"): + self.sock = ssl.wrap_socket(self.sock, cert_reqs=ssl.CERT_NONE) #@TODO: support custom certificate + + nick = self.getConfig("nick") + self.sock.send("NICK %s\r\n" % nick) + self.sock.send("USER %s %s bla :%s\r\n" % (nick, host, nick)) + for t in self.getConfig("owner").split(): + if t.strip().startswith("#"): + self.sock.send("JOIN %s\r\n" % t.strip()) + self.logInfo(_("Connected to"), host) + self.logInfo(_("Switching to listening mode!")) + try: + self.main_loop() + + except IRCError, ex: + self.sock.send("QUIT :byebye\r\n") + print_exc() + self.sock.close() + + + def main_loop(self): + readbuffer = "" + while True: + sleep(1) + fdset = select([self.sock], [], [], 0) + if self.sock not in fdset[0]: + continue + + if self.abort: + raise IRCError("quit") + + readbuffer += self.sock.recv(1024) + temp = readbuffer.split("\n") + readbuffer = temp.pop() + + for line in temp: + line = line.rstrip() + first = line.split() + + if first[0] == "PING": + self.sock.send("PONG %s\r\n" % first[1]) + + if first[0] == "ERROR": + raise IRCError(line) + + msg = line.split(None, 3) + if len(msg) < 4: + continue + + msg = { + "origin": msg[0][1:], + "action": msg[1], + "target": msg[2], + "text": msg[3][1:] + } + + self.handle_events(msg) + + + def handle_events(self, msg): + if not msg['origin'].split("!", 1)[0] in self.getConfig("owner").split(): + return + + if msg['target'].split("!", 1)[0] != self.getConfig("nick"): + return + + if msg['action'] != "PRIVMSG": + return + + # HANDLE CTCP ANTI FLOOD/BOT PROTECTION + if msg['text'] == "\x01VERSION\x01": + self.logDebug("Sending CTCP VERSION") + self.sock.send("NOTICE %s :%s\r\n" % (msg['origin'], "pyLoad! IRC Interface")) + return + elif msg['text'] == "\x01TIME\x01": + self.logDebug("Sending CTCP TIME") + self.sock.send("NOTICE %s :%d\r\n" % (msg['origin'], time.time())) + return + elif msg['text'] == "\x01LAG\x01": + self.logDebug("Received CTCP LAG") #: don't know how to answer + return + + trigger = "pass" + args = None + + try: + temp = msg['text'].split() + trigger = temp[0] + if len(temp) > 1: + args = temp[1:] + except Exception: + pass + + handler = getattr(self, "event_%s" % trigger, self.event_pass) + try: + res = handler(args) + for line in res: + self.response(line, msg['origin']) + except Exception, e: + self.logError(e) + + + def response(self, msg, origin=""): + if origin == "": + for t in self.getConfig("owner").split(): + self.sock.send("PRIVMSG %s :%s\r\n" % (t.strip(), msg)) + else: + self.sock.send("PRIVMSG %s :%s\r\n" % (origin.split("!", 1)[0], msg)) + + + #### Events + + def event_pass(self, args): + return [] + + + def event_status(self, args): + downloads = self.core.api.statusDownloads() + if not downloads: + return ["INFO: There are no active downloads currently."] + + temp_progress = "" + lines = ["ID - Name - Status - Speed - ETA - Progress"] + for data in downloads: + + if data.status == 5: + temp_progress = data.format_wait + else: + temp_progress = "%d%% (%s)" % (data.percent, data.format_size) + + lines.append("#%d - %s - %s - %s - %s - %s" % + ( + data.fid, + data.name, + data.statusmsg, + "%s/s" % formatSize(data.speed), + "%s" % data.format_eta, + temp_progress + )) + return lines + + + def event_queue(self, args): + ps = self.core.api.getQueueData() + + if not ps: + return ["INFO: There are no packages in queue."] + + lines = [] + for pack in ps: + lines.append('PACKAGE #%s: "%s" with %d links.' % (pack.pid, pack.name, len(pack.links))) + + return lines + + + def event_collector(self, args): + ps = self.core.api.getCollectorData() + if not ps: + return ["INFO: No packages in collector!"] + + lines = [] + for pack in ps: + lines.append('PACKAGE #%s: "%s" with %d links.' % (pack.pid, pack.name, len(pack.links))) + + return lines + + + def event_info(self, args): + if not args: + return ["ERROR: Use info like this: info <id>"] + + info = None + try: + info = self.core.api.getFileData(int(args[0])) + + except FileDoesNotExists: + return ["ERROR: Link doesn't exists."] + + return ['LINK #%s: %s (%s) [%s][%s]' % (info.fid, info.name, info.format_size, info.statusmsg, info.plugin)] + + + def event_packinfo(self, args): + if not args: + return ["ERROR: Use packinfo like this: packinfo <id>"] + + lines = [] + pack = None + try: + pack = self.core.api.getPackageData(int(args[0])) + + except PackageDoesNotExists: + return ["ERROR: Package doesn't exists."] + + id = args[0] + + self.more = [] + + lines.append('PACKAGE #%s: "%s" with %d links' % (id, pack.name, len(pack.links))) + for pyfile in pack.links: + self.more.append('LINK #%s: %s (%s) [%s][%s]' % (pyfile.fid, pyfile.name, pyfile.format_size, + pyfile.statusmsg, pyfile.plugin)) + + if len(self.more) < 6: + lines.extend(self.more) + self.more = [] + else: + lines.extend(self.more[:6]) + self.more = self.more[6:] + lines.append("%d more links do display." % len(self.more)) + + return lines + + + def event_more(self, args): + if not self.more: + return ["No more information to display."] + + lines = self.more[:6] + self.more = self.more[6:] + lines.append("%d more links do display." % len(self.more)) + + return lines + + + def event_start(self, args): + self.core.api.unpauseServer() + return ["INFO: Starting downloads."] + + + def event_stop(self, args): + self.core.api.pauseServer() + return ["INFO: No new downloads will be started."] + + + def event_add(self, args): + if len(args) < 2: + return ['ERROR: Add links like this: "add <packagename|id> links". ', + "This will add the link <link> to to the package <package> / the package with id <id>!"] + + pack = args[0].strip() + links = [x.strip() for x in args[1:]] + + count_added = 0 + count_failed = 0 + try: + id = int(pack) + pack = self.core.api.getPackageData(id) + if not pack: + return ["ERROR: Package doesn't exists."] + + #TODO add links + + return ["INFO: Added %d links to Package %s [#%d]" % (len(links), pack['name'], id)] + + except Exception: + # create new package + id = self.core.api.addPackage(pack, links, 1) + return ["INFO: Created new Package %s [#%d] with %d links." % (pack, id, len(links))] + + + def event_del(self, args): + if len(args) < 2: + return ["ERROR: Use del command like this: del -p|-l <id> [...] (-p indicates that the ids are from packages, -l indicates that the ids are from links)"] + + if args[0] == "-p": + ret = self.core.api.deletePackages(map(int, args[1:])) + return ["INFO: Deleted %d packages!" % len(args[1:])] + + elif args[0] == "-l": + ret = self.core.api.delLinks(map(int, args[1:])) + return ["INFO: Deleted %d links!" % len(args[1:])] + + else: + return ["ERROR: Use del command like this: del <-p|-l> <id> [...] (-p indicates that the ids are from packages, -l indicates that the ids are from links)"] + + + def event_push(self, args): + if not args: + return ["ERROR: Push package to queue like this: push <package id>"] + + id = int(args[0]) + try: + info = self.core.api.getPackageInfo(id) + except PackageDoesNotExists: + return ["ERROR: Package #%d does not exist." % id] + + self.core.api.pushToQueue(id) + return ["INFO: Pushed package #%d to queue." % id] + + + def event_pull(self, args): + if not args: + return ["ERROR: Pull package from queue like this: pull <package id>."] + + id = int(args[0]) + if not self.core.api.getPackageData(id): + return ["ERROR: Package #%d does not exist." % id] + + self.core.api.pullFromQueue(id) + return ["INFO: Pulled package #%d from queue to collector." % id] + + + def event_c(self, args): + """ captcha answer """ + if not args: + return ["ERROR: Captcha ID missing."] + + task = self.core.captchaManager.getTaskByID(args[0]) + if not task: + return ["ERROR: Captcha Task with ID %s does not exists." % args[0]] + + task.setResult(" ".join(args[1:])) + return ["INFO: Result %s saved." % " ".join(args[1:])] + + + def event_help(self, args): + lines = ["The following commands are available:", + "add <package|packid> <links> [...] Adds link to package. (creates new package if it does not exist)", + "queue Shows all packages in the queue", + "collector Shows all packages in collector", + "del -p|-l <id> [...] Deletes all packages|links with the ids specified", + "info <id> Shows info of the link with id <id>", + "packinfo <id> Shows info of the package with id <id>", + "more Shows more info when the result was truncated", + "start Starts all downloads", + "stop Stops the download (but not abort active downloads)", + "push <id> Push package to queue", + "pull <id> Pull package from queue", + "status Show general download status", + "help Shows this help message"] + return lines + + +class IRCError(Exception): + + def __init__(self, value): + self.value = value + + + def __str__(self): + return repr(self.value) diff --git a/pyload/plugin/addon/MergeFiles.py b/pyload/plugin/addon/MergeFiles.py new file mode 100644 index 000000000..72dfd583d --- /dev/null +++ b/pyload/plugin/addon/MergeFiles.py @@ -0,0 +1,85 @@ +# -*- coding: utf-8 -*- + +from __future__ import with_statement + +import os +import re + +from traceback import print_exc + +from pyload.plugin.Addon import Addon, threaded +from pyload.utils import safe_join, fs_encode + + +class MergeFiles(Addon): + __name = "MergeFiles" + __type = "addon" + __version = "0.13" + + __config = [("activated", "bool", "Activated", True)] + + __description = """Merges parts splitted with hjsplit""" + __license = "GPLv3" + __authors = [("and9000", "me@has-no-mail.com")] + + + BUFFER_SIZE = 4096 + + + def setup(self): + pass + + + @threaded + def packageFinished(self, pack): + files = {} + fid_dict = {} + for fid, data in pack.getChildren().iteritems(): + if re.search("\.\d{3}$", data['name']): + if data['name'][:-4] not in files: + files[data['name'][:-4]] = [] + files[data['name'][:-4]].append(data['name']) + files[data['name'][:-4]].sort() + fid_dict[data['name']] = fid + + download_folder = self.config['general']['download_folder'] + + if self.config['general']['folder_per_package']: + download_folder = safe_join(download_folder, pack.folder) + + for name, file_list in files.iteritems(): + self.logInfo(_("Starting merging of"), name) + + final_file = open(safe_join(download_folder, name), "wb") + for splitted_file in file_list: + self.logDebug("Merging part", splitted_file) + + pyfile = self.core.files.getFile(fid_dict[splitted_file]) + + pyfile.setStatus("processing") + + try: + with open(os.path.join(download_folder, splitted_file), "rb") as s_file: + size_written = 0 + s_file_size = int(os.path.getsize(os.path.join(download_folder, splitted_file))) + + while True: + f_buffer = s_file.read(self.BUFFER_SIZE) + if f_buffer: + final_file.write(f_buffer) + size_written += self.BUFFER_SIZE + pyfile.setProgress((size_written * 100) / s_file_size) + else: + break + + self.logDebug("Finished merging part", splitted_file) + + except Exception, e: + print_exc() + + finally: + pyfile.setProgress(100) + pyfile.setStatus("finished") + pyfile.release() + + self.logInfo(_("Finished merging of"), name) diff --git a/pyload/plugin/addon/MultiHome.py b/pyload/plugin/addon/MultiHome.py new file mode 100644 index 000000000..1bf78d2db --- /dev/null +++ b/pyload/plugin/addon/MultiHome.py @@ -0,0 +1,81 @@ +# -*- coding: utf-8 -*- + +from time import time + +from pyload.plugin.Addon import Addon + + +class MultiHome(Addon): + __name = "MultiHome" + __type = "addon" + __version = "0.12" + + __config = [("interfaces", "str", "Interfaces", "None")] + + __description = """Ip address changer""" + __license = "GPLv3" + __authors = [("mkaay", "mkaay@mkaay.de")] + + + def setup(self): + self.register = {} + self.interfaces = [] + self.parseInterfaces(self.getConfig("interfaces").split(";")) + if not self.interfaces: + self.parseInterfaces([self.config['download']['interface']]) + self.setConfig("interfaces", self.toConfig()) + + + def toConfig(self): + return ";".join([i.adress for i in self.interfaces]) + + + def parseInterfaces(self, interfaces): + for interface in interfaces: + if not interface or str(interface).lower() == "none": + continue + self.interfaces.append(Interface(interface)) + + + def activate(self): + requestFactory = self.core.requestFactory + oldGetRequest = requestFactory.getRequest + + def getRequest(pluginName, account=None): + iface = self.bestInterface(pluginName, account) + if iface: + iface.useFor(pluginName, account) + requestFactory.iface = lambda: iface.adress + self.logDebug("Using address", iface.adress) + return oldGetRequest(pluginName, account) + + requestFactory.getRequest = getRequest + + + def bestInterface(self, pluginName, account): + best = None + for interface in self.interfaces: + if not best or interface.lastPluginAccess(pluginName, account) < best.lastPluginAccess(pluginName, account): + best = interface + return best + + +class Interface(object): + + def __init__(self, adress): + self.adress = adress + self.history = {} + + + def lastPluginAccess(self, pluginName, account): + if (pluginName, account) in self.history: + return self.history[(pluginName, account)] + return 0 + + + def useFor(self, pluginName, account): + self.history[(pluginName, account)] = time() + + + def __repr__(self): + return "<Interface - %s>" % self.adress diff --git a/pyload/plugin/addon/RestartFailed.py b/pyload/plugin/addon/RestartFailed.py new file mode 100644 index 000000000..5611cc791 --- /dev/null +++ b/pyload/plugin/addon/RestartFailed.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.Addon import Addon + + +class RestartFailed(Addon): + __name = "RestartFailed" + __type = "addon" + __version = "1.57" + + __config = [("activated", "bool", "Activated" , True), + ("interval" , "int" , "Check interval in minutes", 90 )] + + __description = """Periodically restart all failed downloads in queue""" + __license = "GPLv3" + __authors = [("Walter Purcaro", "vuolter@gmail.com")] + + + # event_list = ["pluginConfigChanged"] + + MIN_INTERVAL = 15 * 60 #: 15m minimum check interval (value is in seconds) + + + def pluginConfigChanged(self, plugin, name, value): + if name == "interval": + interval = value * 60 + if self.MIN_INTERVAL <= interval != self.interval: + self.core.scheduler.removeJob(self.cb) + self.interval = interval + self.initPeriodical() + else: + self.logDebug("Invalid interval value, kept current") + + + def periodical(self): + self.logDebug(_("Restart failed downloads")) + self.core.api.restartFailed() + + + def setup(self): + self.interval = 0 + + + def activate(self): + self.pluginConfigChanged(self.__name, "interval", self.getConfig("interval")) diff --git a/pyload/plugin/addon/RestartSlow.py b/pyload/plugin/addon/RestartSlow.py new file mode 100644 index 000000000..8005abaea --- /dev/null +++ b/pyload/plugin/addon/RestartSlow.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- + +import pycurl + +from pyload.plugin.Addon import Addon + + +class RestartSlow(Addon): + __name = "RestartSlow" + __type = "addon" + __version = "0.02" + + __config = [("free_limit" , "int" , "Transfer speed threshold in kilobytes" , 100 ), + ("free_time" , "int" , "Sample interval in minutes" , 5 ), + ("premium_limit", "int" , "Transfer speed threshold for premium download in kilobytes", 300 ), + ("premium_time" , "int" , "Sample interval for premium download in minutes" , 2 ), + ("safe_mode" , "bool", "Don't restart if download is not resumable" , True)] + + __description = """Restart slow downloads""" + __license = "GPLv3" + __authors = [("Walter Purcaro", "vuolter@gmail.com")] + + + event_map = {'download-start': "downloadStarts"} + + + def setup(self): + self.info = {'chunk': {}} + + + def periodical(self): + if not self.pyfile.req.dl: + return + + if self.getConfig("safe_mode") and not self.pyfile.plugin.resumeDownload: + time = 30 + limit = 5 + else: + type = "premium" if self.pyfile.plugin.premium else "free" + time = max(30, self.getConfig("%s_time" % type) * 60) + limit = max(5, self.getConfig("%s_limit" % type) * 1024) + + chunks = [chunk for chunk in self.pyfile.req.dl.chunks \ + if chunk.id not in self.info['chunk'] or self.info['chunk'][chunk.id] not is (time, limit)] + + for chunk in chunks: + chunk.c.setopt(pycurl.LOW_SPEED_TIME , time) + chunk.c.setopt(pycurl.LOW_SPEED_LIMIT, limit) + + self.info['chunk'][chunk.id] = (time, limit) + + + def downloadStarts(self, pyfile, url, filename): + if self.cb or (self.getConfig("safe_mode") and not pyfile.plugin.resumeDownload): + return + + self.initPeriodical() diff --git a/pyload/plugin/addon/SkipRev.py b/pyload/plugin/addon/SkipRev.py new file mode 100644 index 000000000..6ff590792 --- /dev/null +++ b/pyload/plugin/addon/SkipRev.py @@ -0,0 +1,77 @@ +# -*- coding: utf-8 -*- + +from urllib import unquote +from urlparse import urlparse + +from pyload.plugin.Addon import Addon +from pyload.plugin.Plugin import SkipDownload + + +class SkipRev(Adoon): + __name = "SkipRev" + __type = "addon" + __version = "0.15" + + __config = [("tokeep", "int", "Number of rev files to keep for package (-1 to auto)", -1)] + + __description = """Skip files ending with extension rev""" + __license = "GPLv3" + __authors = [("Walter Purcaro", "vuolter@gmail.com")] + + + def _setup(self): + super(self.pyfile.plugin, self).setup() + if self.pyfile.hasStatus("skipped"): + raise SkipDownload(self.pyfile.getStatusName() or self.pyfile.pluginname) + + + def pyname(self, pyfile): + url = pyfile.url + plugin = pyfile.plugin + + if hasattr(plugin, "info") and 'name' in plugin.info and plugin.info['name']: + name = plugin.info['name'] + + elif hasattr(plugin, "parseInfos"): + name = next(plugin.parseInfos([url]))['name'] + + elif hasattr(plugin, "getInfo"): #@NOTE: if parseInfos was not found, getInfo should be missing too + name = plugin.getInfo(url)['name'] + + else: + self.logWarning("Unable to grab file name") + name = urlparse(unquote(url)).path.split('/')[-1]) + + return name + + + def downloadPreparing(self, pyfile): + if pyfile.getStatusName() is "unskipped" or not pyname(pyfile).endswith(".rev"): + return + + tokeep = self.getConfig("tokeep") + + if tokeep: + saved = [True for link in pyfile.package().getChildren() \ + if link.name.endswith(".rev") and (link.hasStatus("finished") or link.hasStatus("downloading"))].count(True) + + if not saved or saved < tokeep: #: keep one rev at least in auto mode + return + + pyfile.setCustomStatus("SkipRev", "skipped") + pyfile.plugin.setup = _setup #: work-around: inject status checker inside the preprocessing routine of the plugin + + + def downloadFailed(self, pyfile): + tokeep = self.getConfig("tokeep") + + if not tokeep: + return + + for link in pyfile.package().getChildren(): + if link.hasStatus("skipped") and link.name.endswith(".rev"): + if tokeep > -1 or pyfile.name.endswith(".rev"): + link.setStatus("queued") + else: + link.setCustomStatus("unskipped", "queued") + return diff --git a/pyload/plugin/addon/UnSkipOnFail.py b/pyload/plugin/addon/UnSkipOnFail.py new file mode 100644 index 000000000..b640c7daa --- /dev/null +++ b/pyload/plugin/addon/UnSkipOnFail.py @@ -0,0 +1,87 @@ +# -*- coding: utf-8 -*- + +from os.path import basename + +from pyload.datatype.File import PyFile +from pyload.plugin.Addon import Addon +from pyload.utils import fs_encode + + +class UnSkipOnFail(Addon): + __name = "UnSkipOnFail" + __type = "addon" + __version = "0.02" + + __config = [("activated", "bool", "Activated", True)] + + __description = """When a download fails, restart skipped duplicates""" + __license = "GPLv3" + __authors = [("hagg", "")] + + + def downloadFailed(self, pyfile): + pyfile_name = basename(pyfile.name) + pid = pyfile.package().id + msg = _('look for skipped duplicates for %s (pid:%s)') + self.logInfo(msg % (pyfile_name, pid)) + dups = self.findDuplicates(pyfile) + for link in dups: + # check if link is "skipped"(=4) + if link.status == 4: + lpid = link.packageID + self.logInfo(_('restart "%s" (pid:%s)') % (pyfile_name, lpid)) + self.setLinkStatus(link, "queued") + + + def findDuplicates(self, pyfile): + """ Search all packages for duplicate links to "pyfile". + Duplicates are links that would overwrite "pyfile". + To test on duplicity the package-folder and link-name + of twolinks are compared (basename(link.name)). + So this method returns a list of all links with equal + package-folders and filenames as "pyfile", but except + the data for "pyfile" iotselöf. + It does MOT check the link's status. + """ + dups = [] + pyfile_name = fs_encode(basename(pyfile.name)) + # get packages (w/o files, as most file data is useless here) + queue = self.core.api.getQueue() + for package in queue: + # check if package-folder equals pyfile's package folder + if fs_encode(package.folder) == fs_encode(pyfile.package().folder): + # now get packaged data w/ files/links + pdata = self.core.api.getPackageData(package.pid) + if pdata.links: + for link in pdata.links: + link_name = fs_encode(basename(link.name)) + # check if link name collides with pdata's name + if link_name == pyfile_name: + # at last check if it is not pyfile itself + if link.fid != pyfile.id: + dups.append(link) + return dups + + + def setLinkStatus(self, link, new_status): + """ Change status of "link" to "new_status". + "link" has to be a valid FileData object, + "new_status" has to be a valid status name + (i.e. "queued" for this Plugin) + It creates a temporary PyFile object using + "link" data, changes its status, and tells + the core.files-manager to save its data. + """ + pyfile = PyFile(self.core.files, + link.fid, + link.url, + link.name, + link.size, + link.status, + link.error, + link.plugin, + link.packageID, + link.order) + pyfile.setStatus(new_status) + self.core.files.save() + pyfile.release() diff --git a/pyload/plugin/addon/UpdateManager.py b/pyload/plugin/addon/UpdateManager.py new file mode 100644 index 000000000..c5c34d1c8 --- /dev/null +++ b/pyload/plugin/addon/UpdateManager.py @@ -0,0 +1,305 @@ +# -*- coding: utf-8 -*- + +from __future__ import with_statement + +import re +import sys + +from operator import itemgetter +from os import path, remove, stat + +from pyload.network.RequestFactory import getURL +from pyload.plugin.Addon import Expose, Addon, threaded +from pyload.utils import safe_join + + +class UpdateManager(Addon): + __name = "UpdateManager" + __type = "addon" + __version = "0.42" + + __config = [("activated" , "bool" , "Activated" , True ), + ("mode" , "pyLoad + plugins;plugins only", "Check updates for" , "pyLoad + plugins"), + ("interval" , "int" , "Check interval in hours" , 8 ), + ("autorestart" , "bool" , "Automatically restart pyLoad when required" , True ), + ("reloadplugins", "bool" , "Monitor plugins for code changes in debug mode", True ), + ("nodebugupdate", "bool" , "Don't check for updates in debug mode" , True )] + + __description = """Check for updates""" + __license = "GPLv3" + __authors = [("Walter Purcaro", "vuolter@gmail.com")] + + + # event_list = ["pluginConfigChanged"] + + SERVER_URL = "http://updatemanager.pyload.org" + VERSION = re.compile(r'__version.*=.*("|\')([\d.]+)') + MIN_INTERVAL = 3 * 60 * 60 #: 3h minimum check interval (value is in seconds) + + + def pluginConfigChanged(self, plugin, name, value): + if name == "interval": + interval = value * 60 * 60 + if self.MIN_INTERVAL <= interval != self.interval: + self.core.scheduler.removeJob(self.cb) + self.interval = interval + self.initPeriodical() + else: + self.logDebug("Invalid interval value, kept current") + + elif name == "reloadplugins": + if self.cb2: + self.core.scheduler.removeJob(self.cb2) + if value is True and self.core.debug: + self.periodical2() + + + def activate(self): + self.pluginConfigChanged(self.__name, "interval", self.getConfig("interval")) + x = lambda: self.pluginConfigChanged(self.__name, "reloadplugins", self.getConfig("reloadplugins")) + self.core.scheduler.addJob(10, x, threaded=False) + + + def deactivate(self): + self.pluginConfigChanged(self.__name, "reloadplugins", False) + + + def setup(self): + self.cb2 = None + self.interval = 0 + self.updating = False + self.info = {'pyload': False, 'version': None, 'plugins': False} + self.mtimes = {} #: store modification time for each plugin + + + def periodical2(self): + if not self.updating: + self.autoreloadPlugins() + + self.cb2 = self.core.scheduler.addJob(4, self.periodical2, threaded=False) + + + @Expose + def autoreloadPlugins(self): + """ reload and reindex all modified plugins """ + modules = filter( + lambda m: m and (m.__name.startswith("pyload.plugin.") or + m.__name.startswith("userplugins.")) and + m.__name.count(".") >= 2, sys.modules.itervalues() + ) + + reloads = [] + + for m in modules: + root, type, name = m.__name.rsplit(".", 2) + id = (type, name) + if type in self.core.pluginManager.plugins: + f = m.__file__.replace(".pyc", ".py") + if not path.isfile(f): + continue + + mtime = stat(f).st_mtime + + if id not in self.mtimes: + self.mtimes[id] = mtime + elif self.mtimes[id] < mtime: + reloads.append(id) + self.mtimes[id] = mtime + + return True if self.core.pluginManager.reloadPlugins(reloads) else False + + + def periodical(self): + if self.info['pyload'] or self.getConfig("nodebugupdate") and self.core.debug: + return + + self.updateThread() + + + def server_request(self): + try: + return getURL(self.SERVER_URL, get={'v': self.core.api.getServerVersion()}).splitlines() + except Exception: + self.logWarning(_("Unable to contact server to get updates")) + + + @threaded + def updateThread(self): + self.updating = True + + status = self.update(onlyplugin=self.getConfig("mode") == "plugins only") + + if status is 2 and self.getConfig("autorestart"): + self.core.api.restart() + else: + self.updating = False + + + @Expose + def updatePlugins(self): + """ simple wrapper for calling plugin update quickly """ + return self.update(onlyplugin=True) + + + @Expose + def update(self, onlyplugin=False): + """ check for updates """ + data = self.server_request() + + if not data: + exitcode = 0 + + elif data[0] == "None": + self.logInfo(_("No new pyLoad version available")) + updates = data[1:] + exitcode = self._updatePlugins(updates) + + elif onlyplugin: + exitcode = 0 + + else: + newversion = data[0] + self.logInfo(_("*** New pyLoad Version %s available ***") % newversion) + self.logInfo(_("*** Get it here: https://github.com/pyload/pyload/releases ***")) + exitcode = 3 + self.info['pyload'] = True + self.info['version'] = newversion + + return exitcode #: 0 = No plugins updated; 1 = Plugins updated; 2 = Plugins updated, but restart required; 3 = No plugins updated, new pyLoad version available + + + def _updatePlugins(self, updates): + """ check for plugin updates """ + + if self.info['plugins']: + return False #: plugins were already updated + + exitcode = 0 + updated = [] + + url = updates[0] + schema = updates[1].split('|') + + if "BLACKLIST" in updates: + blacklist = updates[updates.index('BLACKLIST') + 1:] + updates = updates[2:updates.index('BLACKLIST')] + else: + blacklist = None + updates = updates[2:] + + upgradable = [dict(zip(schema, x.split('|'))) for x in updates] + blacklisted = [(x.split('|')[0], x.split('|')[1].rsplit('.', 1)[0]) for x in blacklist] if blacklist else [] + + if blacklist: + # Protect internal plugins against removing + for i, t, n in enumerate(blacklisted): + if t == "internal": + blacklisted.pop(i) + continue + + for idx, plugin in enumerate(upgradable): + if n == plugin['name'] and t == plugin['type']: + upgradable.pop(idx) + break + + for t, n in self.removePlugins(sorted(blacklisted)): + self.logInfo(_("Removed blacklisted plugin [%(type)s] %(name)s") % { + 'type': t, + 'name': n, + }) + + for plugin in sorted(upgradable, key=itemgetter("type", "name")): + filename = plugin['name'] + type = plugin['type'] + version = plugin['version'] + + if filename.endswith(".pyc"): + name = filename[:filename.find("_")] + else: + name = filename.replace(".py", "") + + plugins = getattr(self.core.pluginManager, "%sPlugins" % type) + + oldver = float(plugins[name]['version']) if name in plugins else None + newver = float(version) + + if not oldver: + msg = "New plugin: [%(type)s] %(name)s (v%(newver).2f)" + elif newver > oldver: + msg = "New version of plugin: [%(type)s] %(name)s (v%(oldver).2f -> v%(newver).2f)" + else: + continue + + self.logInfo(_(msg) % {'type' : type, + 'name' : name, + 'oldver': oldver, + 'newver': newver}) + try: + content = getURL(url % plugin) + m = self.VERSION.search(content) + + if m and m.group(2) == version: + with open(safe_join("userplugins", prefix, filename), "wb") as f: + f.write(content) + + updated.append((prefix, name)) + else: + raise Exception, _("Version mismatch") + + except Exception, e: + self.logError(_("Error updating plugin: %s") % filename, str(e)) + + if updated: + reloaded = self.core.pluginManager.reloadPlugins(updated) + if reloaded: + self.logInfo(_("Plugins updated and reloaded")) + exitcode = 1 + else: + self.logInfo(_("*** Plugins have been updated, but need a pyLoad restart to be reloaded ***")) + self.info['plugins'] = True + exitcode = 2 + else: + self.logInfo(_("No plugin updates available")) + + return exitcode #: 0 = No plugins updated; 1 = Plugins updated; 2 = Plugins updated, but restart required + + + @Expose + def removePlugins(self, type_plugins): + """ delete plugins from disk """ + + if not type_plugins: + return + + self.logDebug("Requested deletion of plugins: %s" % type_plugins) + + removed = [] + + for type, name in type_plugins: + err = False + file = name + ".py" + + for root in ("userplugins", path.join(pypath, "pyload", "plugins")): + + filename = safe_join(root, type, file) + try: + remove(filename) + except Exception, e: + self.logDebug("Error deleting: %s" % path.basename(filename), e) + err = True + + filename += "c" + if path.isfile(filename): + try: + if type == "addon": + self.manager.deactivateAddon(name) + remove(filename) + except Exception, e: + self.logDebug("Error deleting: %s" % path.basename(filename), e) + err = True + + if not err: + id = (type, name) + removed.append(id) + + return removed #: return a list of the plugins successfully removed diff --git a/pyload/plugin/addon/WindowsPhoneToastNotify.py b/pyload/plugin/addon/WindowsPhoneToastNotify.py new file mode 100644 index 000000000..fadc17d04 --- /dev/null +++ b/pyload/plugin/addon/WindowsPhoneToastNotify.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- + +import httplib +import time + +from pyload.plugin.Addon import Addon + + +class WindowsPhoneToastNotify(Addon): + __name = "WindowsPhoneToastNotify" + __type = "addon" + __version = "0.03" + + __config = [("force" , "bool", "Force even if client is connected" , False), + ("pushId" , "str" , "pushId" , "" ), + ("pushUrl" , "str" , "pushUrl" , "" ), + ("pushTimeout", "int" , "Timeout between notifications in seconds", 0 )] + + __description = """Send push notifications to Windows Phone""" + __license = "GPLv3" + __authors = [("Andy Voigt", "phone-support@hotmail.de")] + + + def getXmlData(self): + myxml = ("<?xml version='1.0' encoding='utf-8'?> <wp:Notification xmlns:wp='WPNotification'> " + "<wp:Toast> <wp:Text1>Pyload Mobile</wp:Text1> <wp:Text2>Captcha waiting!</wp:Text2> " + "</wp:Toast> </wp:Notification>") + return myxml + + + def doRequest(self): + URL = self.getConfig("pushUrl") + request = self.getXmlData() + webservice = httplib.HTTP(URL) + webservice.putrequest("POST", self.getConfig("pushId")) + webservice.putheader("Host", URL) + webservice.putheader("Content-type", "text/xml") + webservice.putheader("X-NotificationClass", "2") + webservice.putheader("X-WindowsPhone-Target", "toast") + webservice.putheader("Content-length", "%d" % len(request)) + webservice.endheaders() + webservice.send(request) + webservice.close() + self.setStorage("LAST_NOTIFY", time.time()) + + + def captchaTask(self, task): + if not self.getConfig("pushId") or not self.getConfig("pushUrl"): + return False + + if self.core.isClientConnected() and not self.getConfig("force"): + return False + + if (time.time() - float(self.getStorage("LAST_NOTIFY", 0))) < self.getConf("pushTimeout"): + return False + + self.doRequest() diff --git a/pyload/plugin/addon/XMPPInterface.py b/pyload/plugin/addon/XMPPInterface.py new file mode 100644 index 000000000..8baffe284 --- /dev/null +++ b/pyload/plugin/addon/XMPPInterface.py @@ -0,0 +1,252 @@ +# -*- coding: utf-8 -*- + +from pyxmpp import streamtls +from pyxmpp.all import JID, Message +from pyxmpp.interface import implements +from pyxmpp.interfaces import * +from pyxmpp.jabber.client import JabberClient + +from pyload.plugin.addon.IRCInterface import IRCInterface + + +class XMPPInterface(IRCInterface, JabberClient): + __name = "XMPPInterface" + __type = "addon" + __version = "0.11" + + __config = [("jid" , "str" , "Jabber ID" , "user@exmaple-jabber-server.org" ), + ("pw" , "str" , "Password" , "" ), + ("tls" , "bool", "Use TLS" , False ), + ("owners" , "str" , "List of JIDs accepting commands from", "me@icq-gateway.org;some@msn-gateway.org"), + ("info_file", "bool", "Inform about every file finished" , False ), + ("info_pack", "bool", "Inform about every package finished" , True ), + ("captcha" , "bool", "Send captcha requests" , True )] + + __description = """Connect to jabber and let owner perform different tasks""" + __license = "GPLv3" + __authors = [("RaNaN", "RaNaN@pyload.org")] + + + implements(IMessageHandlersProvider) + + + def __init__(self, core, manager): + IRCInterface.__init__(self, core, manager) + + self.jid = JID(self.getConfig("jid")) + password = self.getConfig("pw") + + # if bare JID is provided add a resource -- it is required + if not self.jid.resource: + self.jid = JID(self.jid.node, self.jid.domain, "pyLoad") + + if self.getConfig("tls"): + tls_settings = streamtls.TLSSettings(require=True, verify_peer=False) + auth = ("sasl:PLAIN", "sasl:DIGEST-MD5") + else: + tls_settings = None + auth = ("sasl:DIGEST-MD5", "digest") + + # setup client with provided connection information + # and identity data + JabberClient.__init__(self, self.jid, password, + disco_name="pyLoad XMPP Client", disco_type="bot", + tls_settings=tls_settings, auth_methods=auth) + + self.interface_providers = [ + VersionHandler(self), + self, + ] + + + def activate(self): + self.new_package = {} + + self.start() + + + def packageFinished(self, pypack): + try: + if self.getConfig("info_pack"): + self.announce(_("Package finished: %s") % pypack.name) + except Exception: + pass + + + def downloadFinished(self, pyfile): + try: + if self.getConfig("info_file"): + self.announce( + _("Download finished: %(name)s @ %(plugin)s") % {"name": pyfile.name, "plugin": pyfile.pluginname}) + except Exception: + pass + + + def run(self): + # connect to IRC etc. + self.connect() + try: + self.loop() + except Exception, ex: + self.logError(ex) + + + def stream_state_changed(self, state, arg): + """This one is called when the state of stream connecting the component + to a server changes. This will usually be used to let the user + know what is going on.""" + self.logDebug("*** State changed: %s %r ***" % (state, arg)) + + + def disconnected(self): + self.logDebug("Client was disconnected") + + + def stream_closed(self, stream): + self.logDebug("Stream was closed", stream) + + + def stream_error(self, err): + self.logDebug("Stream Error", err) + + + def get_message_handlers(self): + """Return list of (message_type, message_handler) tuples. + + The handlers returned will be called when matching message is received + in a client session.""" + return [("normal", self.message)] + + + def message(self, stanza): + """Message handler for the component.""" + subject = stanza.get_subject() + body = stanza.get_body() + t = stanza.get_type() + self.logDebug("Message from %s received." % unicode(stanza.get_from())) + self.logDebug("Body: %s Subject: %s Type: %s" % (body, subject, t)) + + if t == "headline": + # 'headline' messages should never be replied to + return True + if subject: + subject = u"Re: " + subject + + to_jid = stanza.get_from() + from_jid = stanza.get_to() + + #j = JID() + to_name = to_jid.as_utf8() + from_name = from_jid.as_utf8() + + names = self.getConfig("owners").split(";") + + if to_name in names or to_jid.node + "@" + to_jid.domain in names: + messages = [] + + trigger = "pass" + args = None + + try: + temp = body.split() + trigger = temp[0] + if len(temp) > 1: + args = temp[1:] + except Exception: + pass + + handler = getattr(self, "event_%s" % trigger, self.event_pass) + try: + res = handler(args) + for line in res: + m = Message( + to_jid=to_jid, + from_jid=from_jid, + stanza_type=stanza.get_type(), + subject=subject, + body=line) + + messages.append(m) + except Exception, e: + self.logError(e) + + return messages + + else: + return True + + + def response(self, msg, origin=""): + return self.announce(msg) + + + def announce(self, message): + """ send message to all owners""" + for user in self.getConfig("owners").split(";"): + self.logDebug("Send message to", user) + + to_jid = JID(user) + + m = Message(from_jid=self.jid, + to_jid=to_jid, + stanza_type="chat", + body=message) + + stream = self.get_stream() + if not stream: + self.connect() + stream = self.get_stream() + + stream.send(m) + + + def beforeReconnecting(self, ip): + self.disconnect() + + + def afterReconnecting(self, ip): + self.connect() + + +class VersionHandler(object): + """Provides handler for a version query. + + This class will answer version query and announce 'jabber:iq:version' namespace + in the client's disco#info results.""" + + implements(IIqHandlersProvider, IFeaturesProvider) + + + def __init__(self, client): + """Just remember who created this.""" + self.client = client + + + def get_features(self): + """Return namespace which should the client include in its reply to a + disco#info query.""" + return ["jabber:iq:version"] + + + def get_iq_get_handlers(self): + """Return list of tuples (element_name, namespace, handler) describing + handlers of <iq type='get'/> stanzas""" + return [("query", "jabber:iq:version", self.get_version)] + + + def get_iq_set_handlers(self): + """Return empty list, as this class provides no <iq type='set'/> stanza handler.""" + return [] + + + def get_version(self, iq): + """Handler for jabber:iq:version queries. + + jabber:iq:version queries are not supported directly by PyXMPP, so the + XML node is accessed directly through the libxml2 API. This should be + used very carefully!""" + iq = iq.make_result_response() + q = iq.new_query("jabber:iq:version") + q.newTextChild(q.ns(), "name", "Echo component") + q.newTextChild(q.ns(), "version", "1.0") + return iq diff --git a/pyload/plugin/addon/__init__.py b/pyload/plugin/addon/__init__.py new file mode 100644 index 000000000..40a96afc6 --- /dev/null +++ b/pyload/plugin/addon/__init__.py @@ -0,0 +1 @@ +# -*- coding: utf-8 -*- diff --git a/pyload/plugin/captcha/AdYouLike.py b/pyload/plugin/captcha/AdYouLike.py new file mode 100644 index 000000000..9c32d0569 --- /dev/null +++ b/pyload/plugin/captcha/AdYouLike.py @@ -0,0 +1,107 @@ +# -*- coding: utf-8 -*- + +import re + +from pyload.plugin.Captcha import Captcha +from pyload.utils import json_loads + + +class AdYouLike(Captcha): + __name = "AdYouLike" + __type = "captcha" + __version = "0.02" + + __description = """AdYouLike captcha service plugin""" + __license = "GPLv3" + __authors = [("Walter Purcaro", "vuolter@gmail.com")] + + + AYL_PATTERN = r'Adyoulike\.create\s*\((.+?)\)' + CALLBACK_PATTERN = r'(Adyoulike\.g\._jsonp_\d+)' + + + def detect_key(self, html=None): + if not html: + if hasattr(self.plugin, "html") and self.plugin.html: + html = self.plugin.html + else: + errmsg = _("AdYouLike html not found") + self.plugin.fail(errmsg) + raise TypeError(errmsg) + + m = re.search(self.AYL_PATTERN, html) + n = re.search(self.CALLBACK_PATTERN, html) + if m and n: + self.key = (m.group(1).strip(), n.group(1).strip()) + self.plugin.logDebug("AdYouLike ayl|callback: %s | %s" % self.key) + return self.key #: key is the tuple(ayl, callback) + else: + self.plugin.logDebug("AdYouLike ayl or callback not found") + return None + + + def challenge(self, key=None): + if not key: + if self.detect_key(): + key = self.key + else: + errmsg = _("AdYouLike key not found") + self.plugin.fail(errmsg) + raise TypeError(errmsg) + + ayl, callback = key + + # {"adyoulike":{"key":"P~zQ~O0zV0WTiAzC-iw0navWQpCLoYEP"}, + # "all":{"element_id":"ayl_private_cap_92300","lang":"fr","env":"prod"}} + ayl = json_loads(ayl) + + html = self.plugin.req.load("http://api-ayl.appspot.com/challenge", + get={'key' : ayl['adyoulike']['key'], + 'env' : ayl['all']['env'], + 'callback': callback}) + try: + challenge = json_loads(re.search(callback + r'\s*\((.+?)\)', html).group(1)) + except Exception: + errmsg = _("AdYouLike challenge pattern not found") + self.plugin.error(errmsg) + raise ValueError(errmsg) + + self.plugin.logDebug("AdYouLike challenge: %s" % challenge) + + return self.result(ayl, challenge) + + + def result(self, server, challenge): + # Adyoulike.g._jsonp_5579316662423138 + # ({"translations":{"fr":{"instructions_visual":"Recopiez « Soonnight » ci-dessous :"}}, + # "site_under":true,"clickable":true,"pixels":{"VIDEO_050":[],"DISPLAY":[],"VIDEO_000":[],"VIDEO_100":[], + # "VIDEO_025":[],"VIDEO_075":[]},"medium_type":"image/adyoulike", + # "iframes":{"big":"<iframe src=\"http://www.soonnight.com/campagn.html\" scrolling=\"no\" + # height=\"250\" width=\"300\" frameborder=\"0\"></iframe>"},"shares":{},"id":256, + # "token":"e6QuI4aRSnbIZJg02IsV6cp4JQ9~MjA1","formats":{"small":{"y":300,"x":0,"w":300,"h":60}, + # "big":{"y":0,"x":0,"w":300,"h":250},"hover":{"y":440,"x":0,"w":300,"h":60}}, + # "tid":"SqwuAdxT1EZoi4B5q0T63LN2AkiCJBg5"}) + + if isinstance(server, basestring): + server = json_loads(server) + + if isinstance(challenge, basestring): + challenge = json_loads(challenge) + + try: + instructions_visual = challenge['translations'][server['all']['lang']]['instructions_visual'] + result = re.search(u'«(.+?)»', instructions_visual).group(1).strip() + except Exception: + errmsg = _("AdYouLike result not found") + self.plugin.error(errmsg) + raise ValueError(errmsg) + + result = {'_ayl_captcha_engine' : "adyoulike", + '_ayl_env' : server['all']['env'], + '_ayl_tid' : challenge['tid'], + '_ayl_token_challenge': challenge['token'], + '_ayl_response' : response} + + self.plugin.logDebug("AdYouLike result: %s" % result) + + return result diff --git a/pyload/plugin/captcha/AdsCaptcha.py b/pyload/plugin/captcha/AdsCaptcha.py new file mode 100644 index 000000000..f879151ff --- /dev/null +++ b/pyload/plugin/captcha/AdsCaptcha.py @@ -0,0 +1,77 @@ +# -*- coding: utf-8 -*- + +import re + +from random import random + +from pyload.plugin.Captcha import Captcha + + +class AdsCaptcha(Captcha): + __name = "AdsCaptcha" + __type = "captcha" + __version = "0.06" + + __description = """AdsCaptcha captcha service plugin""" + __license = "GPLv3" + __authors = [("pyLoad Team", "admin@pyload.org")] + + + CAPTCHAID_PATTERN = r'api\.adscaptcha\.com/Get\.aspx\?[^"\']*CaptchaId=(\d+)' + PUBLICKEY_PATTERN = r'api\.adscaptcha\.com/Get\.aspx\?[^"\']*PublicKey=([\w-]+)' + + + def detect_key(self, html=None): + if not html: + if hasattr(self.plugin, "html") and self.plugin.html: + html = self.plugin.html + else: + errmsg = _("AdsCaptcha html not found") + self.plugin.fail(errmsg) + raise TypeError(errmsg) + + m = re.search(self.PUBLICKEY_PATTERN, html) + n = re.search(self.CAPTCHAID_PATTERN, html) + if m and n: + self.key = (m.group(1).strip(), n.group(1).strip()) #: key is the tuple(PublicKey, CaptchaId) + self.plugin.logDebug("AdsCaptcha key|id: %s | %s" % self.key) + return self.key + else: + self.plugin.logDebug("AdsCaptcha key or id not found") + return None + + + def challenge(self, key=None): + if not key: + if self.detect_key(): + key = self.key + else: + errmsg = _("AdsCaptcha key not found") + self.plugin.fail(errmsg) + raise TypeError(errmsg) + + PublicKey, CaptchaId = key + + html = self.plugin.req.load("http://api.adscaptcha.com/Get.aspx", get={'CaptchaId': CaptchaId, 'PublicKey': PublicKey}) + try: + challenge = re.search("challenge: '(.+?)',", html).group(1) + server = re.search("server: '(.+?)',", html).group(1) + except Exception: + errmsg = _("AdsCaptcha challenge pattern not found") + self.plugin.error(errmsg) + raise ValueError(errmsg) + + self.plugin.logDebug("AdsCaptcha challenge: %s" % challenge) + + return challenge, self.result(server, challenge) + + + def result(self, server, challenge): + result = self.plugin.decryptCaptcha("%sChallenge.aspx" % server, + get={'cid': challenge, 'dummy': random()}, + cookies=True, + imgtype="jpg") + + self.plugin.logDebug("AdsCaptcha result: %s" % result) + + return result diff --git a/pyload/plugin/captcha/ReCaptcha.py b/pyload/plugin/captcha/ReCaptcha.py new file mode 100644 index 000000000..076a30214 --- /dev/null +++ b/pyload/plugin/captcha/ReCaptcha.py @@ -0,0 +1,73 @@ +# -*- coding: utf-8 -*- + +import re + +from pyload.plugin.Captcha import Captcha + + +class ReCaptcha(Captcha): + __name = "ReCaptcha" + __type = "captcha" + __version = "0.08" + + __description = """ReCaptcha captcha service plugin""" + __license = "GPLv3" + __authors = [("pyLoad Team", "admin@pyload.org")] + + + KEY_PATTERN = r'recaptcha(?:/api|\.net)/(?:challenge|noscript)\?k=([\w-]+)' + KEY_AJAX_PATTERN = r'Recaptcha\.create\s*\(\s*["\']([\w-]+)' + + + def detect_key(self, html=None): + if not html: + if hasattr(self.plugin, "html") and self.plugin.html: + html = self.plugin.html + else: + errmsg = _("ReCaptcha html not found") + self.plugin.fail(errmsg) + raise TypeError(errmsg) + + m = re.search(self.KEY_PATTERN, html) or re.search(self.KEY_AJAX_PATTERN, html) + if m: + self.key = m.group(1).strip() + self.plugin.logDebug("ReCaptcha key: %s" % self.key) + return self.key + else: + self.plugin.logDebug("ReCaptcha key not found") + return None + + + def challenge(self, key=None): + if not key: + if self.detect_key(): + key = self.key + else: + errmsg = _("ReCaptcha key not found") + self.plugin.fail(errmsg) + raise TypeError(errmsg) + + html = self.plugin.req.load("http://www.google.com/recaptcha/api/challenge", get={'k': key}) + try: + challenge = re.search("challenge : '(.+?)',", html).group(1) + server = re.search("server : '(.+?)',", html).group(1) + except Exception: + errmsg = _("ReCaptcha challenge pattern not found") + self.plugin.error(errmsg) + raise ValueError(errmsg) + + self.plugin.logDebug("ReCaptcha challenge: %s" % challenge) + + return challenge, self.result(server, challenge) + + + def result(self, server, challenge): + result = self.plugin.decryptCaptcha("%simage" % server, + get={'c': challenge}, + cookies=True, + forceUser=True, + imgtype="jpg") + + self.plugin.logDebug("ReCaptcha result: %s" % result) + + return result diff --git a/pyload/plugin/captcha/SolveMedia.py b/pyload/plugin/captcha/SolveMedia.py new file mode 100644 index 000000000..c2b1ba7eb --- /dev/null +++ b/pyload/plugin/captcha/SolveMedia.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- + +import re + +from pyload.plugin.Captcha import Captcha + + +class SolveMedia(Captcha): + __name = "SolveMedia" + __type = "captcha" + __version = "0.06" + + __description = """SolveMedia captcha service plugin""" + __license = "GPLv3" + __authors = [("pyLoad Team", "admin@pyload.org")] + + + KEY_PATTERN = r'api\.solvemedia\.com/papi/challenge\.(?:no)?script\?k=(.+?)["\']' + + + def challenge(self, key=None): + if not key: + if self.detect_key(): + key = self.key + else: + errmsg = _("SolveMedia key not found") + self.plugin.fail(errmsg) + raise TypeError(errmsg) + + html = self.plugin.req.load("http://api.solvemedia.com/papi/challenge.noscript", get={'k': key}) + try: + challenge = re.search(r'<input type=hidden name="adcopy_challenge" id="adcopy_challenge" value="([^"]+)">', + html).group(1) + server = "http://api.solvemedia.com/papi/media" + except Exception: + errmsg = _("SolveMedia challenge pattern not found") + self.plugin.error(errmsg) + raise ValueError(errmsg) + + self.plugin.logDebug("SolveMedia challenge: %s" % challenge) + + return challenge, self.result(server, challenge) + + + def result(self, server, challenge): + result = self.plugin.decryptCaptcha(server, get={'c': challenge}, imgtype="gif") + + self.plugin.logDebug("SolveMedia result: %s" % result) + + return result diff --git a/pyload/plugin/captcha/__init__.py b/pyload/plugin/captcha/__init__.py new file mode 100644 index 000000000..40a96afc6 --- /dev/null +++ b/pyload/plugin/captcha/__init__.py @@ -0,0 +1 @@ +# -*- coding: utf-8 -*- diff --git a/pyload/plugin/container/CCF.py b/pyload/plugin/container/CCF.py new file mode 100644 index 000000000..943c114c8 --- /dev/null +++ b/pyload/plugin/container/CCF.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- + +from __future__ import with_statement + +import re + +from os import makedirs +from os.path import exists +from urllib2 import build_opener + +from MultipartPostHandler import MultipartPostHandler + +from pyload.plugin.Container import Container +from pyload.utils import safe_join + + +class CCF(Container): + __name = "CCF" + __version = "0.20" + + __pattern = r'.+\.ccf' + + __description = """CCF container decrypter plugin""" + __license = "GPLv3" + __authors = [("Willnix", "Willnix@pyload.org")] + + + def decrypt(self, pyfile): + infile = pyfile.url.replace("\n", "") + + opener = build_opener(MultipartPostHandler) + params = {"src": "ccf", + "filename": "test.ccf", + "upload": open(infile, "rb")} + tempdlc_content = opener.open('http://service.jdownloader.net/dlcrypt/getDLC.php', params).read() + + download_folder = self.config['general']['download_folder'] + + tempdlc_name = safe_join(download_folder, "tmp_%s.dlc" % pyfile.name) + with open(tempdlc_name, "w") as tempdlc: + tempdlc.write(re.search(r'<dlc>(.*)</dlc>', tempdlc_content, re.S).group(1)) + + self.urls = [tempdlc_name] diff --git a/pyload/plugin/container/LinkList.py b/pyload/plugin/container/LinkList.py new file mode 100644 index 000000000..f8134f03d --- /dev/null +++ b/pyload/plugin/container/LinkList.py @@ -0,0 +1,71 @@ +# -*- coding: utf-8 -*- + +import codecs + +from pyload.plugin.Container import Container +from pyload.utils import fs_encode + + +class LinkList(Container): + __name = "LinkList" + __version = "0.12" + + __pattern = r'.+\.txt' + __config = [("clear", "bool", "Clear Linklist after adding", False), + ("encoding", "string", "File encoding (default utf-8)", "")] + + __description = """Read link lists in txt format""" + __license = "GPLv3" + __authors = [("spoob", "spoob@pyload.org"), + ("jeix", "jeix@hasnomail.com")] + + + def decrypt(self, pyfile): + try: + file_enc = codecs.lookup(self.getConfig("encoding")).name + except Exception: + file_enc = "utf-8" + + file_name = fs_encode(pyfile.url) + + txt = codecs.open(file_name, 'r', file_enc) + links = txt.readlines() + curPack = "Parsed links from %s" % pyfile.name + + packages = {curPack:[],} + + for link in links: + link = link.strip() + if not link: + continue + + if link.startswith(";"): + continue + if link.startswith("[") and link.endswith("]"): + # new package + curPack = link[1:-1] + packages[curPack] = [] + continue + packages[curPack].append(link) + txt.close() + + # empty packages fix + + delete = [] + + for key,value in packages.iteritems(): + if not value: + delete.append(key) + + for key in delete: + del packages[key] + + if self.getConfig("clear"): + try: + txt = open(file_name, 'wb') + txt.close() + except Exception: + self.logWarning(_("LinkList could not be cleared")) + + for name, links in packages.iteritems(): + self.packages.append((name, links, name)) diff --git a/pyload/plugin/container/RSDF.py b/pyload/plugin/container/RSDF.py new file mode 100644 index 000000000..22670ce4f --- /dev/null +++ b/pyload/plugin/container/RSDF.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- + +from __future__ import with_statement + +import base64 +import binascii +import re + +from pyload.plugin.Container import Container +from pyload.utils import fs_encode + + +class RSDF(Container): + __name = "RSDF" + __version = "0.24" + + __pattern = r'.+\.rsdf' + + __description = """RSDF container decrypter plugin""" + __license = "GPLv3" + __authors = [("RaNaN", "RaNaN@pyload.org"), + ("spoob", "spoob@pyload.org")] + + + def decrypt(self, pyfile): + + from Crypto.Cipher import AES + + infile = fs_encode(pyfile.url.replace("\n", "")) + Key = binascii.unhexlify('8C35192D964DC3182C6F84F3252239EB4A320D2500000000') + + IV = binascii.unhexlify('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF') + IV_Cipher = AES.new(Key, AES.MODE_ECB) + IV = IV_Cipher.encrypt(IV) + + obj = AES.new(Key, AES.MODE_CFB, IV) + + try: + with open(infile, 'r') as rsdf: + data = rsdf.read() + except IOError, e: + self.fail(str(e)) + + if re.search(r"<title>404 - Not Found", data) is None: + data = binascii.unhexlify(''.join(data.split())) + data = data.splitlines() + + for link in data: + if not link: + continue + link = base64.b64decode(link) + link = obj.decrypt(link) + decryptedUrl = link.replace('CCF: ', '') + self.urls.append(decryptedUrl) + + self.logDebug("Adding package %s with %d links" % (pyfile.package().name, len(self.urls))) diff --git a/pyload/plugin/container/__init__.py b/pyload/plugin/container/__init__.py new file mode 100644 index 000000000..40a96afc6 --- /dev/null +++ b/pyload/plugin/container/__init__.py @@ -0,0 +1 @@ +# -*- coding: utf-8 -*- diff --git a/pyload/plugin/crypter/BitshareCom.py b/pyload/plugin/crypter/BitshareCom.py new file mode 100644 index 000000000..dfa7b71df --- /dev/null +++ b/pyload/plugin/crypter/BitshareCom.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.internal.SimpleCrypter import SimpleCrypter + + +class BitshareCom(SimpleCrypter): + __name = "BitshareCom" + __type = "crypter" + __version = "0.03" + + __pattern = r'http://(?:www\.)?bitshare\.com/\?d=\w+' + __config = [("use_subfolder", "bool", "Save package to subfolder", True), + ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] + + __description = """Bitshare.com folder decrypter plugin""" + __license = "GPLv3" + __authors = [("stickell", "l.stickell@yahoo.it")] + + + LINK_PATTERN = r'.+' + NAME_PATTERN = r'View public folder "(?P.+)"' diff --git a/pyload/plugin/crypter/C1neonCom.py b/pyload/plugin/crypter/C1neonCom.py new file mode 100644 index 000000000..ad428f6dd --- /dev/null +++ b/pyload/plugin/crypter/C1neonCom.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.internal.DeadCrypter import DeadCrypter, create_getInfo + + +class C1neonCom(DeadCrypter): + __name = "C1neonCom" + __type = "crypter" + __version = "0.05" + + __pattern = r'http://(?:www\.)?c1neon\.com/.*?' + __config = [] + + __description = """C1neon.com decrypter plugin""" + __license = "GPLv3" + __authors = [("godofdream", "soilfiction@gmail.com")] + + +getInfo = create_getInfo(C1neonCom) diff --git a/pyload/plugin/crypter/ChipDe.py b/pyload/plugin/crypter/ChipDe.py new file mode 100644 index 000000000..36735fd13 --- /dev/null +++ b/pyload/plugin/crypter/ChipDe.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- + +import re +from pyload.plugin.Crypter import Crypter + + +class ChipDe(Crypter): + __name = "ChipDe" + __type = "crypter" + __version = "0.10" + + __pattern = r'http://(?:www\.)?chip\.de/video/.*\.html' + __config = [("use_subfolder", "bool", "Save package to subfolder", True), + ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] + + __description = """Chip.de decrypter plugin""" + __license = "GPLv3" + __authors = [("4Christopher", "4Christopher@gmx.de")] + + + def decrypt(self, pyfile): + self.html = self.load(pyfile.url) + try: + f = re.search(r'"(http://video\.chip\.de/.+)"', self.html) + except Exception: + self.fail(_("Failed to find the URL")) + else: + self.urls = [f.group(1)] + self.logDebug("The file URL is %s" % self.urls[0]) diff --git a/pyload/plugin/crypter/CrockoCom.py b/pyload/plugin/crypter/CrockoCom.py new file mode 100644 index 000000000..8782c86e6 --- /dev/null +++ b/pyload/plugin/crypter/CrockoCom.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.internal.SimpleCrypter import SimpleCrypter + + +class CrockoCom(SimpleCrypter): + __name = "CrockoCom" + __type = "crypter" + __version = "0.01" + + __pattern = r'http://(?:www\.)?crocko\.com/f/.*' + __config = [("use_subfolder", "bool", "Save package to subfolder", True), + ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] + + __description = """Crocko.com folder decrypter plugin""" + __license = "GPLv3" + __authors = [("zoidberg", "zoidberg@mujmail.cz")] + + + LINK_PATTERN = r'download' diff --git a/pyload/plugin/crypter/CryptItCom.py b/pyload/plugin/crypter/CryptItCom.py new file mode 100644 index 000000000..dfb6be954 --- /dev/null +++ b/pyload/plugin/crypter/CryptItCom.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.internal.DeadCrypter import DeadCrypter, create_getInfo + + +class CryptItCom(DeadCrypter): + __name = "CryptItCom" + __type = "crypter" + __version = "0.11" + + __pattern = r'http://(?:www\.)?crypt-it\.com/(s|e|d|c)/\w+' + __config = [] + + __description = """Crypt-it.com decrypter plugin""" + __license = "GPLv3" + __authors = [("jeix", "jeix@hasnomail.de")] + + +getInfo = create_getInfo(CryptItCom) diff --git a/pyload/plugin/crypter/CzshareCom.py b/pyload/plugin/crypter/CzshareCom.py new file mode 100644 index 000000000..e36394426 --- /dev/null +++ b/pyload/plugin/crypter/CzshareCom.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- + +import re +from pyload.plugin.Crypter import Crypter + + +class CzshareCom(Crypter): + __name = "CzshareCom" + __type = "crypter" + __version = "0.20" + + __pattern = r'http://(?:www\.)?(czshare|sdilej)\.(com|cz)/folders/.*' + __config = [("use_subfolder", "bool", "Save package to subfolder", True), + ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] + + __description = """Czshare.com folder decrypter plugin, now Sdilej.cz""" + __license = "GPLv3" + __authors = [("zoidberg", "zoidberg@mujmail.cz")] + + + FOLDER_PATTERN = r'\s*\s*(.*?)
    ' + LINK_PATTERN = r'info' + + + def decrypt(self, pyfile): + html = self.load(pyfile.url) + + m = re.search(self.FOLDER_PATTERN, html, re.S) + if m is None: + self.error(_("FOLDER_PATTERN not found")) + + self.urls.extend(re.findall(self.LINK_PATTERN, m.group(1))) diff --git a/pyload/plugin/crypter/DDLMusicOrg.py b/pyload/plugin/crypter/DDLMusicOrg.py new file mode 100644 index 000000000..a24cac22d --- /dev/null +++ b/pyload/plugin/crypter/DDLMusicOrg.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- + +import re + +from time import sleep + +from pyload.plugin.Crypter import Crypter + + +class DDLMusicOrg(Crypter): + __name = "DDLMusicOrg" + __type = "crypter" + __version = "0.30" + + __pattern = r'http://(?:www\.)?ddl-music\.org/captcha/ddlm_cr\d\.php\?\d+\?\d+' + __config = [("use_subfolder", "bool", "Save package to subfolder", True), + ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] + + __description = """Ddl-music.org decrypter plugin""" + __license = "GPLv3" + __authors = [("mkaay", "mkaay@mkaay.de")] + + + def setup(self): + self.multiDL = False + + + def decrypt(self, pyfile): + html = self.load(pyfile.url, cookies=True) + + if re.search(r"Wer dies nicht rechnen kann", html) is not None: + self.offline() + + math = re.search(r"(\d+) ([+-]) (\d+) =\s+", htmlwithlink) + if m: + self.urls = [m.group(1)] + else: + self.retry() diff --git a/pyload/plugin/crypter/DailymotionBatch.py b/pyload/plugin/crypter/DailymotionBatch.py new file mode 100644 index 000000000..4b5b7106c --- /dev/null +++ b/pyload/plugin/crypter/DailymotionBatch.py @@ -0,0 +1,106 @@ +# -*- coding: utf-8 -*- + +import re + +from urlparse import urljoin + +from pyload.utils import json_loads +from pyload.plugin.Crypter import Crypter +from pyload.utils import safe_join + + +class DailymotionBatch(Crypter): + __name = "DailymotionBatch" + __type = "crypter" + __version = "0.01" + + __pattern = r'https?://(?:www\.)?dailymotion\.com/((playlists/)?(?Pplaylist|user)/)?(?P[\w^_]+)(?(TYPE)|#)' + __config = [("use_subfolder", "bool", "Save package to subfolder", True), + ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] + + __description = """Dailymotion.com channel & playlist decrypter""" + __license = "GPLv3" + __authors = [("Walter Purcaro", "vuolter@gmail.com")] + + + def api_response(self, ref, req=None): + url = urljoin("https://api.dailymotion.com/", ref) + page = self.load(url, get=req) + return json_loads(page) + + + def getPlaylistInfo(self, id): + ref = "playlist/" + id + req = {"fields": "name,owner.screenname"} + playlist = self.api_response(ref, req) + + if "error" in playlist: + return + + name = playlist['name'] + owner = playlist['owner.screenname'] + return name, owner + + + def _getPlaylists(self, user_id, page=1): + ref = "user/%s/playlists" % user_id + req = {"fields": "id", "page": page, "limit": 100} + user = self.api_response(ref, req) + + if "error" in user: + return + + for playlist in user['list']: + yield playlist['id'] + + if user['has_more']: + for item in self._getPlaylists(user_id, page + 1): + yield item + + + def getPlaylists(self, user_id): + return [(id,) + self.getPlaylistInfo(id) for id in self._getPlaylists(user_id)] + + + def _getVideos(self, id, page=1): + ref = "playlist/%s/videos" % id + req = {"fields": "url", "page": page, "limit": 100} + playlist = self.api_response(ref, req) + + if "error" in playlist: + return + + for video in playlist['list']: + yield video['url'] + + if playlist['has_more']: + for item in self._getVideos(id, page + 1): + yield item + + + def getVideos(self, playlist_id): + return list(self._getVideos(playlist_id))[::-1] + + + def decrypt(self, pyfile): + m = re.match(self.__pattern, pyfile.url) + m_id = m.group("ID") + m_type = m.group("TYPE") + + if m_type == "playlist": + self.logDebug("Url recognized as Playlist") + p_info = self.getPlaylistInfo(m_id) + playlists = [(m_id,) + p_info] if p_info else None + else: + self.logDebug("Url recognized as Channel") + playlists = self.getPlaylists(m_id) + self.logDebug("%s playlist\s found on channel \"%s\"" % (len(playlists), m_id)) + + if not playlists: + self.fail(_("No playlist available")) + + for p_id, p_name, p_owner in playlists: + p_videos = self.getVideos(p_id) + p_folder = safe_join(self.config['general']['download_folder'], p_owner, p_name) + self.logDebug("%s video\s found on playlist \"%s\"" % (len(p_videos), p_name)) + self.packages.append((p_name, p_videos, p_folder)) #: folder is NOT recognized by pyload 0.4.9! diff --git a/pyload/plugin/crypter/DataHu.py b/pyload/plugin/crypter/DataHu.py new file mode 100644 index 000000000..bc677253a --- /dev/null +++ b/pyload/plugin/crypter/DataHu.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- + +import re + +from pyload.plugin.internal.SimpleCrypter import SimpleCrypter + + +class DataHu(SimpleCrypter): + __name = "DataHu" + __type = "crypter" + __version = "0.06" + + __pattern = r'http://(?:www\.)?data\.hu/dir/\w+' + __config = [("use_subfolder", "bool", "Save package to subfolder", True), + ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] + + __description = """Data.hu folder decrypter plugin""" + __license = "GPLv3" + __authors = [("crash", ""), + ("stickell", "l.stickell@yahoo.it")] + + + LINK_PATTERN = r'\1' + NAME_PATTERN = ur'(?P<N>.+) Let\xf6lt\xe9se' + + + def prepare(self): + super(DataHu, self).prepare() + + if u'K\xe9rlek add meg a jelsz\xf3t' in self.html: # Password protected + password = self.getPassword() + if not password: + self.fail(_("Password required")) + + self.logDebug("The folder is password protected', 'Using password: " + password) + + self.html = self.load(self.pyfile.url, post={'mappa_pass': password}, decode=True) + + if u'Hib\xe1s jelsz\xf3' in self.html: # Wrong password + self.fail(_("Wrong password")) diff --git a/pyload/plugin/crypter/DdlstorageCom.py b/pyload/plugin/crypter/DdlstorageCom.py new file mode 100644 index 000000000..c6f423bb6 --- /dev/null +++ b/pyload/plugin/crypter/DdlstorageCom.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.internal.DeadCrypter import DeadCrypter, create_getInfo + + +class DdlstorageCom(DeadCrypter): + __name = "DdlstorageCom" + __type = "crypter" + __version = "0.03" + + __pattern = r'https?://(?:www\.)?ddlstorage\.com/folder/\w+' + __config = [] + + __description = """DDLStorage.com folder decrypter plugin""" + __license = "GPLv3" + __authors = [("godofdream", "soilfiction@gmail.com"), + ("stickell", "l.stickell@yahoo.it")] + + +getInfo = create_getInfo(DdlstorageCom) diff --git a/pyload/plugin/crypter/DepositfilesCom.py b/pyload/plugin/crypter/DepositfilesCom.py new file mode 100644 index 000000000..8ecbb6f8d --- /dev/null +++ b/pyload/plugin/crypter/DepositfilesCom.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.internal.SimpleCrypter import SimpleCrypter + + +class DepositfilesCom(SimpleCrypter): + __name = "DepositfilesCom" + __type = "crypter" + __version = "0.01" + + __pattern = r'http://(?:www\.)?depositfiles\.com/folders/\w+' + __config = [("use_subfolder", "bool", "Save package to subfolder", True), + ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] + + __description = """Depositfiles.com folder decrypter plugin""" + __license = "GPLv3" + __authors = [("zoidberg", "zoidberg@mujmail.cz")] + + + LINK_PATTERN = r'
    ]*>\s*' diff --git a/pyload/plugin/crypter/Dereferer.py b/pyload/plugin/crypter/Dereferer.py new file mode 100644 index 000000000..ec7f48a52 --- /dev/null +++ b/pyload/plugin/crypter/Dereferer.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- + +import re + +from urllib import unquote + +from pyload.plugin.Crypter import Crypter + + +class Dereferer(Crypter): + __name = "Dereferer" + __type = "crypter" + __version = "0.10" + + __pattern = r'https?://([^/]+)/.*?(?P(ht|f)tps?(://|%3A%2F%2F).*)' + __config = [("use_subfolder", "bool", "Save package to subfolder", True), + ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] + + __description = """Crypter for dereferers""" + __license = "GPLv3" + __authors = [("zoidberg", "zoidberg@mujmail.cz")] + + + def decrypt(self, pyfile): + link = re.match(self.__pattern, pyfile.url).group('url') + self.urls = [unquote(link).rstrip('+')] diff --git a/pyload/plugin/crypter/DevhostStFolder.py b/pyload/plugin/crypter/DevhostStFolder.py new file mode 100644 index 000000000..aa00fe60e --- /dev/null +++ b/pyload/plugin/crypter/DevhostStFolder.py @@ -0,0 +1,58 @@ +# -*- coding: utf-8 -*- +# +# Test links: +# http://d-h.st/users/shine/?fld_id=37263#files + +import re + +from urlparse import urljoin + +from pyload.plugin.internal.SimpleCrypter import SimpleCrypter + + +class DevhostStFolder(SimpleCrypter): + __name = "DevhostStFolder" + __type = "crypter" + __version = "0.03" + + __pattern = r'http://(?:www\.)?d-h\.st/users/(?P\w+)(/\?fld_id=(?P\d+))?' + __config = [("use_subfolder", "bool", "Save package to subfolder", True), + ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] + + __description = """d-h.st folder decrypter plugin""" + __license = "GPLv3" + __authors = [("zapp-brannigan", "fuerst.reinje@web.de"), + ("Walter Purcaro", "vuolter@gmail.com")] + + + LINK_PATTERN = r'(?:/> |;">)Back to \w+<)' + OFFLINE_PATTERN = r'"/cHP">test\.png<' + + + def getFileInfo(self): + if re.search(self.OFFLINE_PATTERN, self.html): + self.offline() + + try: + id = re.match(self.__pattern, self.pyfile.url).group('ID') + if id == "0": + raise + + p = r'href="(.+?)">Back to \w+<' + m = re.search(p, self.html) + html = self.load(urljoin("http://d-h.st", m.group(1)), + cookies=False) + + p = '\?fld_id=%s.*?">(.+?)<' % id + m = re.search(p, html) + name = folder = m.group(1) + + except Exception, e: + self.logDebug(e) + name = folder = re.match(self.__pattern, self.pyfile.url).group('USER') + + return {'name': name, 'folder': folder} + + + def getLinks(self): + return [urljoin("http://d-h.st", link) for link in re.findall(self.LINK_PATTERN, self.html)] diff --git a/pyload/plugin/crypter/DlProtectCom.py b/pyload/plugin/crypter/DlProtectCom.py new file mode 100644 index 000000000..0a9f00cc4 --- /dev/null +++ b/pyload/plugin/crypter/DlProtectCom.py @@ -0,0 +1,65 @@ +# -*- coding: utf-8 -*- + +import re + +from base64 import urlsafe_b64encode +from time import time + +from pyload.plugin.internal.SimpleCrypter import SimpleCrypter + + +class DlProtectCom(SimpleCrypter): + __name = "DlProtectCom" + __type = "crypter" + __version = "0.01" + + __pattern = r'http://(?:www\.)?dl-protect\.com/((en|fr)/)?(?P\w+)' + __config = [("use_subfolder", "bool", "Save package to subfolder", True), + ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] + + __description = """Dl-protect.com decrypter plugin""" + __license = "GPLv3" + __authors = [("Walter Purcaro", "vuolter@gmail.com")] + + + OFFLINE_PATTERN = r'>Unfortunately, the link you are looking for is not found' + + + def getLinks(self): + # Direct link with redirect + if not re.match(r"http://(?:www\.)?dl-protect\.com", self.req.http.lastEffectiveURL): + return [self.req.http.lastEffectiveURL] + + #id = re.match(self.__pattern, self.pyfile.url).group("ID") + key = re.search(r'name="id_key" value="(.+?)"', self.html).group(1) + + post_req = {"id_key": key, "submitform": ""} + + if self.OFFLINE_PATTERN in self.html: + self.offline() + elif ">Please click on continue to see the content" in self.html: + post_req.update({"submitform": "Continue"}) + else: + mstime = int(round(time() * 1000)) + b64time = "_" + urlsafe_b64encode(str(mstime)).replace("=", "%3D") + + post_req.update({"i": b64time, "submitform": "Decrypt+link"}) + + if ">Password :" in self.html: + post_req['pwd'] = self.getPassword() + + if ">Security Code" in self.html: + captcha_id = re.search(r'/captcha\.php\?uid=(.+?)"', self.html).group(1) + captcha_url = "http://www.dl-protect.com/captcha.php?uid=" + captcha_id + captcha_code = self.decryptCaptcha(captcha_url, imgtype="gif") + + post_req['secure'] = captcha_code + + self.html = self.load(self.pyfile.url, post=post_req) + + for errmsg in (">The password is incorrect", ">The security code is incorrect"): + if errmsg in self.html: + self.fail(_(errmsg[1:])) + + pattern = r'' + return re.findall(pattern, self.html) diff --git a/pyload/plugin/crypter/DontKnowMe.py b/pyload/plugin/crypter/DontKnowMe.py new file mode 100644 index 000000000..7fc1c87e4 --- /dev/null +++ b/pyload/plugin/crypter/DontKnowMe.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- + +import re + +from urllib import unquote + +from pyload.plugin.Crypter import Crypter + + +class DontKnowMe(Crypter): + __name = "DontKnowMe" + __type = "crypter" + __version = "0.10" + + __pattern = r'http://(?:www\.)?dontknow\.me/at/\?.+$' + __config = [("use_subfolder", "bool", "Save package to subfolder", True), + ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] + + __description = """DontKnow.me decrypter plugin""" + __license = "GPLv3" + __authors = [("selaux", "")] + + + LINK_PATTERN = r'http://dontknow\.me/at/\?(.+)$' + + + def decrypt(self, pyfile): + link = re.findall(self.LINK_PATTERN, pyfile.url)[0] + self.urls = [unquote(link)] diff --git a/pyload/plugin/crypter/DuckCryptInfo.py b/pyload/plugin/crypter/DuckCryptInfo.py new file mode 100644 index 000000000..28f9a1505 --- /dev/null +++ b/pyload/plugin/crypter/DuckCryptInfo.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- + +import re + +from BeautifulSoup import BeautifulSoup + +from pyload.plugin.Crypter import Crypter + + +class DuckCryptInfo(Crypter): + __name = "DuckCryptInfo" + __type = "crypter" + __version = "0.02" + + __pattern = r'http://(?:www\.)?duckcrypt\.info/(folder|wait|link)/(\w+)/?(\w*)' + __config = [("use_subfolder", "bool", "Save package to subfolder", True), + ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] + + __description = """DuckCrypt.info decrypter plugin""" + __license = "GPLv3" + __authors = [("godofdream", "soilfiction@gmail.com")] + + + TIMER_PATTERN = r'(.*)' + + + def decrypt(self, pyfile): + url = pyfile.url + + m = re.match(self.__pattern, url) + if m is None: + self.fail(_("Weird error in link")) + if str(m.group(1)) == "link": + self.handleLink(url) + else: + self.handleFolder(m) + + + def handleFolder(self, m): + html = self.load("http://duckcrypt.info/ajax/auth.php?hash=" + str(m.group(2))) + m = re.match(self.__pattern, html) + self.logDebug("Redirectet to " + str(m.group(0))) + html = self.load(str(m.group(0))) + soup = BeautifulSoup(html) + cryptlinks = soup.findAll("div", attrs={"class": "folderbox"}) + self.logDebug("Redirectet to " + str(cryptlinks)) + if not cryptlinks: + self.error(_("No link found")) + for clink in cryptlinks: + if clink.find("a"): + self.handleLink(clink.find("a")['href']) + + + def handleLink(self, url): + html = self.load(url) + soup = BeautifulSoup(html) + self.urls = [soup.find("iframe")['src']] + if not self.urls: + self.logInfo(_("No link found")) diff --git a/pyload/plugin/crypter/DuploadOrg.py b/pyload/plugin/crypter/DuploadOrg.py new file mode 100644 index 000000000..d5839bce0 --- /dev/null +++ b/pyload/plugin/crypter/DuploadOrg.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.internal.DeadCrypter import DeadCrypter, create_getInfo + + +class DuploadOrg(DeadCrypter): + __name = "DuploadOrg" + __type = "crypter" + __version = "0.02" + + __pattern = r'http://(?:www\.)?dupload\.org/folder/\d+' + __config = [] + + __description = """Dupload.org folder decrypter plugin""" + __license = "GPLv3" + __authors = [("stickell", "l.stickell@yahoo.it")] + + +getInfo = create_getInfo(DuploadOrg) diff --git a/pyload/plugin/crypter/EasybytezCom.py b/pyload/plugin/crypter/EasybytezCom.py new file mode 100644 index 000000000..2e7e37537 --- /dev/null +++ b/pyload/plugin/crypter/EasybytezCom.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.internal.XFSCrypter import XFSCrypter + + +class EasybytezCom(XFSCrypter): + __name = "EasybytezCom" + __type = "crypter" + __version = "0.10" + + __pattern = r'http://(?:www\.)?easybytez\.com/users/\d+/\d+' + __config = [("use_subfolder", "bool", "Save package to subfolder", True), + ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] + + __description = """Easybytez.com folder decrypter plugin""" + __license = "GPLv3" + __authors = [("stickell", "l.stickell@yahoo.it")] + + + HOSTER_DOMAIN = "easybytez.com" + + LOGIN_ACCOUNT = True diff --git a/pyload/plugin/crypter/EmbeduploadCom.py b/pyload/plugin/crypter/EmbeduploadCom.py new file mode 100644 index 000000000..88f6db50b --- /dev/null +++ b/pyload/plugin/crypter/EmbeduploadCom.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- + +import re +from pyload.plugin.Crypter import Crypter +from pyload.network.HTTPRequest import BadHeader + + +class EmbeduploadCom(Crypter): + __name = "EmbeduploadCom" + __type = "crypter" + __version = "0.02" + + __pattern = r'http://(?:www\.)?embedupload\.com/\?d=.*' + __config = [("use_subfolder", "bool", "Save package to subfolder", True), + ("subfolder_per_package", "bool", "Create a subfolder for each package", True), + ("preferedHoster", "str", "Prefered hoster list (bar-separated)", "embedupload"), + ("ignoredHoster", "str", "Ignored hoster list (bar-separated)", "")] + + __description = """EmbedUpload.com decrypter plugin""" + __license = "GPLv3" + __authors = [("zoidberg", "zoidberg@mujmail.cz")] + + + LINK_PATTERN = r'
    ]*>\s*' + + + def decrypt(self, pyfile): + self.html = self.load(pyfile.url, decode=True) + tmp_links = [] + + m = re.findall(self.LINK_PATTERN, self.html) + if m: + prefered_set = set(self.getConfig("preferedHoster").split('|')) + prefered_set = map(lambda s: s.lower().split('.')[0], prefered_set) + + self.logDebug("PF: %s" % prefered_set) + + tmp_links.extend([x[1] for x in m if x[0] in prefered_set]) + self.urls = self.getLocation(tmp_links) + + if not self.urls: + ignored_set = set(self.getConfig("ignoredHoster").split('|')) + ignored_set = map(lambda s: s.lower().split('.')[0], ignored_set) + + self.logDebug("IG: %s" % ignored_set) + + tmp_links.extend([x[1] for x in m if x[0] not in ignored_set]) + self.urls = self.getLocation(tmp_links) + + + def getLocation(self, tmp_links): + new_links = [] + for link in tmp_links: + try: + header = self.load(link, just_header=True) + if 'location' in header: + new_links.append(header['location']) + except BadHeader: + pass + return new_links diff --git a/pyload/plugin/crypter/FilebeerInfo.py b/pyload/plugin/crypter/FilebeerInfo.py new file mode 100644 index 000000000..294f57451 --- /dev/null +++ b/pyload/plugin/crypter/FilebeerInfo.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.internal.DeadCrypter import DeadCrypter, create_getInfo + + +class FilebeerInfo(DeadCrypter): + __name = "FilebeerInfo" + __type = "crypter" + __version = "0.02" + + __pattern = r'http://(?:www\.)?filebeer\.info/(\d+~f).*' + __config = [] + + __description = """Filebeer.info folder decrypter plugin""" + __license = "GPLv3" + __authors = [("zoidberg", "zoidberg@mujmail.cz")] + + +getInfo = create_getInfo(FilebeerInfo) diff --git a/pyload/plugin/crypter/FilecloudIo.py b/pyload/plugin/crypter/FilecloudIo.py new file mode 100644 index 000000000..1926d04bb --- /dev/null +++ b/pyload/plugin/crypter/FilecloudIo.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- + +from pyload.plugin.internal.SimpleCrypter import SimpleCrypter + + +class FilecloudIo(SimpleCrypter): + __name = "FilecloudIo" + __type = "crypter" + __version = "0.03" + + __pattern = r'https?://(?:www\.)?(filecloud\.io|ifile\.it)/_\w+' + __config = [("use_subfolder", "bool", "Save package to subfolder", True), + ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] + + __description = """Filecloud.io folder decrypter plugin""" + __license = "GPLv3" + __authors = [("Walter Purcaro", "vuolter@gmail.com")] + + + LINK_PATTERN = r'href="(http://filecloud\.io/\w+)" title' + NAME_PATTERN = r'>(?P.+?) - filecloud\.io<' diff --git a/pyload/plugin/crypter/FilecryptCc.py b/pyload/plugin/crypter/FilecryptCc.py new file mode 100644 index 000000000..7db82f24c --- /dev/null +++ b/pyload/plugin/crypter/FilecryptCc.py @@ -0,0 +1,148 @@ +# -*- coding: utf-8 -*- + +import base64 +import binascii +import re + +from Crypto.Cipher import AES + +from pyload.plugin.Crypter import Crypter + + +class FilecryptCc(Crypter): + __name = "FilecryptCc" + __type = "crypter" + __version = "0.05" + + __pattern = r'https?://(?:www\.)?filecrypt\.cc/Container/\w+' + + __description = """Filecrypt.cc decrypter plugin""" + __license = "GPLv3" + __authors = [("zapp-brannigan", "fuerst.reinje@web.de")] + + + # URL_REPLACEMENTS = [(r'.html$', ""), (r'$', ".html")] #@TODO: Extend SimpleCrypter + + DLC_LINK_PATTERN = r'
  • \s*
  • .*\s*(.*?)[\s\w<>/]*href="/logout"' - VALID_UNTIL_PATTERN = r'
    [\s\w<>=-":;]*.*?(.*?)' - - - def loadAccountInfo(self, user, req): - premium = False - validuntil = -1 - - html = req.load("http://catshare.net/", decode=True) - - try: - m = re.search(self.PREMIUM_PATTERN, html) - if "Premium" in m.group(1): - premium = True - except Exception: - pass - - try: - m = re.search(self.VALID_UNTIL_PATTERN, html) - expiredate = m.group(1) - if "-" not in expiredate: - validuntil = mktime(strptime(expiredate, "%d.%m.%Y")) - except Exception: - pass - - return {'premium': premium, 'trafficleft': -1, 'validuntil': validuntil} - - - def login(self, user, data, req): - html = req.load("http://catshare.net/login", - post={'user_email': user, - 'user_password': data['password'], - 'remindPassword': 0, - 'user[submit]': "Login"}) - - if not 'Wyloguj' in html: - self.wrongPassword() diff --git a/pyload/plugins/account/CramitIn.py b/pyload/plugins/account/CramitIn.py deleted file mode 100644 index 6b8b5eead..000000000 --- a/pyload/plugins/account/CramitIn.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.internal.XFSAccount import XFSAccount - - -class CramitIn(XFSAccount): - __name = "CramitIn" - __type = "account" - __version = "0.03" - - __description = """Cramit.in account plugin""" - __license = "GPLv3" - __authors = [("zoidberg", "zoidberg@mujmail.cz")] - - - HOSTER_DOMAIN = "cramit.in" diff --git a/pyload/plugins/account/CzshareCom.py b/pyload/plugins/account/CzshareCom.py deleted file mode 100644 index 5e94b1516..000000000 --- a/pyload/plugins/account/CzshareCom.py +++ /dev/null @@ -1,44 +0,0 @@ -# -*- coding: utf-8 -*- - -from time import mktime, strptime -import re - -from pyload.plugins.Account import Account - - -class CzshareCom(Account): - __name = "CzshareCom" - __type = "account" - __version = "0.14" - - __description = """Czshare.com account plugin, now Sdilej.cz""" - __license = "GPLv3" - __authors = [("zoidberg", "zoidberg@mujmail.cz"), - ("stickell", "l.stickell@yahoo.it")] - - - CREDIT_LEFT_PATTERN = r'\s*([\d ,]+) (KiB|MiB|GiB)\s*([^<]*)\s*' - - - def loadAccountInfo(self, user, req): - html = req.load("http://sdilej.cz/prehled_kreditu/") - - m = re.search(self.CREDIT_LEFT_PATTERN, html) - if m is None: - return {"validuntil": 0, "trafficleft": 0} - else: - credits = float(m.group(1).replace(' ', '').replace(',', '.')) - credits = credits * 1024 ** {'KiB': 0, 'MiB': 1, 'GiB': 2}[m.group(2)] - validuntil = mktime(strptime(m.group(3), '%d.%m.%y %H:%M')) - return {"validuntil": validuntil, "trafficleft": credits} - - - def login(self, user, data, req): - html = req.load('https://sdilej.cz/index.php', post={ - "Prihlasit": "Prihlasit", - "login-password": data['password'], - "login-name": user - }) - - if '", html).group(1) - - validuntil = int(mktime(strptime(validuntil, "%Y-%m-%d %H:%M:%S"))) - - return {"validuntil": validuntil, "trafficleft": -1} - - - def login(self, user, data, req): - html = req.load("https://dfiles.eu/de/login.php", get={"return": "/de/gold/payment.php"}, - post={"login": user, "password": data['password']}) - if r'
    Sie haben eine falsche Benutzername-Passwort-Kombination verwendet.
    ' in html: - self.wrongPassword() diff --git a/pyload/plugins/account/DropboxCom.py b/pyload/plugins/account/DropboxCom.py deleted file mode 100644 index 30c26bc20..000000000 --- a/pyload/plugins/account/DropboxCom.py +++ /dev/null @@ -1,42 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from pyload.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo - - -class DropboxCom(SimpleHoster): - __name = "DropboxCom" - __type = "hoster" - __version = "0.03" - - __pattern = r'https?://(?:www\.)?dropbox\.com/.+' - - __description = """Dropbox.com hoster plugin""" - __license = "GPLv3" - __authors = [("zapp-brannigan", "fuerst.reinje@web.de")] - - - NAME_PATTERN = r'Dropbox - (?P<N>.+?)<' - SIZE_PATTERN = r' ·  (?P<S>[\d.,]+) (?P<U>[\w^_]+)' - - OFFLINE_PATTERN = r'<title>Dropbox - (404|Shared link error)<' - - COOKIES = [("dropbox.com", "lang", "en")] - - - def setup(self): - self.multiDL = True - self.chunkLimit = 1 - self.resumeDownload = True - - - def handleFree(self): - self.download(self.pyfile.url, get={'dl': "1"}) - - check = self.checkDownload({'html': re.compile("html")}) - if check == "html": - self.error(_("Downloaded file is an html page")) - - -getInfo = create_getInfo(DropboxCom) diff --git a/pyload/plugins/account/EasybytezCom.py b/pyload/plugins/account/EasybytezCom.py deleted file mode 100644 index 1491b8a80..000000000 --- a/pyload/plugins/account/EasybytezCom.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from pyload.plugins.internal.XFSAccount import XFSAccount - - -class EasybytezCom(XFSAccount): - __name = "EasybytezCom" - __type = "account" - __version = "0.12" - - __description = """EasyBytez.com account plugin""" - __license = "GPLv3" - __authors = [("zoidberg", "zoidberg@mujmail.cz"), - ("guidobelix", "guidobelix@hotmail.it")] - - - HOSTER_DOMAIN = "easybytez.com" diff --git a/pyload/plugins/account/EuroshareEu.py b/pyload/plugins/account/EuroshareEu.py deleted file mode 100644 index 667718651..000000000 --- a/pyload/plugins/account/EuroshareEu.py +++ /dev/null @@ -1,41 +0,0 @@ -# -*- coding: utf-8 -*- - -from time import mktime, strptime -import re - -from pyload.plugins.Account import Account - - -class EuroshareEu(Account): - __name = "EuroshareEu" - __type = "account" - __version = "0.01" - - __description = """Euroshare.eu account plugin""" - __license = "GPLv3" - __authors = [("zoidberg", "zoidberg@mujmail.cz")] - - - def loadAccountInfo(self, user, req): - self.relogin(user) - html = req.load("http://euroshare.eu/customer-zone/settings/") - - m = re.search('id="input_expire_date" value="(\d+\.\d+\.\d+ \d+:\d+)"', html) - if m is None: - premium, validuntil = False, -1 - else: - premium = True - validuntil = mktime(strptime(m.group(1), "%d.%m.%Y %H:%M")) - - return {"validuntil": validuntil, "trafficleft": -1, "premium": premium} - - - def login(self, user, data, req): - html = req.load('http://euroshare.eu/customer-zone/login/', post={ - "trvale": "1", - "login": user, - "password": data['password'] - }, decode=True) - - if u">Nesprávne prihlasovacie meno alebo heslo" in html: - self.wrongPassword() diff --git a/pyload/plugins/account/FastixRu.py b/pyload/plugins/account/FastixRu.py deleted file mode 100644 index 40b567b92..000000000 --- a/pyload/plugins/account/FastixRu.py +++ /dev/null @@ -1,38 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.Account import Account -from pyload.utils import json_loads - - -class FastixRu(Account): - __name = "FastixRu" - __type = "account" - __version = "0.02" - - __description = """Fastix account plugin""" - __license = "GPLv3" - __authors = [("Massimo Rosamilia", "max@spiritix.eu")] - - - def loadAccountInfo(self, user, req): - data = self.getAccountData(user) - page = json_loads(req.load("http://fastix.ru/api_v2/", get={'apikey': data['api'], 'sub': "getaccountdetails"})) - - points = page['points'] - kb = float(points) * 1024 ** 2 / 1000 - - if points > 0: - account_info = {"validuntil": -1, "trafficleft": kb} - else: - account_info = {"validuntil": None, "trafficleft": None, "premium": False} - return account_info - - - def login(self, user, data, req): - page = req.load("http://fastix.ru/api_v2/", - get={'sub': "get_apikey", 'email': user, 'password': data['password']}) - api = json_loads(page) - api = api['apikey'] - data['api'] = api - if "error_code" in page: - self.wrongPassword() diff --git a/pyload/plugins/account/FastshareCz.py b/pyload/plugins/account/FastshareCz.py deleted file mode 100644 index 46f4c304c..000000000 --- a/pyload/plugins/account/FastshareCz.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from pyload.plugins.Account import Account -from pyload.utils import parseFileSize - - -class FastshareCz(Account): - __name = "FastshareCz" - __type = "account" - __version = "0.05" - - __description = """Fastshare.cz account plugin""" - __license = "GPLv3" - __authors = [("zoidberg", "zoidberg@mujmail.cz"), - ("stickell", "l.stickell@yahoo.it")] - - - CREDIT_PATTERN = r'My account\s*\((.+?)\)' - - - def loadAccountInfo(self, user, req): - validuntil = None - trafficleft = None - premium = None - - html = req.load("http://www.fastshare.cz/user", decode=True) - - m = re.search(self.CREDIT_PATTERN, html) - if m: - trafficleft = self.parseTraffic(m.group(1)) - - if trafficleft: - premium = True - validuntil = -1 - else: - premium = False - - return {"validuntil": validuntil, "trafficleft": trafficleft, "premium": premium} - - - def login(self, user, data, req): - req.cj.setCookie("fastshare.cz", "lang", "en") - - req.load('http://www.fastshare.cz/login') # Do not remove or it will not login - - html = req.load("http://www.fastshare.cz/sql.php", - post={'login': user, 'heslo': data['password']}, - decode=True) - - if ">Wrong username or password" in html: - self.wrongPassword() diff --git a/pyload/plugins/account/File4safeCom.py b/pyload/plugins/account/File4safeCom.py deleted file mode 100644 index 555e9f4ea..000000000 --- a/pyload/plugins/account/File4safeCom.py +++ /dev/null @@ -1,18 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.internal.XFSAccount import XFSAccount - - -class File4safeCom(XFSAccount): - __name = "File4safeCom" - __type = "account" - __version = "0.04" - - __description = """File4safe.com account plugin""" - __license = "GPLv3" - __authors = [("stickell", "l.stickell@yahoo.it")] - - - HOSTER_DOMAIN = "file4safe.com" - - LOGIN_FAIL_PATTERN = r'input_login' diff --git a/pyload/plugins/account/FileParadoxIn.py b/pyload/plugins/account/FileParadoxIn.py deleted file mode 100644 index b0090bb27..000000000 --- a/pyload/plugins/account/FileParadoxIn.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.internal.XFSAccount import XFSAccount - - -class FileParadoxIn(XFSAccount): - __name = "FileParadoxIn" - __type = "account" - __version = "0.02" - - __description = """FileParadox.in account plugin""" - __license = "GPLv3" - __authors = [("Walter Purcaro", "vuolter@gmail.com")] - - - HOSTER_DOMAIN = "fileparadox.in" diff --git a/pyload/plugins/account/FilecloudIo.py b/pyload/plugins/account/FilecloudIo.py deleted file mode 100644 index ce0cc2d34..000000000 --- a/pyload/plugins/account/FilecloudIo.py +++ /dev/null @@ -1,59 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.Account import Account -from pyload.utils import json_loads - - -class FilecloudIo(Account): - __name = "FilecloudIo" - __type = "account" - __version = "0.02" - - __description = """FilecloudIo account plugin""" - __license = "GPLv3" - __authors = [("zoidberg", "zoidberg@mujmail.cz"), - ("stickell", "l.stickell@yahoo.it")] - - - def loadAccountInfo(self, user, req): - # It looks like the first API request always fails, so we retry 5 times, it should work on the second try - for _i in xrange(5): - rep = req.load("https://secure.filecloud.io/api-fetch_apikey.api", - post={"username": user, "password": self.accounts[user]['password']}) - rep = json_loads(rep) - if rep['status'] == 'ok': - break - elif rep['status'] == 'error' and rep['message'] == 'no such user or wrong password': - self.logError(_("Wrong username or password")) - return {"valid": False, "premium": False} - else: - return {"premium": False} - - akey = rep['akey'] - self.accounts[user]['akey'] = akey # Saved for hoster plugin - rep = req.load("http://api.filecloud.io/api-fetch_account_details.api", - post={"akey": akey}) - rep = json_loads(rep) - - if rep['is_premium'] == 1: - return {"validuntil": int(rep['premium_until']), "trafficleft": -1} - else: - return {"premium": False} - - - def login(self, user, data, req): - req.cj.setCookie("secure.filecloud.io", "lang", "en") - html = req.load('https://secure.filecloud.io/user-login.html') - - if not hasattr(self, "form_data"): - self.form_data = {} - - self.form_data['username'] = user - self.form_data['password'] = data['password'] - - html = req.load('https://secure.filecloud.io/user-login_p.html', - post=self.form_data, - multipart=True) - - self.logged_in = True if "you have successfully logged in - filecloud.io" in html else False - self.form_data = {} diff --git a/pyload/plugins/account/FilefactoryCom.py b/pyload/plugins/account/FilefactoryCom.py deleted file mode 100644 index 21a6db6fb..000000000 --- a/pyload/plugins/account/FilefactoryCom.py +++ /dev/null @@ -1,49 +0,0 @@ -# -*- coding: utf-8 -*- - -import re -from time import mktime, strptime - -from pycurl import REFERER - -from pyload.plugins.Account import Account - - -class FilefactoryCom(Account): - __name = "FilefactoryCom" - __type = "account" - __version = "0.14" - - __description = """Filefactory.com account plugin""" - __license = "GPLv3" - __authors = [("zoidberg", "zoidberg@mujmail.cz"), - ("stickell", "l.stickell@yahoo.it")] - - - VALID_UNTIL_PATTERN = r'Premium valid until: <strong>(?P<d>\d{1,2})\w{1,2} (?P<m>\w{3}), (?P<y>\d{4})</strong>' - - - def loadAccountInfo(self, user, req): - html = req.load("http://www.filefactory.com/account/") - - m = re.search(self.VALID_UNTIL_PATTERN, html) - if m: - premium = True - validuntil = re.sub(self.VALID_UNTIL_PATTERN, '\g<d> \g<m> \g<y>', m.group(0)) - validuntil = mktime(strptime(validuntil, "%d %b %Y")) - else: - premium = False - validuntil = -1 - - return {"premium": premium, "trafficleft": -1, "validuntil": validuntil} - - - def login(self, user, data, req): - req.http.c.setopt(REFERER, "http://www.filefactory.com/member/login.php") - - html = req.load("http://www.filefactory.com/member/signin.php", post={ - "loginEmail": user, - "loginPassword": data['password'], - "Submit": "Sign In"}) - - if req.lastEffectiveURL != "http://www.filefactory.com/account/": - self.wrongPassword() diff --git a/pyload/plugins/account/FilejungleCom.py b/pyload/plugins/account/FilejungleCom.py deleted file mode 100644 index d3dbcd603..000000000 --- a/pyload/plugins/account/FilejungleCom.py +++ /dev/null @@ -1,49 +0,0 @@ -# -*- coding: utf-8 -*- - -import re -from time import mktime, strptime - -from pyload.plugins.Account import Account - - -class FilejungleCom(Account): - __name = "FilejungleCom" - __type = "account" - __version = "0.11" - - __description = """Filejungle.com account plugin""" - __license = "GPLv3" - __authors = [("zoidberg", "zoidberg@mujmail.cz")] - - - login_timeout = 60 - - URL = "http://filejungle.com/" - TRAFFIC_LEFT_PATTERN = r'"/extend_premium\.php">Until (\d+ \w+ \d+)<br' - LOGIN_FAILED_PATTERN = r'<span htmlfor="loginUser(Name|Password)" generated="true" class="fail_info">' - - - def loadAccountInfo(self, user, req): - html = req.load(self.URL + "dashboard.php") - m = re.search(self.TRAFFIC_LEFT_PATTERN, html) - if m: - premium = True - validuntil = mktime(strptime(m.group(1), "%d %b %Y")) - else: - premium = False - validuntil = -1 - - return {"premium": premium, "trafficleft": -1, "validuntil": validuntil} - - - def login(self, user, data, req): - html = req.load(self.URL + "login.php", post={ - "loginUserName": user, - "loginUserPassword": data['password'], - "loginFormSubmit": "Login", - "recaptcha_challenge_field": "", - "recaptcha_response_field": "", - "recaptcha_shortencode_field": ""}) - - if re.search(self.LOGIN_FAILED_PATTERN, html): - self.wrongPassword() diff --git a/pyload/plugins/account/FileomCom.py b/pyload/plugins/account/FileomCom.py deleted file mode 100644 index 583b81d8a..000000000 --- a/pyload/plugins/account/FileomCom.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.internal.XFSAccount import XFSAccount - - -class FileomCom(XFSAccount): - __name = "FileomCom" - __type = "account" - __version = "0.02" - - __description = """Fileom.com account plugin""" - __license = "GPLv3" - __authors = [("Walter Purcaro", "vuolter@gmail.com")] - - - HOSTER_DOMAIN = "fileom.com" diff --git a/pyload/plugins/account/FilerNet.py b/pyload/plugins/account/FilerNet.py deleted file mode 100644 index 36758f37d..000000000 --- a/pyload/plugins/account/FilerNet.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- coding: utf-8 -*- - -import re -import time - -from pyload.plugins.Account import Account - - -class FilerNet(Account): - __name = "FilerNet" - __type = "account" - __version = "0.02" - - __description = """Filer.net account plugin""" - __license = "GPLv3" - __authors = [("stickell", "l.stickell@yahoo.it")] - - - TOKEN_PATTERN = r'_csrf_token" value="([^"]+)" />' - WALID_UNTIL_PATTERN = r'Der Premium-Zugang ist gültig bis (.+)\.\s*</td>' - TRAFFIC_PATTERN = r'Traffic</th>\s*<td>([^<]+)</td>' - FREE_PATTERN = r'Account Status</th>\s*<td>\s*Free' - - - def loadAccountInfo(self, user, req): - html = req.load("https://filer.net/profile") - - # Free user - if re.search(self.FREE_PATTERN, html): - return {"premium": False, "validuntil": None, "trafficleft": None} - - until = re.search(self.WALID_UNTIL_PATTERN, html) - traffic = re.search(self.TRAFFIC_PATTERN, html) - if until and traffic: - validuntil = int(time.mktime(time.strptime(until.group(1), "%d.%m.%Y %H:%M:%S"))) - trafficleft = self.parseTraffic(traffic.group(1)) - return {"premium": True, "validuntil": validuntil, "trafficleft": trafficleft} - else: - self.logError(_("Unable to retrieve account information")) - return {"premium": False, "validuntil": None, "trafficleft": None} - - - def login(self, user, data, req): - html = req.load("https://filer.net/login") - token = re.search(self.TOKEN_PATTERN, html).group(1) - html = req.load("https://filer.net/login_check", - post={"_username": user, "_password": data['password'], - "_remember_me": "on", "_csrf_token": token, "_target_path": "https://filer.net/"}) - if 'Logout' not in html: - self.wrongPassword() diff --git a/pyload/plugins/account/FilerioCom.py b/pyload/plugins/account/FilerioCom.py deleted file mode 100644 index 87a633dff..000000000 --- a/pyload/plugins/account/FilerioCom.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.internal.XFSAccount import XFSAccount - - -class FilerioCom(XFSAccount): - __name = "FilerioCom" - __type = "account" - __version = "0.03" - - __description = """FileRio.in account plugin""" - __license = "GPLv3" - __authors = [("zoidberg", "zoidberg@mujmail.cz")] - - - HOSTER_DOMAIN = "filerio.in" diff --git a/pyload/plugins/account/FilesMailRu.py b/pyload/plugins/account/FilesMailRu.py deleted file mode 100644 index 4a829be89..000000000 --- a/pyload/plugins/account/FilesMailRu.py +++ /dev/null @@ -1,28 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.Account import Account - - -class FilesMailRu(Account): - __name = "FilesMailRu" - __type = "account" - __version = "0.10" - - __description = """Filesmail.ru account plugin""" - __license = "GPLv3" - __authors = [("RaNaN", "RaNaN@pyload.org")] - - - def loadAccountInfo(self, user, req): - return {"validuntil": None, "trafficleft": None} - - - def login(self, user, data, req): - user, domain = user.split("@") - - page = req.load("http://swa.mail.ru/cgi-bin/auth", None, - {"Domain": domain, "Login": user, "Password": data['password'], - "Page": "http://files.mail.ru/"}, cookies=True) - - if "Неверное имя пользователя или пароль" in page: # @TODO seems not to work - self.wrongPassword() diff --git a/pyload/plugins/account/FileserveCom.py b/pyload/plugins/account/FileserveCom.py deleted file mode 100644 index 80be1db70..000000000 --- a/pyload/plugins/account/FileserveCom.py +++ /dev/null @@ -1,44 +0,0 @@ -# -*- coding: utf-8 -*- - -from time import mktime, strptime - -from pyload.plugins.Account import Account -from pyload.utils import json_loads - - -class FileserveCom(Account): - __name = "FileserveCom" - __type = "account" - __version = "0.20" - - __description = """Fileserve.com account plugin""" - __license = "GPLv3" - __authors = [("mkaay", "mkaay@mkaay.de")] - - - def loadAccountInfo(self, user, req): - data = self.getAccountData(user) - - page = req.load("http://app.fileserve.com/api/login/", post={"username": user, "password": data['password'], - "submit": "Submit+Query"}) - res = json_loads(page) - - if res['type'] == "premium": - validuntil = mktime(strptime(res['expireTime'], "%Y-%m-%d %H:%M:%S")) - return {"trafficleft": res['traffic'], "validuntil": validuntil} - else: - return {"premium": False, "trafficleft": None, "validuntil": None} - - - def login(self, user, data, req): - page = req.load("http://app.fileserve.com/api/login/", post={"username": user, "password": data['password'], - "submit": "Submit+Query"}) - res = json_loads(page) - - if not res['type']: - self.wrongPassword() - - #login at fileserv page - req.load("http://www.fileserve.com/login.php", - post={"loginUserName": user, "loginUserPassword": data['password'], "autoLogin": "checked", - "loginFormSubmit": "Login"}) diff --git a/pyload/plugins/account/FourSharedCom.py b/pyload/plugins/account/FourSharedCom.py deleted file mode 100644 index 5565cbfc0..000000000 --- a/pyload/plugins/account/FourSharedCom.py +++ /dev/null @@ -1,33 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.Account import Account -from pyload.utils import json_loads - - -class FourSharedCom(Account): - __name = "FourSharedCom" - __type = "account" - __version = "0.03" - - __description = """FourShared.com account plugin""" - __license = "GPLv3" - __authors = [("zoidberg", "zoidberg@mujmail.cz"), - ("stickell", "l.stickell@yahoo.it")] - - - def loadAccountInfo(self, user, req): - # Free mode only for now - return {"premium": False} - - - def login(self, user, data, req): - req.cj.setCookie("4shared.com", "4langcookie", "en") - res = req.load('http://www.4shared.com/web/login', - post={'login': user, - 'password': data['password'], - 'remember': "on", - '_remember': "on", - 'returnTo': "http://www.4shared.com/account/home.jsp"}) - - if 'Please log in to access your 4shared account' in res: - self.wrongPassword() diff --git a/pyload/plugins/account/FreakshareCom.py b/pyload/plugins/account/FreakshareCom.py deleted file mode 100644 index 4a7bf5b59..000000000 --- a/pyload/plugins/account/FreakshareCom.py +++ /dev/null @@ -1,43 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from time import strptime, mktime - -from pyload.plugins.Account import Account - - -class FreakshareCom(Account): - __name = "FreakshareCom" - __type = "account" - __version = "0.11" - - __description = """Freakshare.com account plugin""" - __license = "GPLv3" - __authors = [("RaNaN", "RaNaN@pyload.org")] - - - def loadAccountInfo(self, user, req): - page = req.load("http://freakshare.com/") - - validuntil = r'ltig bis:</td>\s*<td><b>([\d.:-]+)</b></td>' - validuntil = re.search(validuntil, page, re.M) - validuntil = validuntil.group(1).strip() - validuntil = mktime(strptime(validuntil, "%d.%m.%Y - %H:%M")) - - traffic = r'Traffic verbleibend:</td>\s*<td>([^<]+)' - traffic = re.search(traffic, page, re.M) - traffic = traffic.group(1).strip() - traffic = self.parseTraffic(traffic) - - return {"validuntil": validuntil, "trafficleft": traffic} - - - def login(self, user, data, req): - req.load("http://freakshare.com/index.php?language=EN") - - page = req.load("http://freakshare.com/login.html", None, - {"submit": "Login", "user": user, "pass": data['password']}, cookies=True) - - if ">Wrong Username or Password" in page: - self.wrongPassword() diff --git a/pyload/plugins/account/FreeWayMe.py b/pyload/plugins/account/FreeWayMe.py deleted file mode 100644 index efc4b28fc..000000000 --- a/pyload/plugins/account/FreeWayMe.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.Account import Account -from pyload.utils import json_loads - - -class FreeWayMe(Account): - __name = "FreeWayMe" - __type = "account" - __version = "0.11" - - __description = """FreeWayMe account plugin""" - __license = "GPLv3" - __authors = [("Nicolas Giese", "james@free-way.me")] - - - def loadAccountInfo(self, user, req): - status = self.getAccountStatus(user, req) - if not status: - return False - self.logDebug(status) - - account_info = {"validuntil": -1, "premium": False} - if status['premium'] == "Free": - account_info['trafficleft'] = int(status['guthaben']) * 1024 - elif status['premium'] == "Spender": - account_info['trafficleft'] = -1 - elif status['premium'] == "Flatrate": - account_info = {"validuntil": int(status['Flatrate']), - "trafficleft": -1, - "premium": True} - - return account_info - - - def getpw(self, user): - return self.accounts[user]['password'] - - - def login(self, user, data, req): - status = self.getAccountStatus(user, req) - - # Check if user and password are valid - if not status: - self.wrongPassword() - - - def getAccountStatus(self, user, req): - answer = req.load("https://www.free-way.me/ajax/jd.php", - get={"id": 4, "user": user, "pass": self.accounts[user]['password']}) - self.logDebug("Login: %s" % answer) - if answer == "Invalid login": - self.wrongPassword() - return False - return json_loads(answer) diff --git a/pyload/plugins/account/FshareVn.py b/pyload/plugins/account/FshareVn.py deleted file mode 100644 index 00ad9711c..000000000 --- a/pyload/plugins/account/FshareVn.py +++ /dev/null @@ -1,63 +0,0 @@ -# -*- coding: utf-8 -*- - -from time import mktime, strptime -from pycurl import REFERER -import re - -from pyload.plugins.Account import Account - - -class FshareVn(Account): - __name = "FshareVn" - __type = "account" - __version = "0.07" - - __description = """Fshare.vn account plugin""" - __license = "GPLv3" - __authors = [("zoidberg", "zoidberg@mujmail.cz"), - ("stickell", "l.stickell@yahoo.it")] - - - VALID_UNTIL_PATTERN = ur'<dt>Thời hạn dùng:</dt>\s*<dd>([^<]+)</dd>' - LIFETIME_PATTERN = ur'<dt>Lần đăng nhập trước:</dt>\s*<dd>[^<]+</dd>' - TRAFFIC_LEFT_PATTERN = ur'<dt>Tổng Dung Lượng Tài Khoản</dt>\s*<dd[^>]*>([\d.]+) ([kKMG])B</dd>' - DIRECT_DOWNLOAD_PATTERN = ur'<input type="checkbox"\s*([^=>]*)[^>]*/>Kích hoạt download trực tiếp</dt>' - - - def loadAccountInfo(self, user, req): - html = req.load("http://www.fshare.vn/account_info.php", decode=True) - - if re.search(self.LIFETIME_PATTERN, html): - self.logDebug("Lifetime membership detected") - trafficleft = self.getTrafficLeft() - return {"validuntil": -1, "trafficleft": trafficleft, "premium": True} - - m = re.search(self.VALID_UNTIL_PATTERN, html) - if m: - premium = True - validuntil = mktime(strptime(m.group(1), '%I:%M:%S %p %d-%m-%Y')) - trafficleft = self.getTrafficLeft() - else: - premium = False - validuntil = None - trafficleft = None - - return {"validuntil": validuntil, "trafficleft": trafficleft, "premium": premium} - - - def login(self, user, data, req): - req.http.c.setopt(REFERER, "https://www.fshare.vn/login.php") - - html = req.load('https://www.fshare.vn/login.php', post={ - "login_password": data['password'], - "login_useremail": user, - "url_refe": "http://www.fshare.vn/index.php" - }, referer=True, decode=True) - - if not re.search(r'<img\s+alt="VIP"', html): - self.wrongPassword() - - - def getTrafficLeft(self): - m = re.search(self.TRAFFIC_LEFT_PATTERN, html) - return float(m.group(1)) * 1024 ** {'k': 0, 'K': 0, 'M': 1, 'G': 2}[m.group(2)] if m else 0 diff --git a/pyload/plugins/account/Ftp.py b/pyload/plugins/account/Ftp.py deleted file mode 100644 index cdc4d46cb..000000000 --- a/pyload/plugins/account/Ftp.py +++ /dev/null @@ -1,17 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.Account import Account - - -class Ftp(Account): - __name = "Ftp" - __type = "account" - __version = "0.01" - - __description = """Ftp dummy account plugin""" - __license = "GPLv3" - __authors = [("zoidberg", "zoidberg@mujmail.cz")] - - - login_timeout = -1 #: Unlimited - info_threshold = -1 #: Unlimited diff --git a/pyload/plugins/account/HellshareCz.py b/pyload/plugins/account/HellshareCz.py deleted file mode 100644 index 964511383..000000000 --- a/pyload/plugins/account/HellshareCz.py +++ /dev/null @@ -1,76 +0,0 @@ -# -*- coding: utf-8 -*- - -import re -import time - -from pyload.plugins.Account import Account - - -class HellshareCz(Account): - __name = "HellshareCz" - __type = "account" - __version = "0.14" - - __description = """Hellshare.cz account plugin""" - __license = "GPLv3" - __authors = [("zoidberg", "zoidberg@mujmail.cz")] - - - CREDIT_LEFT_PATTERN = r'<div class="credit-link">\s*<table>\s*<tr>\s*<th>(\d+|\d\d\.\d\d\.)</th>' - - - def loadAccountInfo(self, user, req): - self.relogin(user) - html = req.load("http://www.hellshare.com/") - - m = re.search(self.CREDIT_LEFT_PATTERN, html) - if m is None: - trafficleft = None - validuntil = None - premium = False - else: - credit = m.group(1) - premium = True - try: - if "." in credit: - #Time-based account - vt = [int(x) for x in credit.split('.')[:2]] - lt = time.localtime() - year = lt.tm_year + int(vt[1] < lt.tm_mon or (vt[1] == lt.tm_mon and vt[0] < lt.tm_mday)) - validuntil = time.mktime(time.strptime("%s%d 23:59:59" % (credit, year), "%d.%m.%Y %H:%M:%S")) - trafficleft = -1 - else: - #Traffic-based account - trafficleft = int(credit) * 1024 - validuntil = -1 - except Exception, e: - self.logError(_("Unable to parse credit info"), e) - validuntil = -1 - trafficleft = -1 - - return {"validuntil": validuntil, "trafficleft": trafficleft, "premium": premium} - - - def login(self, user, data, req): - html = req.load('http://www.hellshare.com/') - if req.lastEffectiveURL != 'http://www.hellshare.com/': - #Switch to English - self.logDebug("Switch lang - URL: %s" % req.lastEffectiveURL) - json = req.load("%s?do=locRouter-show" % req.lastEffectiveURL) - hash = re.search(r"(\-\-[0-9a-f]+\-)", json).group(1) - self.logDebug("Switch lang - HASH: %s" % hash) - html = req.load('http://www.hellshare.com/%s/' % hash) - - if re.search(self.CREDIT_LEFT_PATTERN, html): - self.logDebug("Already logged in") - return - - html = req.load('http://www.hellshare.com/login?do=loginForm-submit', post={ - "login": "Log in", - "password": data['password'], - "username": user, - "perm_login": "on" - }) - - if "<p>You input a wrong user name or wrong password</p>" in html: - self.wrongPassword() diff --git a/pyload/plugins/account/Http.py b/pyload/plugins/account/Http.py deleted file mode 100644 index 141443e27..000000000 --- a/pyload/plugins/account/Http.py +++ /dev/null @@ -1,17 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.Account import Account - - -class Http(Account): - __name = "Http" - __type = "account" - __version = "0.01" - - __description = """Http dummy account plugin""" - __license = "GPLv3" - __authors = [("zoidberg", "zoidberg@mujmail.cz")] - - - login_timeout = -1 #: Unlimited - info_threshold = -1 #: Unlimited diff --git a/pyload/plugins/account/HugefilesNet.py b/pyload/plugins/account/HugefilesNet.py deleted file mode 100644 index 475d50295..000000000 --- a/pyload/plugins/account/HugefilesNet.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.internal.XFSAccount import XFSAccount - - -class HugefilesNet(XFSAccount): - __name = "HugefilesNet" - __type = "account" - __version = "0.02" - - __description = """Hugefiles.net account plugin""" - __license = "GPLv3" - __authors = [("Walter Purcaro", "vuolter@gmail.com")] - - - HOSTER_DOMAIN = "hugefiles.net" diff --git a/pyload/plugins/account/HundredEightyUploadCom.py b/pyload/plugins/account/HundredEightyUploadCom.py deleted file mode 100644 index 6a22285cb..000000000 --- a/pyload/plugins/account/HundredEightyUploadCom.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.internal.XFSAccount import XFSAccount - - -class HundredEightyUploadCom(XFSAccount): - __name = "HundredEightyUploadCom" - __type = "account" - __version = "0.02" - - __description = """180upload.com account plugin""" - __license = "GPLv3" - __authors = [("Walter Purcaro", "vuolter@gmail.com")] - - - HOSTER_DOMAIN = "180upload.com" diff --git a/pyload/plugins/account/JunocloudMe.py b/pyload/plugins/account/JunocloudMe.py deleted file mode 100644 index 547aec47a..000000000 --- a/pyload/plugins/account/JunocloudMe.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.internal.XFSAccount import XFSAccount - - -class JunocloudMe(XFSAccount): - __name = "JunocloudMe" - __type = "account" - __version = "0.02" - - __description = """Junocloud.me account plugin""" - __license = "GPLv3" - __authors = [("guidobelix", "guidobelix@hotmail.it")] - - - HOSTER_DOMAIN = "junocloud.me" diff --git a/pyload/plugins/account/Keep2shareCc.py b/pyload/plugins/account/Keep2shareCc.py deleted file mode 100644 index cbbf75548..000000000 --- a/pyload/plugins/account/Keep2shareCc.py +++ /dev/null @@ -1,69 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from time import gmtime, mktime, strptime - -from pyload.plugins.Account import Account - - -class Keep2shareCc(Account): - __name = "Keep2shareCc" - __type = "account" - __version = "0.02" - - __description = """Keep2share.cc account plugin""" - __license = "GPLv3" - __authors = [("aeronaut", "aeronaut@pianoguy.de")] - - - VALID_UNTIL_PATTERN = r'Premium expires: <b>(.+?)</b>' - TRAFFIC_LEFT_PATTERN = r'Available traffic \(today\):<b><a href="/user/statistic.html">(.+?)</a>' - - LOGIN_FAIL_PATTERN = r'Please fix the following input errors' - - - def loadAccountInfo(self, user, req): - validuntil = None - trafficleft = None - premium = None - - html = req.load("http://keep2share.cc/site/profile.html", decode=True) - - m = re.search(self.VALID_UNTIL_PATTERN, html) - if m: - expiredate = m.group(1).strip() - self.logDebug("Expire date: " + expiredate) - - try: - validuntil = mktime(strptime(expiredate, "%Y.%m.%d")) - - except Exception, e: - self.logError(e) - - else: - if validuntil > mktime(gmtime()): - premium = True - else: - premium = False - validuntil = None - - m = re.search(self.TRAFFIC_LEFT_PATTERN, html) - if m: - try: - trafficleft = self.parseTraffic(m.group(1)) - - except Exception, e: - self.logError(e) - - return {'validuntil': validuntil, 'trafficleft': trafficleft, 'premium': premium} - - - def login(self, user, data, req): - req.cj.setCookie("keep2share.cc", "lang", "en") - - html = req.load("http://keep2share.cc/login.html", - post={'LoginForm[username]': user, 'LoginForm[password]': data['password']}) - - if re.search(self.LOGIN_FAIL_PATTERN, html): - self.wrongPassword() diff --git a/pyload/plugins/account/LetitbitNet.py b/pyload/plugins/account/LetitbitNet.py deleted file mode 100644 index 5a3d2ea90..000000000 --- a/pyload/plugins/account/LetitbitNet.py +++ /dev/null @@ -1,34 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.Account import Account -# from pyload.utils import json_loads, json_dumps - - -class LetitbitNet(Account): - __name = "LetitbitNet" - __type = "account" - __version = "0.01" - - __description = """Letitbit.net account plugin""" - __license = "GPLv3" - __authors = [("stickell", "l.stickell@yahoo.it")] - - - def loadAccountInfo(self, user, req): - ## DISABLED BECAUSE IT GET 'key exausted' EVEN IF VALID ## - # api_key = self.accounts[user]['password'] - # json_data = [api_key, ['key/info']] - # api_rep = req.load('http://api.letitbit.net/json', post={'r': json_dumps(json_data)}) - # self.logDebug("API Key Info: " + api_rep) - # api_rep = json_loads(api_rep) - # - # if api_rep['status'] == 'FAIL': - # self.logWarning(api_rep['data']) - # return {'valid': False, 'premium': False} - - return {"premium": True} - - - def login(self, user, data, req): - # API_KEY is the username and the PREMIUM_KEY is the password - self.logInfo(_("You must use your API KEY as username and the PREMIUM KEY as password")) diff --git a/pyload/plugins/account/LinestorageCom.py b/pyload/plugins/account/LinestorageCom.py deleted file mode 100644 index f94ee8fa0..000000000 --- a/pyload/plugins/account/LinestorageCom.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.internal.XFSAccount import XFSAccount - - -class LinestorageCom(XFSAccount): - __name = "LinestorageCom" - __type = "account" - __version = "0.02" - - __description = """Linestorage.com account plugin""" - __license = "GPLv3" - __authors = [("Walter Purcaro", "vuolter@gmail.com")] - - - HOSTER_DOMAIN = "linestorage.com" diff --git a/pyload/plugins/account/LinksnappyCom.py b/pyload/plugins/account/LinksnappyCom.py deleted file mode 100644 index cf3d7a6e2..000000000 --- a/pyload/plugins/account/LinksnappyCom.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- coding: utf-8 -*- - -from hashlib import md5 - -from pyload.plugins.Account import Account -from pyload.utils import json_loads - - -class LinksnappyCom(Account): - __name = "LinksnappyCom" - __type = "account" - __version = "0.02" - - __description = """Linksnappy.com account plugin""" - __license = "GPLv3" - __authors = [("stickell", "l.stickell@yahoo.it")] - - - def loadAccountInfo(self, user, req): - data = self.getAccountData(user) - r = req.load('http://gen.linksnappy.com/lseAPI.php', - get={'act': 'USERDETAILS', 'username': user, 'password': md5(data['password']).hexdigest()}) - self.logDebug("JSON data: " + r) - j = json_loads(r) - - if j['error']: - return {"premium": False} - - validuntil = j['return']['expire'] - if validuntil == 'lifetime': - validuntil = -1 - elif validuntil == 'expired': - return {"premium": False} - else: - validuntil = float(validuntil) - - if 'trafficleft' not in j['return'] or isinstance(j['return']['trafficleft'], str): - trafficleft = -1 - else: - trafficleft = int(j['return']['trafficleft']) * 1024 - - return {"premium": True, "validuntil": validuntil, "trafficleft": trafficleft} - - - def login(self, user, data, req): - r = req.load('http://gen.linksnappy.com/lseAPI.php', - get={'act': 'USERDETAILS', 'username': user, 'password': md5(data['password']).hexdigest()}) - - if 'Invalid Account Details' in r: - self.wrongPassword() diff --git a/pyload/plugins/account/LomafileCom.py b/pyload/plugins/account/LomafileCom.py deleted file mode 100644 index fdf0bd528..000000000 --- a/pyload/plugins/account/LomafileCom.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.internal.XFSAccount import XFSAccount - - -class LomafileCom(XFSAccount): - __name = "LomafileCom" - __type = "account" - __version = "0.02" - - __description = """Lomafile.com account plugin""" - __license = "GPLv3" - __authors = [("guidobelix", "guidobelix@hotmail.it")] - - - HOSTER_DOMAIN = "lomafile.com" diff --git a/pyload/plugins/account/MegaDebridEu.py b/pyload/plugins/account/MegaDebridEu.py deleted file mode 100644 index 7b0e6f3f4..000000000 --- a/pyload/plugins/account/MegaDebridEu.py +++ /dev/null @@ -1,39 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.Account import Account -from pyload.utils import json_loads - - -class MegaDebridEu(Account): - __name = "MegaDebridEu" - __type = "account" - __version = "0.20" - - __description = """mega-debrid.eu account plugin""" - __license = "GPLv3" - __authors = [("D.Ducatel", "dducatel@je-geek.fr")] - - - # Define the base URL of MegaDebrid api - API_URL = "https://www.mega-debrid.eu/api.php" - - - def loadAccountInfo(self, user, req): - data = self.getAccountData(user) - jsonResponse = req.load(self.API_URL, - get={'action': 'connectUser', 'login': user, 'password': data['password']}) - res = json_loads(jsonResponse) - - if res['response_code'] == "ok": - return {"premium": True, "validuntil": float(res['vip_end']), "status": True} - else: - self.logError(res) - return {"status": False, "premium": False} - - - def login(self, user, data, req): - jsonResponse = req.load(self.API_URL, - get={'action': 'connectUser', 'login': user, 'password': data['password']}) - res = json_loads(jsonResponse) - if res['response_code'] != "ok": - self.wrongPassword() diff --git a/pyload/plugins/account/MegaRapidCz.py b/pyload/plugins/account/MegaRapidCz.py deleted file mode 100644 index ffe08319f..000000000 --- a/pyload/plugins/account/MegaRapidCz.py +++ /dev/null @@ -1,59 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from time import mktime, strptime -from pyload.plugins.Account import Account - - -class MegaRapidCz(Account): - __name = "MegaRapidCz" - __type = "account" - __version = "0.34" - - __description = """MegaRapid.cz account plugin""" - __license = "GPLv3" - __authors = [("MikyWoW", "mikywow@seznam.cz"), - ("zoidberg", "zoidberg@mujmail.cz")] - - - login_timeout = 60 - - LIMITDL_PATTERN = ur'<td>Max. počet paralelních stahování: </td><td>(\d+)' - VALID_UNTIL_PATTERN = ur'<td>Paušální stahování aktivní. Vyprší </td><td><strong>(.*?)</strong>' - TRAFFIC_LEFT_PATTERN = r'<tr><td>Kredit</td><td>(.*?) GiB' - - - def loadAccountInfo(self, user, req): - html = req.load("http://megarapid.cz/mujucet/", decode=True) - - m = re.search(self.LIMITDL_PATTERN, html) - if m: - data = self.getAccountData(user) - data['options']['limitDL'] = [int(m.group(1))] - - m = re.search(self.VALID_UNTIL_PATTERN, html) - if m: - validuntil = mktime(strptime(m.group(1), "%d.%m.%Y - %H:%M")) - return {"premium": True, "trafficleft": -1, "validuntil": validuntil} - - m = re.search(self.TRAFFIC_LEFT_PATTERN, html) - if m: - trafficleft = float(m.group(1)) * (1 << 20) - return {"premium": True, "trafficleft": trafficleft, "validuntil": -1} - - return {"premium": False, "trafficleft": None, "validuntil": None} - - - def login(self, user, data, req): - htm = req.load("http://megarapid.cz/prihlaseni/") - if "Heslo:" in htm: - start = htm.index('id="inp_hash" name="hash" value="') - htm = htm[start + 33:] - hashes = htm[0:32] - htm = req.load("http://megarapid.cz/prihlaseni/", - post={"hash": hashes, - "login": user, - "pass1": data['password'], - "remember": 0, - "sbmt": u"Přihlásit"}) diff --git a/pyload/plugins/account/MegasharesCom.py b/pyload/plugins/account/MegasharesCom.py deleted file mode 100644 index d55e6c3a4..000000000 --- a/pyload/plugins/account/MegasharesCom.py +++ /dev/null @@ -1,48 +0,0 @@ -# -*- coding: utf-8 -*- - -import re -from time import mktime, strptime - -from pyload.plugins.Account import Account - - -class MegasharesCom(Account): - __name = "MegasharesCom" - __type = "account" - __version = "0.02" - - __description = """Megashares.com account plugin""" - __license = "GPLv3" - __authors = [("zoidberg", "zoidberg@mujmail.cz")] - - - VALID_UNTIL_PATTERN = r'<p class="premium_info_box">Period Ends: (\w{3} \d{1,2}, \d{4})</p>' - - - def loadAccountInfo(self, user, req): - #self.relogin(user) - html = req.load("http://d01.megashares.com/myms.php", decode=True) - - premium = False if '>Premium Upgrade<' in html else True - - validuntil = trafficleft = -1 - try: - timestr = re.search(self.VALID_UNTIL_PATTERN, html).group(1) - self.logDebug(timestr) - validuntil = mktime(strptime(timestr, "%b %d, %Y")) - except Exception, e: - self.logError(e) - - return {"validuntil": validuntil, "trafficleft": -1, "premium": premium} - - - def login(self, user, data, req): - html = req.load('http://d01.megashares.com/myms_login.php', post={ - "httpref": "", - "myms_login": "Login", - "mymslogin_name": user, - "mymspassword": data['password'] - }, decode=True) - - if not '<span class="b ml">%s</span>' % user in html: - self.wrongPassword() diff --git a/pyload/plugins/account/MovReelCom.py b/pyload/plugins/account/MovReelCom.py deleted file mode 100644 index 7e41693e0..000000000 --- a/pyload/plugins/account/MovReelCom.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.internal.XFSAccount import XFSAccount - - -class MovReelCom(XFSAccount): - __name = "MovReelCom" - __type = "account" - __version = "0.03" - - __description = """Movreel.com account plugin""" - __license = "GPLv3" - __authors = [("t4skforce", "t4skforce1337[AT]gmail[DOT]com")] - - - login_timeout = 60 - info_threshold = 30 - - HOSTER_DOMAIN = "movreel.com" diff --git a/pyload/plugins/account/MultishareCz.py b/pyload/plugins/account/MultishareCz.py deleted file mode 100644 index cb2f6a1d4..000000000 --- a/pyload/plugins/account/MultishareCz.py +++ /dev/null @@ -1,44 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from pyload.plugins.Account import Account - - -class MultishareCz(Account): - __name = "MultishareCz" - __type = "account" - __version = "0.03" - - __description = """Multishare.cz account plugin""" - __license = "GPLv3" - __authors = [("zoidberg", "zoidberg@mujmail.cz")] - - - TRAFFIC_LEFT_PATTERN = r'<span class="profil-zvyrazneni">Kredit:</span>\s*<strong>(?P<S>[\d.,]+) (?P<U>[\w^_]+)</strong>' - ACCOUNT_INFO_PATTERN = r'<input type="hidden" id="(u_ID|u_hash)" name="[^"]*" value="([^"]+)">' - - - def loadAccountInfo(self, user, req): - #self.relogin(user) - html = req.load("http://www.multishare.cz/profil/", decode=True) - - m = re.search(self.TRAFFIC_LEFT_PATTERN, html) - trafficleft = self.parseTraffic(m.group('S'), m.group('U')) if m else 0 - self.premium = True if trafficleft else False - - html = req.load("http://www.multishare.cz/", decode=True) - mms_info = dict(re.findall(self.ACCOUNT_INFO_PATTERN, html)) - - return dict(mms_info, **{"validuntil": -1, "trafficleft": trafficleft}) - - - def login(self, user, data, req): - html = req.load('http://www.multishare.cz/html/prihlaseni_process.php', post={ - "akce": "Přihlásit", - "heslo": data['password'], - "jmeno": user - }, decode=True) - - if '<div class="akce-chyba akce">' in html: - self.wrongPassword() diff --git a/pyload/plugins/account/MyfastfileCom.py b/pyload/plugins/account/MyfastfileCom.py deleted file mode 100644 index 3aa16ee80..000000000 --- a/pyload/plugins/account/MyfastfileCom.py +++ /dev/null @@ -1,35 +0,0 @@ -# -*- coding: utf-8 -*- - -from time import time - -from pyload.plugins.Account import Account -from pyload.utils import json_loads - - -class MyfastfileCom(Account): - __name = "MyfastfileCom" - __type = "account" - __version = "0.02" - - __description = """Myfastfile.com account plugin""" - __license = "GPLv3" - __authors = [("stickell", "l.stickell@yahoo.it")] - - - def loadAccountInfo(self, user, req): - if 'days_left' in self.json_data: - validuntil = int(time() + self.json_data['days_left'] * 24 * 60 * 60) - return {"premium": True, "validuntil": validuntil, "trafficleft": -1} - else: - self.logError(_("Unable to get account information")) - - - def login(self, user, data, req): - # Password to use is the API-Password written in http://myfastfile.com/myaccount - html = req.load("http://myfastfile.com/api.php", - get={"user": user, "pass": data['password']}) - self.logDebug("JSON data: " + html) - self.json_data = json_loads(html) - if self.json_data['status'] != 'ok': - self.logError(_('Invalid login. The password to use is the API-Password you find in your "My Account" page')) - self.wrongPassword() diff --git a/pyload/plugins/account/NetloadIn.py b/pyload/plugins/account/NetloadIn.py deleted file mode 100644 index e2cb03b91..000000000 --- a/pyload/plugins/account/NetloadIn.py +++ /dev/null @@ -1,40 +0,0 @@ -# -*- coding: utf-8 -*- - -import re -from time import time - -from pyload.plugins.Account import Account - - -class NetloadIn(Account): - __name = "NetloadIn" - __type = "account" - __version = "0.22" - - __description = """Netload.in account plugin""" - __license = "GPLv3" - __authors = [("RaNaN", "RaNaN@pyload.org"), - ("CryNickSystems", "webmaster@pcProfil.de")] - - - def loadAccountInfo(self, user, req): - page = req.load("http://netload.in/index.php", get={'id': 2, 'lang': "de"}) - left = r'>(\d+) (Tag|Tage), (\d+) Stunden<' - left = re.search(left, page) - if left: - validuntil = time() + int(left.group(1)) * 24 * 60 * 60 + int(left.group(3)) * 60 * 60 - trafficleft = -1 - premium = True - else: - validuntil = None - premium = False - trafficleft = None - return {"validuntil": validuntil, "trafficleft": trafficleft, "premium": premium} - - - def login(self, user, data, req): - page = req.load("http://netload.in/index.php", None, - {"txtuser": user, "txtpass": data['password'], "txtcheck": "login", "txtlogin": "Login"}, - cookies=True) - if "password or it might be invalid!" in page: - self.wrongPassword() diff --git a/pyload/plugins/account/NosuploadCom.py b/pyload/plugins/account/NosuploadCom.py deleted file mode 100644 index d839827ed..000000000 --- a/pyload/plugins/account/NosuploadCom.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.internal.XFSAccount import XFSAccount - - -class NosuploadCom(XFSAccount): - __name = "NosuploadCom" - __type = "account" - __version = "0.02" - - __description = """Nosupload.com account plugin""" - __license = "GPLv3" - __authors = [("Walter Purcaro", "vuolter@gmail.com")] - - - HOSTER_DOMAIN = "nosupload.com" diff --git a/pyload/plugins/account/NovafileCom.py b/pyload/plugins/account/NovafileCom.py deleted file mode 100644 index b244139bc..000000000 --- a/pyload/plugins/account/NovafileCom.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.internal.XFSAccount import XFSAccount - - -class NovafileCom(XFSAccount): - __name = "NovafileCom" - __type = "account" - __version = "0.02" - - __description = """Novafile.com account plugin""" - __license = "GPLv3" - __authors = [("Walter Purcaro", "vuolter@gmail.com")] - - - HOSTER_DOMAIN = "novafile.com" diff --git a/pyload/plugins/account/NowVideoAt.py b/pyload/plugins/account/NowVideoAt.py deleted file mode 100644 index 0926dc03b..000000000 --- a/pyload/plugins/account/NowVideoAt.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from time import gmtime, mktime, strptime - -from pyload.plugins.Account import Account - - -class NowVideoAt(Account): - __name = "NowVideoAt" - __type = "account" - __version = "0.01" - - __description = """NowVideo.at account plugin""" - __license = "GPLv3" - __authors = [("Walter Purcaro", "vuolter@gmail.com")] - - - VALID_UNTIL_PATTERN = r'>Your premium membership expires on: (.+?)<' - - - def loadAccountInfo(self, user, req): - validuntil = None - trafficleft = -1 - premium = None - - html = req.load("http://www.nowvideo.at/premium.php") - - m = re.search(self.VALID_UNTIL_PATTERN, html) - if m: - expiredate = m.group(1).strip() - self.logDebug("Expire date: " + expiredate) - - try: - validuntil = mktime(strptime(expiredate, "%Y-%b-%d")) - - except Exception, e: - self.logError(e) - - else: - if validuntil > mktime(gmtime()): - premium = True - else: - premium = False - validuntil = -1 - - return {"validuntil": validuntil, "trafficleft": trafficleft, "premium": premium} - - - def login(self, user, data, req): - html = req.load("http://www.nowvideo.at/login.php", - post={'user': user, 'pass': data['password']}) - - if ">Invalid login details" is html: - self.wrongPassword() diff --git a/pyload/plugins/account/OboomCom.py b/pyload/plugins/account/OboomCom.py deleted file mode 100644 index 4ea2483aa..000000000 --- a/pyload/plugins/account/OboomCom.py +++ /dev/null @@ -1,62 +0,0 @@ -# -*- coding: utf-8 -*- - -import time - -from beaker.crypto.pbkdf2 import PBKDF2 - -from pyload.utils import json_loads -from pyload.plugins.Account import Account - - -class OboomCom(Account): - __name = "OboomCom" - __type = "account" - __version = "0.21" - - __description = """Oboom.com account plugin""" - __license = "GPLv3" - __authors = [("stanley", "stanley.foerster@gmail.com")] - - - def loadAccountData(self, user, req): - passwd = self.getAccountData(user)['password'] - salt = passwd[::-1] - pbkdf2 = PBKDF2(passwd, salt, 1000).hexread(16) - result = json_loads(req.load("https://www.oboom.com/1/login", get={"auth": user, "pass": pbkdf2})) - if not result[0] == 200: - self.logWarning(_("Failed to log in: %s") % result[1]) - self.wrongPassword() - return result[1] - - - def loadAccountInfo(self, name, req): - accountData = self.loadAccountData(name, req) - - userData = accountData['user'] - - if userData['premium'] == "null": - premium = False - else: - premium = True - - if userData['premium_unix'] == "null": - validUntil = -1 - else: - validUntil = int(userData['premium_unix']) - - traffic = userData['traffic'] - - trafficLeft = traffic['current'] - maxTraffic = traffic['max'] - - session = accountData['session'] - - return {'premium' : premium, - 'validuntil' : validUntil, - 'trafficleft': trafficLeft / 1024, #@TODO: Remove / 1024 in 0.4.10 - 'maxtraffic' : maxTraffic / 1024, #@TODO: Remove / 1024 in 0.4.10 - 'session' : session} - - - def login(self, user, data, req): - self.loadAccountData(user, req) diff --git a/pyload/plugins/account/OneFichierCom.py b/pyload/plugins/account/OneFichierCom.py deleted file mode 100644 index 3ee602202..000000000 --- a/pyload/plugins/account/OneFichierCom.py +++ /dev/null @@ -1,55 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from time import strptime, mktime - -from pycurl import REFERER - -from pyload.plugins.Account import Account - - -class OneFichierCom(Account): - __name = "OneFichierCom" - __type = "account" - __version = "0.11" - - __description = """1fichier.com account plugin""" - __license = "GPLv3" - __authors = [("Elrick69", "elrick69[AT]rocketmail[DOT]com"), - ("Walter Purcaro", "vuolter@gmail.com")] - - - VALID_UNTIL_PATTERN = r'Your Premium Status will end the (\d+/\d+/\d+)' - - - def loadAccountInfo(self, user, req): - validuntil = None - trafficleft = -1 - premium = None - - html = req.load("https://1fichier.com/console/abo.pl") - - m = re.search(self.VALID_UNTIL_PATTERN, html) - if m: - expiredate = m.group(1) - self.logDebug("Expire date: " + expiredate) - - try: - validuntil = mktime(strptime(expiredate, "%d/%m/%Y")) - except Exception, e: - self.logError(e) - else: - premium = True - - return {'validuntil': validuntil, 'trafficleft': trafficleft, 'premium': premium or False} - - - def login(self, user, data, req): - req.http.c.setopt(REFERER, "https://1fichier.com/login.pl?lg=en") - - html = req.load("https://1fichier.com/login.pl?lg=en", - post={'mail': user, 'pass': data['password'], 'It': "on", 'purge': "off", 'valider': "Send"}) - - if '>Invalid email address' in html or '>Invalid password' in html: - self.wrongPassword() diff --git a/pyload/plugins/account/OverLoadMe.py b/pyload/plugins/account/OverLoadMe.py deleted file mode 100644 index 2bedb496a..000000000 --- a/pyload/plugins/account/OverLoadMe.py +++ /dev/null @@ -1,36 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.Account import Account -from pyload.utils import json_loads - - -class OverLoadMe(Account): - __name = "OverLoadMe" - __type = "account" - __version = "0.01" - - __description = """Over-Load.me account plugin""" - __license = "GPLv3" - __authors = [("marley", "marley@over-load.me")] - - - def loadAccountInfo(self, user, req): - data = self.getAccountData(user) - page = req.load("https://api.over-load.me/account.php", get={"user": user, "auth": data['password']}).strip() - data = json_loads(page) - - # Check for premium - if data['membership'] == "Free": - return {"premium": False} - - account_info = {"validuntil": data['expirationunix'], "trafficleft": -1} - return account_info - - - def login(self, user, data, req): - jsondata = req.load("https://api.over-load.me/account.php", - get={"user": user, "auth": data['password']}).strip() - data = json_loads(jsondata) - - if data['err'] == 1: - self.wrongPassword() diff --git a/pyload/plugins/account/PremiumTo.py b/pyload/plugins/account/PremiumTo.py deleted file mode 100644 index 191678434..000000000 --- a/pyload/plugins/account/PremiumTo.py +++ /dev/null @@ -1,34 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.Account import Account - - -class PremiumTo(Account): - __name = "PremiumTo" - __type = "account" - __version = "0.04" - - __description = """Premium.to account plugin""" - __license = "GPLv3" - __authors = [("RaNaN", "RaNaN@pyload.org"), - ("zoidberg", "zoidberg@mujmail.cz"), - ("stickell", "l.stickell@yahoo.it")] - - - - def loadAccountInfo(self, user, req): - api_r = req.load("http://premium.to/api/straffic.php", - get={'username': self.username, 'password': self.password}) - traffic = sum(map(int, api_r.split(';'))) - - return {"trafficleft": int(traffic) / 1024, "validuntil": -1} #@TODO: Remove / 1024 in 0.4.10 - - - def login(self, user, data, req): - self.username = user - self.password = data['password'] - authcode = req.load("http://premium.to/api/getauthcode.php", - get={'username': user, 'password': self.password}).strip() - - if "wrong username" in authcode: - self.wrongPassword() diff --git a/pyload/plugins/account/PremiumizeMe.py b/pyload/plugins/account/PremiumizeMe.py deleted file mode 100644 index 96dd67b98..000000000 --- a/pyload/plugins/account/PremiumizeMe.py +++ /dev/null @@ -1,49 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.Account import Account - -from pyload.utils import json_loads - - -class PremiumizeMe(Account): - __name = "PremiumizeMe" - __type = "account" - __version = "0.11" - - __description = """Premiumize.me account plugin""" - __license = "GPLv3" - __authors = [("Florian Franzen", "FlorianFranzen@gmail.com")] - - - def loadAccountInfo(self, user, req): - # Get user data from premiumize.me - status = self.getAccountStatus(user, req) - self.logDebug(status) - - # Parse account info - account_info = {"validuntil": float(status['result']['expires']), - "trafficleft": max(0, status['result']['trafficleft_bytes'])} - - if status['result']['type'] == 'free': - account_info['premium'] = False - - return account_info - - - def login(self, user, data, req): - # Get user data from premiumize.me - status = self.getAccountStatus(user, req) - - # Check if user and password are valid - if status['status'] != 200: - self.wrongPassword() - - - def getAccountStatus(self, user, req): - # Use premiumize.me API v1 (see https://secure.premiumize.me/?show=api) - # to retrieve account info and return the parsed json answer - answer = req.load("https://api.premiumize.me/pm-api/v1.php", - get={'method' : "accountstatus", - 'params[login]': user, - 'params[pass]' : self.accounts[user]['password']}) - return json_loads(answer) diff --git a/pyload/plugins/account/QuickshareCz.py b/pyload/plugins/account/QuickshareCz.py deleted file mode 100644 index c4da516fb..000000000 --- a/pyload/plugins/account/QuickshareCz.py +++ /dev/null @@ -1,43 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from pyload.plugins.Account import Account - - -class QuickshareCz(Account): - __name = "QuickshareCz" - __type = "account" - __version = "0.02" - - __description = """Quickshare.cz account plugin""" - __license = "GPLv3" - __authors = [("zoidberg", "zoidberg@mujmail.cz")] - - - TRAFFIC_LEFT_PATTERN = r'Stav kreditu: <strong>(.+?)</strong>' - - - def loadAccountInfo(self, user, req): - html = req.load("http://www.quickshare.cz/premium", decode=True) - - m = re.search(self.TRAFFIC_LEFT_PATTERN, html) - if m: - trafficleft = self.parseTraffic(m.group(1)) - premium = True if trafficleft else False - else: - trafficleft = None - premium = False - - return {"validuntil": -1, "trafficleft": trafficleft, "premium": premium} - - - def login(self, user, data, req): - html = req.load('http://www.quickshare.cz/html/prihlaseni_process.php', post={ - "akce": u'Přihlásit', - "heslo": data['password'], - "jmeno": user - }, decode=True) - - if u'>Takový uživatel neexistuje.<' in html or u'>Špatné heslo.<' in html: - self.wrongPassword() diff --git a/pyload/plugins/account/RPNetBiz.py b/pyload/plugins/account/RPNetBiz.py deleted file mode 100644 index b652b377c..000000000 --- a/pyload/plugins/account/RPNetBiz.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.Account import Account -from pyload.utils import json_loads - - -class RPNetBiz(Account): - __name = "RPNetBiz" - __type = "account" - __version = "0.10" - - __description = """RPNet.biz account plugin""" - __license = "GPLv3" - __authors = [("Dman", "dmanugm@gmail.com")] - - - def loadAccountInfo(self, user, req): - # Get account information from rpnet.biz - res = self.getAccountStatus(user, req) - try: - if res['accountInfo']['isPremium']: - # Parse account info. Change the trafficleft later to support per host info. - account_info = {"validuntil": int(res['accountInfo']['premiumExpiry']), - "trafficleft": -1, "premium": True} - else: - account_info = {"validuntil": None, "trafficleft": None, "premium": False} - - except KeyError: - #handle wrong password exception - account_info = {"validuntil": None, "trafficleft": None, "premium": False} - - return account_info - - - def login(self, user, data, req): - # Get account information from rpnet.biz - res = self.getAccountStatus(user, req) - - # If we have an error in the res, we have wrong login information - if 'error' in res: - self.wrongPassword() - - - def getAccountStatus(self, user, req): - # Using the rpnet API, check if valid premium account - res = req.load("https://premium.rpnet.biz/client_api.php", - get={"username": user, "password": self.accounts[user]['password'], - "action": "showAccountInformation"}) - self.logDebug("JSON data: %s" % res) - - return json_loads(res) diff --git a/pyload/plugins/account/RapidfileshareNet.py b/pyload/plugins/account/RapidfileshareNet.py deleted file mode 100644 index 1c055ea19..000000000 --- a/pyload/plugins/account/RapidfileshareNet.py +++ /dev/null @@ -1,18 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.internal.XFSAccount import XFSAccount - - -class RapidfileshareNet(XFSAccount): - __name = "RapidfileshareNet" - __type = "account" - __version = "0.05" - - __description = """Rapidfileshare.net account plugin""" - __license = "GPLv3" - __authors = [("guidobelix", "guidobelix@hotmail.it")] - - - HOSTER_DOMAIN = "rapidfileshare.net" - - TRAFFIC_LEFT_PATTERN = r'>Traffic available today:</TD><TD><label for="name">\s*(?P<S>[\d.,]+)\s*(?:(?P<U>[\w^_]+))?' diff --git a/pyload/plugins/account/RapidgatorNet.py b/pyload/plugins/account/RapidgatorNet.py deleted file mode 100644 index 3dd8cf3d2..000000000 --- a/pyload/plugins/account/RapidgatorNet.py +++ /dev/null @@ -1,58 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.Account import Account -from pyload.utils import json_loads - - -class RapidgatorNet(Account): - __name = "RapidgatorNet" - __type = "account" - __version = "0.04" - - __description = """Rapidgator.net account plugin""" - __license = "GPLv3" - __authors = [("zoidberg", "zoidberg@mujmail.cz")] - - - API_URL = 'http://rapidgator.net/api/user' - - - def loadAccountInfo(self, user, req): - try: - sid = self.getAccountData(user).get('SID') - assert sid - - json = req.load("%s/info?sid=%s" % (self.API_URL, sid)) - self.logDebug("API:USERINFO", json) - json = json_loads(json) - - if json['response_status'] == 200: - if "reset_in" in json['response']: - self.scheduleRefresh(user, json['response']['reset_in']) - - return {"validuntil": json['response']['expire_date'], - "trafficleft": int(json['response']['traffic_left']), - "premium": True} - else: - self.logError(json['response_details']) - except Exception, e: - self.logError(e) - - return {"validuntil": None, "trafficleft": None, "premium": False} - - - def login(self, user, data, req): - try: - json = req.load('%s/login' % self.API_URL, post={"username": user, "password": data['password']}) - self.logDebug("API:LOGIN", json) - json = json_loads(json) - - if json['response_status'] == 200: - data['SID'] = str(json['response']['session_id']) - return - else: - self.logError(json['response_details']) - except Exception, e: - self.logError(e) - - self.wrongPassword() diff --git a/pyload/plugins/account/RapiduNet.py b/pyload/plugins/account/RapiduNet.py deleted file mode 100644 index 4489c6fbc..000000000 --- a/pyload/plugins/account/RapiduNet.py +++ /dev/null @@ -1,48 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from pyload.plugins.Account import Account -from pyload.utils import json_loads - - -class RapiduNet(Account): - __name = "RapiduNet" - __type = "account" - __version = "0.02" - - __description = """Rapidu.net account plugin""" - __license = "GPLv3" - __authors = [("prOq", "")] - - - PREMIUM_PATTERN = r'<a href="premium/" style="padding-left: 0px;">Account: <b>Premium</b></a>' - - - def loadAccountInfo(self, user, req): - info = {'validuntil': None, 'trafficleft': None, 'premium': False} - - req.load("https://rapidu.net/ajax.php", get={'a': "getChangeLang"}, post={"_go": "", "lang": "en"}) - html = req.load("https://rapidu.net/", decode=True) - - if re.search(self.PREMIUM_PATTERN, html): - info['premium'] = True - - return info - - - def login(self, user, data, req): - try: - json = json_loads(req.load("https://rapidu.net/ajax.php?a=getUserLogin", - post={'_go': "", - 'login': user, - 'pass': data['password'], - 'member': "1"})) - - self.logDebug(json) - - if not json['message'] == "success": - self.wrongPassword() - - except Exception, e: - self.logError(e) diff --git a/pyload/plugins/account/RarefileNet.py b/pyload/plugins/account/RarefileNet.py deleted file mode 100644 index c0b855373..000000000 --- a/pyload/plugins/account/RarefileNet.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.internal.XFSAccount import XFSAccount - - -class RarefileNet(XFSAccount): - __name = "RarefileNet" - __type = "account" - __version = "0.04" - - __description = """RareFile.net account plugin""" - __license = "GPLv3" - __authors = [("zoidberg", "zoidberg@mujmail.cz")] - - - HOSTER_DOMAIN = "rarefile.net" diff --git a/pyload/plugins/account/RealdebridCom.py b/pyload/plugins/account/RealdebridCom.py deleted file mode 100644 index c181a1343..000000000 --- a/pyload/plugins/account/RealdebridCom.py +++ /dev/null @@ -1,36 +0,0 @@ -# -*- coding: utf-8 -*- - -import xml.dom.minidom as dom - -from pyload.plugins.Account import Account - - -class RealdebridCom(Account): - __name = "RealdebridCom" - __type = "account" - __version = "0.43" - - __description = """Real-Debrid.com account plugin""" - __license = "GPLv3" - __authors = [("Devirex Hazzard", "naibaf_11@yahoo.de")] - - - def loadAccountInfo(self, user, req): - if self.pin_code: - return {"premium": False} - page = req.load("https://real-debrid.com/api/account.php") - xml = dom.parseString(page) - account_info = {"validuntil": int(xml.getElementsByTagName("expiration")[0].childNodes[0].nodeValue), - "trafficleft": -1} - - return account_info - - - def login(self, user, data, req): - self.pin_code = False - page = req.load("https://real-debrid.com/ajax/login.php", get={"user": user, "pass": data['password']}) - if "Your login informations are incorrect" in page: - self.wrongPassword() - elif "PIN Code required" in page: - self.logWarning(_("PIN code required. Please login to https://real-debrid.com using the PIN or disable the double authentication in your control panel on https://real-debrid.com")) - self.pin_code = True diff --git a/pyload/plugins/account/RehostTo.py b/pyload/plugins/account/RehostTo.py deleted file mode 100644 index 1a7ea9577..000000000 --- a/pyload/plugins/account/RehostTo.py +++ /dev/null @@ -1,41 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.Account import Account - - -class RehostTo(Account): - __name = "RehostTo" - __type = "account" - __version = "0.10" - - __description = """Rehost.to account plugin""" - __license = "GPLv3" - __authors = [("RaNaN", "RaNaN@pyload.org")] - - - def loadAccountInfo(self, user, req): - data = self.getAccountData(user) - page = req.load("http://rehost.to/api.php", - get={'cmd': "login", 'user': user, 'pass': data['password']}) - data = [x.split("=") for x in page.split(",")] - ses = data[0][1] - long_ses = data[1][1] - - page = req.load("http://rehost.to/api.php", - get={'cmd': "get_premium_credits", 'long_ses': long_ses}) - traffic, valid = page.split(",") - - account_info = {"trafficleft": int(traffic) * 1024, - "validuntil": int(valid), - "long_ses": long_ses, - "ses": ses} - - return account_info - - - def login(self, user, data, req): - page = req.load("http://rehost.to/api.php", - get={'cmd': "login", 'user': user, 'pass': data['password']}) - - if "Login failed." in page: - self.wrongPassword() diff --git a/pyload/plugins/account/RyushareCom.py b/pyload/plugins/account/RyushareCom.py deleted file mode 100644 index a555e6208..000000000 --- a/pyload/plugins/account/RyushareCom.py +++ /dev/null @@ -1,25 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.internal.XFSAccount import XFSAccount - - -class RyushareCom(XFSAccount): - __name = "RyushareCom" - __type = "account" - __version = "0.05" - - __description = """Ryushare.com account plugin""" - __license = "GPLv3" - __authors = [("zoidberg", "zoidberg@mujmail.cz"), - ("trance4us", "")] - - - HOSTER_DOMAIN = "ryushare.com" - - - def login(self, user, data, req): - req.lastURL = "http://ryushare.com/login.python" - html = req.load("http://ryushare.com/login.python", - post={"login": user, "password": data['password'], "op": "login"}) - if 'Incorrect Login or Password' in html or '>Error<' in html: - self.wrongPassword() diff --git a/pyload/plugins/account/SafesharingEu.py b/pyload/plugins/account/SafesharingEu.py deleted file mode 100644 index a48ce86b3..000000000 --- a/pyload/plugins/account/SafesharingEu.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.internal.XFSAccount import XFSAccount - - -class SafesharingEu(XFSAccount): - __name = "SafesharingEu" - __type = "account" - __version = "0.02" - - __description = """Safesharing.eu account plugin""" - __license = "GPLv3" - __authors = [("guidobelix", "guidobelix@hotmail.it")] - - - HOSTER_DOMAIN = "safesharing.eu" diff --git a/pyload/plugins/account/SecureUploadEu.py b/pyload/plugins/account/SecureUploadEu.py deleted file mode 100644 index 38c7f9646..000000000 --- a/pyload/plugins/account/SecureUploadEu.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.internal.XFSAccount import XFSAccount - - -class SecureUploadEu(XFSAccount): - __name = "SecureUploadEu" - __type = "account" - __version = "0.02" - - __description = """SecureUpload.eu account plugin""" - __license = "GPLv3" - __authors = [("Walter Purcaro", "vuolter@gmail.com")] - - - HOSTER_DOMAIN = "secureupload.eu" diff --git a/pyload/plugins/account/SendmywayCom.py b/pyload/plugins/account/SendmywayCom.py deleted file mode 100644 index fefbcba4b..000000000 --- a/pyload/plugins/account/SendmywayCom.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.internal.XFSAccount import XFSAccount - - -class SendmywayCom(XFSAccount): - __name = "SendmywayCom" - __type = "account" - __version = "0.02" - - __description = """Sendmyway.com account plugin""" - __license = "GPLv3" - __authors = [("Walter Purcaro", "vuolter@gmail.com")] - - - HOSTER_DOMAIN = "sendmyway.com" diff --git a/pyload/plugins/account/ShareonlineBiz.py b/pyload/plugins/account/ShareonlineBiz.py deleted file mode 100644 index 1cf6fd3c8..000000000 --- a/pyload/plugins/account/ShareonlineBiz.py +++ /dev/null @@ -1,45 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.Account import Account - - -class ShareonlineBiz(Account): - __name = "ShareonlineBiz" - __type = "account" - __version = "0.24" - - __description = """Share-online.biz account plugin""" - __license = "GPLv3" - __authors = [("mkaay", "mkaay@mkaay.de"), - ("zoidberg", "zoidberg@mujmail.cz")] - - - def getUserAPI(self, user, req): - return req.load("http://api.share-online.biz/account.php", - {"username": user, "password": self.accounts[user]['password'], "act": "userDetails"}) - - - def loadAccountInfo(self, user, req): - html = self.getUserAPI(user, req) - - info = {} - for line in html.splitlines(): - if "=" in line: - key, value = line.split("=") - info[key] = value - self.logDebug(info) - - if "dl" in info and info['dl'].lower() != "not_available": - req.cj.setCookie("share-online.biz", "dl", info['dl']) - if "a" in info and info['a'].lower() != "not_available": - req.cj.setCookie("share-online.biz", "a", info['a']) - - return {"validuntil": int(info['expire_date']) if "expire_date" in info else -1, - "trafficleft": -1, - "premium": True if ("dl" in info or "a" in info) and (info['group'] != "Sammler") else False} - - - def login(self, user, data, req): - html = self.getUserAPI(user, req) - if "EXCEPTION" in html: - self.wrongPassword() diff --git a/pyload/plugins/account/SimplyPremiumCom.py b/pyload/plugins/account/SimplyPremiumCom.py deleted file mode 100644 index 2fabe6ce8..000000000 --- a/pyload/plugins/account/SimplyPremiumCom.py +++ /dev/null @@ -1,46 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.utils import json_loads -from pyload.plugins.Account import Account - - -class SimplyPremiumCom(Account): - __name = "SimplyPremiumCom" - __type = "account" - __version = "0.01" - - __description = """Simply-Premium.com account plugin""" - __license = "GPLv3" - __authors = [("EvolutionClip", "evolutionclip@live.de")] - - - def loadAccountInfo(self, user, req): - json_data = req.load('http://www.simply-premium.com/api/user.php?format=json') - self.logDebug("JSON data: " + json_data) - json_data = json_loads(json_data) - - if 'vip' in json_data['result'] and json_data['result']['vip'] == 0: - return {"premium": False} - - #Time package - validuntil = float(json_data['result']['timeend']) - #Traffic package - # {"trafficleft": int(traffic), "validuntil": -1} - #trafficleft = int(json_data['result']['traffic']) - - #return {"premium": True, "validuntil": validuntil, "trafficleft": trafficleft} - return {"premium": True, "validuntil": validuntil} - - - def login(self, user, data, req): - req.cj.setCookie("simply-premium.com", "lang", "EN") - - if data['password'] == '' or data['password'] == '0': - post_data = {"key": user} - else: - post_data = {"login_name": user, "login_pass": data['password']} - - html = req.load("http://www.simply-premium.com/login.php", post=post_data) - - if 'logout' not in html: - self.wrongPassword() diff --git a/pyload/plugins/account/SimplydebridCom.py b/pyload/plugins/account/SimplydebridCom.py deleted file mode 100644 index 4930eaea5..000000000 --- a/pyload/plugins/account/SimplydebridCom.py +++ /dev/null @@ -1,34 +0,0 @@ -# -*- coding: utf-8 -*- - -from time import mktime, strptime - -from pyload.plugins.Account import Account - - -class SimplydebridCom(Account): - __name = "SimplydebridCom" - __type = "account" - __version = "0.10" - - __description = """Simply-Debrid.com account plugin""" - __license = "GPLv3" - __authors = [("Kagenoshin", "kagenoshin@gmx.ch")] - - - def loadAccountInfo(self, user, req): - get_data = {'login': 2, 'u': self.loginname, 'p': self.password} - res = req.load("http://simply-debrid.com/api.php", get=get_data, decode=True) - data = [x.strip() for x in res.split(";")] - if str(data[0]) != "1": - return {"premium": False} - else: - return {"trafficleft": -1, "validuntil": mktime(strptime(str(data[2]), "%d/%m/%Y"))} - - - def login(self, user, data, req): - self.loginname = user - self.password = data['password'] - get_data = {'login': 1, 'u': self.loginname, 'p': self.password} - res = req.load("http://simply-debrid.com/api.php", get=get_data, decode=True) - if res != "02: loggin success": - self.wrongPassword() diff --git a/pyload/plugins/account/StahnuTo.py b/pyload/plugins/account/StahnuTo.py deleted file mode 100644 index d2358191a..000000000 --- a/pyload/plugins/account/StahnuTo.py +++ /dev/null @@ -1,34 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from pyload.plugins.Account import Account - - -class StahnuTo(Account): - __name = "StahnuTo" - __type = "account" - __version = "0.03" - - __description = """StahnuTo account plugin""" - __license = "GPLv3" - __authors = [("zoidberg", "zoidberg@mujmail.cz")] - - - def loadAccountInfo(self, user, req): - html = req.load("http://www.stahnu.to/") - - m = re.search(r'>VIP: (\d+.*)<', html) - trafficleft = self.parseTraffic(m.group(1)) * 1024 if m else 0 - - return {"premium": trafficleft > (512 * 1024), "trafficleft": trafficleft, "validuntil": -1} - - - def login(self, user, data, req): - html = req.load("http://www.stahnu.to/login.php", post={ - "username": user, - "password": data['password'], - "submit": "Login"}) - - if not '<a href="logout.php">' in html: - self.wrongPassword() diff --git a/pyload/plugins/account/StreamcloudEu.py b/pyload/plugins/account/StreamcloudEu.py deleted file mode 100644 index 49768bc6f..000000000 --- a/pyload/plugins/account/StreamcloudEu.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.internal.XFSAccount import XFSAccount - - -class StreamcloudEu(XFSAccount): - __name = "StreamcloudEu" - __type = "account" - __version = "0.02" - - __description = """Streamcloud.eu account plugin""" - __license = "GPLv3" - __authors = [("Walter Purcaro", "vuolter@gmail.com")] - - - HOSTER_DOMAIN = "streamcloud.eu" diff --git a/pyload/plugins/account/TurbobitNet.py b/pyload/plugins/account/TurbobitNet.py deleted file mode 100644 index b60c89a61..000000000 --- a/pyload/plugins/account/TurbobitNet.py +++ /dev/null @@ -1,42 +0,0 @@ -# -*- coding: utf-8 -*- - -import re -from time import mktime, strptime - -from pyload.plugins.Account import Account - - -class TurbobitNet(Account): - __name = "TurbobitNet" - __type = "account" - __version = "0.01" - - __description = """TurbobitNet account plugin""" - __license = "GPLv3" - __authors = [("zoidberg", "zoidberg@mujmail.cz")] - - - def loadAccountInfo(self, user, req): - html = req.load("http://turbobit.net") - - m = re.search(r'<u>Turbo Access</u> to ([\d.]+)', html) - if m: - premium = True - validuntil = mktime(strptime(m.group(1), "%d.%m.%Y")) - else: - premium = False - validuntil = -1 - - return {"premium": premium, "trafficleft": -1, "validuntil": validuntil} - - - def login(self, user, data, req): - req.cj.setCookie("turbobit.net", "user_lang", "en") - - html = req.load("http://turbobit.net/user/login", post={ - "user[login]": user, - "user[pass]": data['password'], - "user[submit]": "Login"}) - - if not '<div class="menu-item user-name">' in html: - self.wrongPassword() diff --git a/pyload/plugins/account/TusfilesNet.py b/pyload/plugins/account/TusfilesNet.py deleted file mode 100644 index c665c608e..000000000 --- a/pyload/plugins/account/TusfilesNet.py +++ /dev/null @@ -1,23 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from time import mktime, strptime, gmtime - -from pyload.plugins.internal.XFSAccount import XFSAccount - - -class TusfilesNet(XFSAccount): - __name = "TusfilesNet" - __type = "account" - __version = "0.06" - - __description = """Tusfile.net account plugin""" - __license = "GPLv3" - __authors = [("guidobelix", "guidobelix@hotmail.it")] - - - HOSTER_DOMAIN = "tusfiles.net" - - VALID_UNTIL_PATTERN = r'<span class="label label-default">([^<]+)</span>' - TRAFFIC_LEFT_PATTERN = r'<td><img src="//www\.tusfiles\.net/i/icon/meter\.png" alt=""/></td>\n<td> (?P<S>[\d.,]+)' diff --git a/pyload/plugins/account/UlozTo.py b/pyload/plugins/account/UlozTo.py deleted file mode 100644 index d7087a7c2..000000000 --- a/pyload/plugins/account/UlozTo.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from urlparse import urljoin - -from pyload.plugins.Account import Account - - -class UlozTo(Account): - __name = "UlozTo" - __type = "account" - __version = "0.07" - - __description = """Uloz.to account plugin""" - __license = "GPLv3" - __authors = [("zoidberg", "zoidberg@mujmail.cz"), - ("pulpe", "")] - - - TRAFFIC_LEFT_PATTERN = r'<li class="menu-kredit"><a href="/kredit" title="[^"]*?GB = ([\d.]+) MB"' - - - def loadAccountInfo(self, user, req): - self.phpsessid = req.cj.getCookie("ULOSESSID") #@NOTE: this cookie gets lost somehow after each request - - html = req.load("http://www.ulozto.net/", decode=True) - - req.cj.setCookie("ulozto.net", "ULOSESSID", self.phpsessid) - - m = re.search(self.TRAFFIC_LEFT_PATTERN, html) - trafficleft = int(float(m.group(1).replace(' ', '').replace(',', '.')) * 1000 * 1.048) if m else 0 - self.premium = True if trafficleft else False - - return {"validuntil": -1, "trafficleft": trafficleft} - - - def login(self, user, data, req): - login_page = req.load('http://www.ulozto.net/?do=web-login', decode=True) - action = re.findall('<form action="(.+?)"', login_page)[1].replace('&', '&') - token = re.search('_token_" value="(.+?)"', login_page).group(1) - - html = req.load(urljoin("http://www.ulozto.net/", action), - post={'_token_' : token, - 'do' : "loginForm-submit", - 'login' : u"Přihlásit", - 'password': data['password'], - 'username': user}, - decode=True) - - if '<div class="flash error">' in html: - self.wrongPassword() diff --git a/pyload/plugins/account/UnrestrictLi.py b/pyload/plugins/account/UnrestrictLi.py deleted file mode 100644 index 8ecfc50eb..000000000 --- a/pyload/plugins/account/UnrestrictLi.py +++ /dev/null @@ -1,44 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.Account import Account -from pyload.utils import json_loads - - -class UnrestrictLi(Account): - __name = "UnrestrictLi" - __type = "account" - __version = "0.03" - - __description = """Unrestrict.li account plugin""" - __license = "GPLv3" - __authors = [("stickell", "l.stickell@yahoo.it")] - - - def loadAccountInfo(self, user, req): - json_data = req.load('http://unrestrict.li/api/jdownloader/user.php?format=json') - self.logDebug("JSON data: " + json_data) - json_data = json_loads(json_data) - - if 'vip' in json_data['result'] and json_data['result']['vip'] == 0: - return {"premium": False} - - validuntil = json_data['result']['expires'] - trafficleft = int(json_data['result']['traffic']) - - return {"premium": True, "validuntil": validuntil, "trafficleft": trafficleft} - - - def login(self, user, data, req): - req.cj.setCookie("unrestrict.li", "lang", "EN") - html = req.load("https://unrestrict.li/sign_in") - - if 'solvemedia' in html: - self.logError(_("A Captcha is required. Go to http://unrestrict.li/sign_in and login, then retry")) - return - - post_data = {"username": user, "password": data['password'], - "remember_me": "remember", "signin": "Sign in"} - html = req.load("https://unrestrict.li/sign_in", post=post_data) - - if 'sign_out' not in html: - self.wrongPassword() diff --git a/pyload/plugins/account/UploadcCom.py b/pyload/plugins/account/UploadcCom.py deleted file mode 100644 index df3d89a13..000000000 --- a/pyload/plugins/account/UploadcCom.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.internal.XFSAccount import XFSAccount - - -class UploadcCom(XFSAccount): - __name = "UploadcCom" - __type = "account" - __version = "0.02" - - __description = """Uploadc.com account plugin""" - __license = "GPLv3" - __authors = [("Walter Purcaro", "vuolter@gmail.com")] - - - HOSTER_DOMAIN = "uploadc.com" diff --git a/pyload/plugins/account/UploadedTo.py b/pyload/plugins/account/UploadedTo.py deleted file mode 100644 index 2db549802..000000000 --- a/pyload/plugins/account/UploadedTo.py +++ /dev/null @@ -1,60 +0,0 @@ -# -*- coding: utf-8 -*- - -import re -from time import time - -from pyload.plugins.Account import Account - - -class UploadedTo(Account): - __name = "UploadedTo" - __type = "account" - __version = "0.27" - - __description = """Uploaded.to account plugin""" - __license = "GPLv3" - __authors = [("mkaay", "mkaay@mkaay.de")] - - - PREMIUM_PATTERN = r'<em>Premium</em>' - VALID_UNTIL_PATTERN = r'<td>Duration:</td>\s*<th>([^<]+)' - TRAFFIC_LEFT_PATTERN = r'<th colspan="2"><b class="cB">([^<]+)' - - - def loadAccountInfo(self, user, req): - validuntil = None - trafficleft = None - premium = None - - html = req.load("http://uploaded.net/me") - - premium = True if re.search(self.PREMIUM_PATTERN, html) else False - - m = re.search(self.VALID_UNTIL_PATTERN, html, re.M) - if m: - expiredate = m.group(1).strip() - - if expiredate == "unlimited": - validuntil = -1 - else: - m = re.findall(r'(\d+) (Week|weeks|day|hour)', expiredate) - if m: - validuntil = time() - for n, u in m: - validuntil += int(n) * 60 * 60 * {'Week': 168, 'weeks': 168, 'day': 24, 'hour': 1}[u] - - m = re.search(self.TRAFFIC_LEFT_PATTERN, html) - if m: - trafficleft = self.parseTraffic(m.group(1).replace('.', '')) - - return {'validuntil': validuntil, 'trafficleft': trafficleft, 'premium': premium} - - - def login(self, user, data, req): - req.cj.setCookie("uploaded.net", "lang", "en") - - page = req.load("http://uploaded.net/io/login", - post={'id': user, 'pw': data['password'], '_': ""}) - - if "User and password do not match" in page: - self.wrongPassword() diff --git a/pyload/plugins/account/UploadheroCom.py b/pyload/plugins/account/UploadheroCom.py deleted file mode 100644 index 5fce73ff1..000000000 --- a/pyload/plugins/account/UploadheroCom.py +++ /dev/null @@ -1,41 +0,0 @@ -# -*- coding: utf-8 -*- - -import re -import datetime -import time - -from pyload.plugins.Account import Account - - -class UploadheroCom(Account): - __name = "UploadheroCom" - __type = "account" - __version = "0.20" - - __description = """Uploadhero.co account plugin""" - __license = "GPLv3" - __authors = [("mcmyst", "mcmyst@hotmail.fr")] - - - def loadAccountInfo(self, user, req): - premium_pattern = re.compile('Il vous reste <span class="bleu">(\d+)</span> jours premium') - - data = self.getAccountData(user) - page = req.load("http://uploadhero.co/my-account") - - if premium_pattern.search(page): - end_date = datetime.date.today() + datetime.timedelta(days=int(premium_pattern.search(page).group(1))) - end_date = time.mktime(future.timetuple()) - account_info = {"validuntil": end_date, "trafficleft": -1, "premium": True} - else: - account_info = {"validuntil": -1, "trafficleft": -1, "premium": False} - - return account_info - - - def login(self, user, data, req): - page = req.load("http://uploadhero.co/lib/connexion.php", - post={"pseudo_login": user, "password_login": data['password']}) - - if "mot de passe invalide" in page: - self.wrongPassword() diff --git a/pyload/plugins/account/UploadingCom.py b/pyload/plugins/account/UploadingCom.py deleted file mode 100644 index b7eecd6b6..000000000 --- a/pyload/plugins/account/UploadingCom.py +++ /dev/null @@ -1,63 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from time import time, strptime, mktime - -from pyload.plugins.Account import Account -from pyload.plugins.internal.SimpleHoster import set_cookies - - -class UploadingCom(Account): - __name = "UploadingCom" - __type = "account" - __version = "0.11" - - __description = """Uploading.com account plugin""" - __license = "GPLv3" - __authors = [("mkaay", "mkaay@mkaay.de")] - - - PREMIUM_PATTERN = r'UPGRADE TO PREMIUM' - VALID_UNTIL_PATTERN = r'Valid Until:(.+?)<' - - - def loadAccountInfo(self, user, req): - validuntil = None - trafficleft = None - premium = None - - html = req.load("http://uploading.com/") - - premium = False if re.search(self.PREMIUM_PATTERN, html) else True - - m = re.search(self.VALID_UNTIL_PATTERN, html) - if m: - expiredate = m.group(1).strip() - self.logDebug("Expire date: " + expiredate) - - try: - validuntil = mktime(strptime(expiredate, "%b %d, %Y")) - - except Exception, e: - self.logError(e) - - else: - if validuntil > mktime(gmtime()): - premium = True - else: - premium = False - validuntil = None - - return {'validuntil': validuntil, 'trafficleft': trafficleft, 'premium': premium} - - - def login(self, user, data, req): - set_cookies([("uploading.com", "lang", "1"), - ("uploading.com", "language", "1"), - ("uploading.com", "setlang", "en"), - ("uploading.com", "_lang", "en")] - - req.load("http://uploading.com/") - req.load("http://uploading.com/general/login_form/?JsHttpRequest=%s-xml" % long(time() * 1000), - post={'email': user, 'password': data['password'], 'remember': "on"}) diff --git a/pyload/plugins/account/UptoboxCom.py b/pyload/plugins/account/UptoboxCom.py deleted file mode 100644 index 869ddf214..000000000 --- a/pyload/plugins/account/UptoboxCom.py +++ /dev/null @@ -1,17 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.internal.XFSAccount import XFSAccount - - -class UptoboxCom(XFSAccount): - __name = "UptoboxCom" - __type = "account" - __version = "0.07" - - __description = """DDLStorage.com account plugin""" - __license = "GPLv3" - __authors = [("zoidberg", "zoidberg@mujmail.cz")] - - - HOSTER_DOMAIN = "uptobox.com" - HOSTER_URL = "https://uptobox.com/" diff --git a/pyload/plugins/account/VidPlayNet.py b/pyload/plugins/account/VidPlayNet.py deleted file mode 100644 index f3c7f0d4a..000000000 --- a/pyload/plugins/account/VidPlayNet.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.internal.XFSAccount import XFSAccount - - -class VidPlayNet(XFSAccount): - __name = "VidPlayNet" - __type = "account" - __version = "0.02" - - __description = """VidPlay.net account plugin""" - __license = "GPLv3" - __authors = [("Walter Purcaro", "vuolter@gmail.com")] - - - HOSTER_DOMAIN = "vidplay.net" diff --git a/pyload/plugins/account/XFileSharingPro.py b/pyload/plugins/account/XFileSharingPro.py deleted file mode 100644 index 834fb9735..000000000 --- a/pyload/plugins/account/XFileSharingPro.py +++ /dev/null @@ -1,30 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.internal.XFSAccount import XFSAccount - - -class XFileSharingPro(XFSAccount): - __name = "XFileSharingPro" - __type = "account" - __version = "0.05" - - __description = """XFileSharingPro multi-purpose account plugin""" - __license = "GPLv3" - __authors = [("Walter Purcaro", "vuolter@gmail.com")] - - - HOSTER_DOMAIN = None - - - def init(self): - if self.HOSTER_DOMAIN: - return super(XFileSharingPro, self).init() - - - def loadAccountInfo(self, user, req): - return super(XFileSharingPro if self.HOSTER_DOMAIN else XFSAccount, self).loadAccountInfo(user, req) - - - def login(self, user, data, req): - if self.HOSTER_DOMAIN: - return super(XFileSharingPro, self).login(user, data, req) diff --git a/pyload/plugins/account/YibaishiwuCom.py b/pyload/plugins/account/YibaishiwuCom.py deleted file mode 100644 index fd9382f0d..000000000 --- a/pyload/plugins/account/YibaishiwuCom.py +++ /dev/null @@ -1,40 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from pyload.plugins.Account import Account - - -class YibaishiwuCom(Account): - __name = "YibaishiwuCom" - __type = "account" - __version = "0.01" - - __description = """115.com account plugin""" - __license = "GPLv3" - __authors = [("zoidberg", "zoidberg@mujmail.cz")] - - - ACCOUNT_INFO_PATTERN = r'var USER_PERMISSION = {(.*?)}' - - - def loadAccountInfo(self, user, req): - #self.relogin(user) - html = req.load("http://115.com/", decode=True) - - m = re.search(self.ACCOUNT_INFO_PATTERN, html, re.S) - premium = True if (m and 'is_vip: 1' in m.group(1)) else False - validuntil = trafficleft = (-1 if m else 0) - return dict({"validuntil": validuntil, "trafficleft": trafficleft, "premium": premium}) - - - def login(self, user, data, req): - html = req.load('http://passport.115.com/?ac=login', post={ - "back": "http://www.115.com/", - "goto": "http://115.com/", - "login[account]": user, - "login[passwd]": data['password'] - }, decode=True) - - if not 'var USER_PERMISSION = {' in html: - self.wrongPassword() diff --git a/pyload/plugins/account/ZeveraCom.py b/pyload/plugins/account/ZeveraCom.py deleted file mode 100644 index f748bef17..000000000 --- a/pyload/plugins/account/ZeveraCom.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- - -from time import mktime, strptime - -from pyload.plugins.Account import Account - - -class ZeveraCom(Account): - __name = "ZeveraCom" - __type = "account" - __version = "0.21" - - __description = """Zevera.com account plugin""" - __license = "GPLv3" - __authors = [("zoidberg", "zoidberg@mujmail.cz")] - - - def loadAccountInfo(self, user, req): - data = self.getAPIData(req) - if data == "No traffic": - account_info = {"trafficleft": 0, "validuntil": 0, "premium": False} - else: - account_info = { - "trafficleft": int(data['availabletodaytraffic']) * 1024, - "validuntil": mktime(strptime(data['endsubscriptiondate'], "%Y/%m/%d %H:%M:%S")), - "premium": True - } - return account_info - - - def login(self, user, data, req): - self.loginname = user - self.password = data['password'] - if self.getAPIData(req) == "No traffic": - self.wrongPassword() - - - def getAPIData(self, req, just_header=False, **kwargs): - get_data = { - 'cmd': 'accountinfo', - 'login': self.loginname, - 'pass': self.password - } - get_data.update(kwargs) - - res = req.load("http://www.zevera.com/jDownloader.ashx", get=get_data, - decode=True, just_header=just_header) - self.logDebug(res) - - if ':' in res: - if not just_header: - res = res.replace(',', '\n') - return dict((y.strip().lower(), z.strip()) for (y, z) in - [x.split(':', 1) for x in res.splitlines() if ':' in x]) - else: - return res diff --git a/pyload/plugins/account/__init__.py b/pyload/plugins/account/__init__.py deleted file mode 100644 index 40a96afc6..000000000 --- a/pyload/plugins/account/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# -*- coding: utf-8 -*- diff --git a/pyload/plugins/addon/Checksum.py b/pyload/plugins/addon/Checksum.py deleted file mode 100644 index 1b9941f4b..000000000 --- a/pyload/plugins/addon/Checksum.py +++ /dev/null @@ -1,186 +0,0 @@ -# -*- coding: utf-8 -*- - -from __future__ import with_statement - -import hashlib -import re -import zlib - -from os import remove -from os.path import getsize, isfile, splitext - -from pyload.plugins.Addon import Addon -from pyload.utils import safe_join, fs_encode - - -def computeChecksum(local_file, algorithm): - if algorithm in getattr(hashlib, "algorithms", ("md5", "sha1", "sha224", "sha256", "sha384", "sha512")): - h = getattr(hashlib, algorithm)() - - with open(local_file, 'rb') as f: - for chunk in iter(lambda: f.read(128 * h.block_size), ''): - h.update(chunk) - - return h.hexdigest() - - elif algorithm in ("adler32", "crc32"): - hf = getattr(zlib, algorithm) - last = 0 - - with open(local_file, 'rb') as f: - for chunk in iter(lambda: f.read(8192), ''): - last = hf(chunk, last) - - return "%x" % last - - else: - return None - - -class Checksum(Addon): - __name = "Checksum" - __type = "addon" - __version = "0.15" - - __config = [("activated" , "bool" , "Activated" , True ), - ("check_checksum", "bool" , "Check checksum? (If False only size will be verified)", True ), - ("check_action" , "fail;retry;nothing", "What to do if check fails?" , "retry"), - ("max_tries" , "int" , "Number of retries" , 2 ), - ("retry_action" , "fail;nothing" , "What to do if all retries fail?" , "fail" ), - ("wait_time" , "int" , "Time to wait before each retry (seconds)" , 1 )] - - __description = """Verify downloaded file size and checksum""" - __license = "GPLv3" - __authors = [("zoidberg", "zoidberg@mujmail.cz"), - ("Walter Purcaro", "vuolter@gmail.com"), - ("stickell", "l.stickell@yahoo.it")] - - - methods = {'sfv': 'crc32', 'crc': 'crc32', 'hash': 'md5'} - regexps = {'sfv': r'^(?P<name>[^;].+)\s+(?P<hash>[0-9A-Fa-f]{8})$', - 'md5': r'^(?P<name>[0-9A-Fa-f]{32}) (?P<file>.+)$', - 'crc': r'filename=(?P<name>.+)\nsize=(?P<size>\d+)\ncrc32=(?P<hash>[0-9A-Fa-f]{8})$', - 'default': r'^(?P<hash>[0-9A-Fa-f]+)\s+\*?(?P<name>.+)$'} - - - def activate(self): - if not self.getConfig("check_checksum"): - self.logInfo(_("Checksum validation is disabled in plugin configuration")) - - - def setup(self): - self.algorithms = sorted( - getattr(hashlib, "algorithms", ("md5", "sha1", "sha224", "sha256", "sha384", "sha512")), reverse=True) - self.algorithms.extend(["crc32", "adler32"]) - self.formats = self.algorithms + ["sfv", "crc", "hash"] - - - def downloadFinished(self, pyfile): - """ - Compute checksum for the downloaded file and compare it with the hash provided by the hoster. - pyfile.plugin.check_data should be a dictionary which can contain: - a) if known, the exact filesize in bytes (e.g. "size": 123456789) - b) hexadecimal hash string with algorithm name as key (e.g. "md5": "d76505d0869f9f928a17d42d66326307") - """ - if hasattr(pyfile.plugin, "check_data") and isinstance(pyfile.plugin.check_data, dict): - data = pyfile.plugin.check_data.copy() - - elif hasattr(pyfile.plugin, "api_data") and isinstance(pyfile.plugin.api_data, dict): - data = pyfile.plugin.api_data.copy() - - # elif hasattr(pyfile.plugin, "info") and isinstance(pyfile.plugin.info, dict): - # data = pyfile.plugin.info.copy() - - else: - return - - self.logDebug(data) - - if not pyfile.plugin.lastDownload: - self.checkFailed(pyfile, None, "No file downloaded") - - local_file = fs_encode(pyfile.plugin.lastDownload) - #download_folder = self.config['general']['download_folder'] - #local_file = fs_encode(safe_join(download_folder, pyfile.package().folder, pyfile.name)) - - if not isfile(local_file): - self.checkFailed(pyfile, None, "File does not exist") - - # validate file size - if "size" in data: - api_size = int(data['size']) - file_size = getsize(local_file) - if api_size != file_size: - self.logWarning(_("File %s has incorrect size: %d B (%d expected)") % (pyfile.name, file_size, api_size)) - self.checkFailed(pyfile, local_file, "Incorrect file size") - del data['size'] - - # validate checksum - if data and self.getConfig("check_checksum"): - if "checksum" in data: - data['md5'] = data['checksum'] - - for key in self.algorithms: - if key in data: - checksum = computeChecksum(local_file, key.replace("-", "").lower()) - if checksum: - if checksum == data[key].lower(): - self.logInfo(_('File integrity of "%s" verified by %s checksum (%s)') % - (pyfile.name, key.upper(), checksum)) - break - else: - self.logWarning(_("%s checksum for file %s does not match (%s != %s)") % - (key.upper(), pyfile.name, checksum, data[key])) - self.checkFailed(pyfile, local_file, "Checksums do not match") - else: - self.logWarning(_("Unsupported hashing algorithm"), key.upper()) - else: - self.logWarning(_("Unable to validate checksum for file: ") + pyfile.name) - - - def checkFailed(self, pyfile, local_file, msg): - check_action = self.getConfig("check_action") - if check_action == "retry": - max_tries = self.getConfig("max_tries") - retry_action = self.getConfig("retry_action") - if pyfile.plugin.retries < max_tries: - if local_file: - remove(local_file) - pyfile.plugin.retry(max_tries, self.getConfig("wait_time"), msg) - elif retry_action == "nothing": - return - elif check_action == "nothing": - return - pyfile.plugin.fail(reason=msg) - - - def packageFinished(self, pypack): - download_folder = safe_join(self.config['general']['download_folder'], pypack.folder, "") - - for link in pypack.getChildren().itervalues(): - file_type = splitext(link['name'])[1][1:].lower() - - if file_type not in self.formats: - continue - - hash_file = fs_encode(safe_join(download_folder, link['name'])) - if not isfile(hash_file): - self.logWarning(_("File not found"), link['name']) - continue - - with open(hash_file) as f: - text = f.read() - - for m in re.finditer(self.regexps.get(file_type, self.regexps['default']), text): - data = m.groupdict() - self.logDebug(link['name'], data) - - local_file = fs_encode(safe_join(download_folder, data['name'])) - algorithm = self.methods.get(file_type, file_type) - checksum = computeChecksum(local_file, algorithm) - if checksum == data['hash']: - self.logInfo(_('File integrity of "%s" verified by %s checksum (%s)') % - (data['name'], algorithm, checksum)) - else: - self.logWarning(_("%s checksum for file %s does not match (%s != %s)") % - (algorithm, data['name'], checksum, data['hash'])) diff --git a/pyload/plugins/addon/ClickAndLoad.py b/pyload/plugins/addon/ClickAndLoad.py deleted file mode 100644 index 490837f65..000000000 --- a/pyload/plugins/addon/ClickAndLoad.py +++ /dev/null @@ -1,74 +0,0 @@ -# -*- coding: utf-8 -*- - -from socket import socket, error -from threading import Thread - -from pyload.plugins.Addon import Addon - - -def forward(source, destination): - string = ' ' - while string: - string = source.recv(1024) - if string: - destination.sendall(string) - else: - #source.shutdown(socket.SHUT_RD) - destination.shutdown(socket.SHUT_WR) - - -class ClickAndLoad(Addon): - __name = "ClickAndLoad" - __type = "addon" - __version = "0.23" - - __config = [("activated", "bool", "Activated" , True ), - ("port" , "int" , "Port" , 9666 ), - ("extern" , "bool", "Allow external link adding", False)] - - __description = """Click'N'Load hook plugin""" - __license = "GPLv3" - __authors = [("RaNaN", "RaNaN@pyload.de"), - ("mkaay", "mkaay@mkaay.de"), - ("Walter Purcaro", "vuolter@gmail.com")] - - - def setup(self): - self.interval = 300 - - - def activate(self): - self.initPeriodical() - - - def periodical(self): - webip = "0.0.0.0" if self.getConfig("extern") else "127.0.0.1" - webport = self.config['webinterface']['port'] - cnlport = self.getConfig("port")) - - try: - s = socket() - s.bind((webip, cnlport)) - s.listen(5) - - client = s.accept()[0] - server = socket() - - server.connect(("127.0.0.1", webport)) - - except error, e: - if hasattr(e, "errno"): - errno = e.errno - else: - errno = e.args[0] - - if errno == 98: - self.logWarning(_("Port %d already in use") % cnlport) - else: - self.logDebug(e) - - else: - self.core.scheduler.removeJob(self.cb) - t = Thread(target=forward, args=[client, server]) - t.setDaemon(True) - t.start() diff --git a/pyload/plugins/addon/DeleteFinished.py b/pyload/plugins/addon/DeleteFinished.py deleted file mode 100644 index 5450a8ee2..000000000 --- a/pyload/plugins/addon/DeleteFinished.py +++ /dev/null @@ -1,79 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.database import style -from pyload.plugins.Addon import Addon - - -class DeleteFinished(Addon): - __name = "DeleteFinished" - __type = "addon" - __version = "1.11" - - __config = [('interval' , 'int' , 'Delete every (hours)' , '72' ), - ('deloffline', 'bool', 'Delete packages with offline links', 'False')] - - __description = """Automatically delete all finished packages from queue""" - __license = "GPLv3" - __authors = [("Walter Purcaro", "vuolter@gmail.com")] - - - # event_list = ["pluginConfigChanged"] - - - ## overwritten methods ## - def periodical(self): - if not self.info['sleep']: - deloffline = self.getConfig('deloffline') - mode = '0,1,4' if deloffline else '0,4' - msg = _('delete all finished packages in queue list (%s packages with offline links)') - self.logInfo(msg % (_('including') if deloffline else _('excluding'))) - self.deleteFinished(mode) - self.info['sleep'] = True - self.addEvent('packageFinished', self.wakeup) - - - def pluginConfigChanged(self, plugin, name, value): - if name == "interval" and value != self.interval: - self.interval = value * 3600 - self.initPeriodical() - - - def deactivate(self): - self.removeEvent('packageFinished', self.wakeup) - - - def activate(self): - self.info = {'sleep': True} - interval = self.getConfig('interval') - self.pluginConfigChanged(self.__name, 'interval', interval) - self.addEvent('packageFinished', self.wakeup) - - - ## own methods ## - @style.queue - def deleteFinished(self, mode): - self.c.execute('DELETE FROM packages WHERE NOT EXISTS(SELECT 1 FROM links WHERE package=packages.id AND status NOT IN (%s))' % mode) - self.c.execute('DELETE FROM links WHERE NOT EXISTS(SELECT 1 FROM packages WHERE id=links.package)') - - - def wakeup(self, pypack): - self.removeEvent('packageFinished', self.wakeup) - self.info['sleep'] = False - - - ## event managing ## - def addEvent(self, event, func): - """Adds an event listener for event name""" - if event in self.m.events: - if func in self.m.events[event]: - self.logDebug("Function already registered", func) - else: - self.m.events[event].append(func) - else: - self.m.events[event] = [func] - - - def setup(self): - self.interval = 0 - self.m = self.manager - self.removeEvent = self.m.removeEvent diff --git a/pyload/plugins/addon/DownloadScheduler.py b/pyload/plugins/addon/DownloadScheduler.py deleted file mode 100644 index 95cede509..000000000 --- a/pyload/plugins/addon/DownloadScheduler.py +++ /dev/null @@ -1,77 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from time import localtime - -from pyload.plugins.Addon import Addon - - -class DownloadScheduler(Addon): - __name = "DownloadScheduler" - __type = "addon" - __version = "0.22" - - __config = [("timetable", "str" , "List time periods as hh:mm full or number(kB/s)" , "0:00 full, 7:00 250, 10:00 0, 17:00 150"), - ("abort" , "bool", "Abort active downloads when start period with speed 0", False )] - - __description = """Download Scheduler""" - __license = "GPLv3" - __authors = [("zoidberg", "zoidberg@mujmail.cz"), - ("stickell", "l.stickell@yahoo.it")] - - - def setup(self): - self.cb = None #: callback to scheduler job; will be by removed AddonManager when addon unloaded - - - def activate(self): - self.updateSchedule() - - - def updateSchedule(self, schedule=None): - if schedule is None: - schedule = self.getConfig("timetable") - - schedule = re.findall("(\d{1,2}):(\d{2})[\s]*(-?\d+)", - schedule.lower().replace("full", "-1").replace("none", "0")) - if not schedule: - self.logError(_("Invalid schedule")) - return - - t0 = localtime() - now = (t0.tm_hour, t0.tm_min, t0.tm_sec, "X") - schedule = sorted([(int(x[0]), int(x[1]), 0, int(x[2])) for x in schedule] + [now]) - - self.logDebug("Schedule", schedule) - - for i, v in enumerate(schedule): - if v[3] == "X": - last, next = schedule[i - 1], schedule[(i + 1) % len(schedule)] - self.logDebug("Now/Last/Next", now, last, next) - - self.setDownloadSpeed(last[3]) - - next_time = (((24 + next[0] - now[0]) * 60 + next[1] - now[1]) * 60 + next[2] - now[2]) % 86400 - self.core.scheduler.removeJob(self.cb) - self.cb = self.core.scheduler.addJob(next_time, self.updateSchedule, threaded=False) - - - def setDownloadSpeed(self, speed): - if speed == 0: - abort = self.getConfig("abort") - self.logInfo(_("Stopping download server. (Running downloads will %sbe aborted.)") % '' if abort else _('not ')) - self.core.api.pauseServer() - if abort: - self.core.api.stopAllDownloads() - else: - self.core.api.unpauseServer() - - if speed > 0: - self.logInfo(_("Setting download speed to %d kB/s") % speed) - self.core.api.setConfigValue("download", "limit_speed", 1) - self.core.api.setConfigValue("download", "max_speed", speed) - else: - self.logInfo(_("Setting download speed to FULL")) - self.core.api.setConfigValue("download", "limit_speed", 0) - self.core.api.setConfigValue("download", "max_speed", -1) diff --git a/pyload/plugins/addon/ExternalScripts.py b/pyload/plugins/addon/ExternalScripts.py deleted file mode 100644 index a2d7b8d86..000000000 --- a/pyload/plugins/addon/ExternalScripts.py +++ /dev/null @@ -1,145 +0,0 @@ -# -*- coding: utf-8 -*- - -import subprocess - -from itertools import chain -from os import listdir, access, X_OK, makedirs -from os.path import join, exists, basename, abspath - -from pyload.plugins.Addon import Addon -from pyload.utils import safe_join - - -class ExternalScripts(Addon): - __name = "ExternalScripts" - __type = "addon" - __version = "0.25" - - __config = [("activated", "bool", "Activated", True)] - - __description = """Run external scripts""" - __license = "GPLv3" - __authors = [("mkaay", "mkaay@mkaay.de"), - ("RaNaN", "ranan@pyload.org"), - ("spoob", "spoob@pyload.org"), - ("Walter Purcaro", "vuolter@gmail.com")] - - - event_map = {'archive-extracted' : "archive_extracted", - 'package-extracted' : "package_extracted", - 'all_archives-extracted' : "all_archives_extracted", - 'all_archives-processed' : "all_archives_processed", - 'all_downloads-finished' : "allDownloadsFinished", - 'all_downloads-processed': "allDownloadsProcessed"} - - - def setup(self): - self.scripts = {} - - folders = ["download_preparing", "download_finished", "all_downloads_finished", "all_downloads_processed", - "before_reconnect", "after_reconnect", - "package_finished", "package_extracted", - "archive_extracted", "all_archives_extracted", "all_archives_processed", - # deprecated folders - "unrar_finished", "all_dls_finished", "all_dls_processed"] - - for folder in folders: - self.scripts[folder] = [] - - self.initPluginType(folder, join(pypath, 'scripts', folder)) - self.initPluginType(folder, join('scripts', folder)) - - for script_type, names in self.scripts.iteritems(): - if names: - self.logInfo(_("Installed scripts for"), script_type, ", ".join([basename(x) for x in names])) - - - def initPluginType(self, folder, path): - if not exists(path): - try: - makedirs(path) - except Exception: - self.logDebug("Script folder %s not created" % folder) - return - - for f in listdir(path): - if f.startswith("#") or f.startswith(".") or f.startswith("_") or f.endswith("~") or f.endswith(".swp"): - continue - - if not access(join(path, f), X_OK): - self.logWarning(_("Script not executable:") + " %s/%s" % (folder, f)) - - self.scripts[folder].append(join(path, f)) - - - def callScript(self, script, *args): - try: - cmd = [script] + [str(x) if not isinstance(x, basestring) else x for x in args] - self.logDebug("Executing", abspath(script), " ".join(cmd)) - #output goes to pyload - subprocess.Popen(cmd, bufsize=-1) - except Exception, e: - self.logError(_("Error in %(script)s: %(error)s") % {"script": basename(script), "error": e}) - - - def downloadPreparing(self, pyfile): - for script in self.scripts['download_preparing']: - self.callScript(script, pyfile.pluginname, pyfile.url, pyfile.id) - - - def downloadFinished(self, pyfile): - download_folder = self.config['general']['download_folder'] - for script in self.scripts['download_finished']: - filename = safe_join(download_folder, pyfile.package().folder, pyfile.name) - self.callScript(script, pyfile.pluginname, pyfile.url, pyfile.name, filename, pyfile.id) - - - def packageFinished(self, pypack): - download_folder = self.config['general']['download_folder'] - for script in self.scripts['package_finished']: - folder = safe_join(download_folder, pypack.folder) - self.callScript(script, pypack.name, folder, pypack.password, pypack.id) - - - def beforeReconnecting(self, ip): - for script in self.scripts['before_reconnect']: - self.callScript(script, ip) - - - def afterReconnecting(self, ip): - for script in self.scripts['after_reconnect']: - self.callScript(script, ip) - - - def archive_extracted(self, pyfile, folder, filename, files): - for script in self.scripts['archive_extracted']: - self.callScript(script, folder, filename, files) - for script in self.scripts['unrar_finished']: #: deprecated - self.callScript(script, folder, filename) - - - def package_extracted(self, pypack): - download_folder = self.config['general']['download_folder'] - for script in self.scripts['package_extracted']: - folder = safe_join(download_folder, pypack.folder) - self.callScript(script, pypack.name, folder, pypack.password, pypack.id) - - - def all_archives_extracted(self): - for script in self.scripts['all_archives_extracted']: - self.callScript(script) - - - def all_archives_processed(self): - for script in self.scripts['all_archives_processed']: - self.callScript(script) - - - def allDownloadsFinished(self): - for script in chain(self.scripts['all_downloads_finished'], self.scripts['all_dls_finished']): - self.callScript(script) - - - def allDownloadsProcessed(self): - for script in chain(self.scripts['all_downloads_processed'], self.scripts['all_dls_processed']): - self.callScript(script) diff --git a/pyload/plugins/addon/ExtractArchive.py b/pyload/plugins/addon/ExtractArchive.py deleted file mode 100644 index 25da7ba12..000000000 --- a/pyload/plugins/addon/ExtractArchive.py +++ /dev/null @@ -1,363 +0,0 @@ -# -*- coding: utf-8 -*- - -from __future__ import with_statement - -import os -import sys - -from copy import copy -from os import remove, chmod, makedirs -from os.path import exists, basename, isfile, isdir -from traceback import print_exc - -# monkey patch bug in python 2.6 and lower -# http://bugs.python.org/issue6122 , http://bugs.python.org/issue1236 , http://bugs.python.org/issue1731717 -if sys.version_info < (2, 7) and os.name != "nt": - import errno - from subprocess import Popen - - - def _eintr_retry_call(func, *args): - while True: - try: - return func(*args) - except OSError, e: - if e.errno == errno.EINTR: - continue - raise - - - # unsued timeout option for older python version - def wait(self, timeout=0): - """Wait for child process to terminate. Returns returncode - attribute.""" - if self.returncode is None: - try: - pid, sts = _eintr_retry_call(os.waitpid, self.pid, 0) - except OSError, e: - if e.errno != errno.ECHILD: - raise - # This happens if SIGCLD is set to be ignored or waiting - # for child processes has otherwise been disabled for our - # process. This child is dead, we can't get the status. - sts = 0 - self._handle_exitstatus(sts) - return self.returncode - - Popen.wait = wait - -if os.name != "nt": - from grp import getgrnam - from os import chown - from pwd import getpwnam - -from pyload.plugins.Addon import Addon, threaded, Expose -from pyload.plugins.internal.AbstractExtractor import ArchiveError, CRCError, WrongPassword -from pyload.utils import safe_join, fs_encode - - -class ExtractArchive(Addon): - __name = "ExtractArchive" - __type = "addon" - __version = "0.19" - - __config = [("activated" , "bool" , "Activated" , True ), - ("fullpath" , "bool" , "Extract full path" , True ), - ("overwrite" , "bool" , "Overwrite files" , True ), - ("passwordfile" , "file" , "password file" , "archive_password.txt"), - ("deletearchive", "bool" , "Delete archives when done" , False ), - ("subfolder" , "bool" , "Create subfolder for each package" , False ), - ("destination" , "folder", "Extract files to" , "" ), - ("excludefiles" , "str" , "Exclude files from unpacking (seperated by ;)", "" ), - ("recursive" , "bool" , "Extract archives in archvies" , True ), - ("queue" , "bool" , "Wait for all downloads to be finished" , True ), - ("renice" , "int" , "CPU Priority" , 0 )] - - __description = """Extract different kind of archives""" - __license = "GPLv3" - __authors = [("RaNaN", "ranan@pyload.org"), - ("AndroKev", ""), - ("Walter Purcaro", "vuolter@gmail.com")] - - - event_map = {'all_downloads-processed': "allDownloadsProcessed"} - - - def setup(self): - self.plugins = [] - self.passwords = [] - names = [] - - for p in ("UnRar", "UnZip"): - try: - module = self.core.pluginManager.loadModule("internal", p) - klass = getattr(module, p) - if klass.checkDeps(): - names.append(p) - self.plugins.append(klass) - - except OSError, e: - if e.errno == 2: - self.logInfo(_("No %s installed") % p) - else: - self.logWarning(_("Could not activate %s") % p, e) - if self.core.debug: - print_exc() - - except Exception, e: - self.logWarning(_("Could not activate %s") % p, e) - if self.core.debug: - print_exc() - - if names: - self.logInfo(_("Activated") + " " + " ".join(names)) - else: - self.logInfo(_("No Extract plugins activated")) - - # queue with package ids - self.queue = [] - - - @Expose - def extractPackage(self, id): - """ Extract package with given id""" - self.manager.startThread(self.extract, [id]) - - - def packageFinished(self, pypack): - pid = pypack.id - if self.getConfig("queue"): - self.logInfo(_("Package %s queued for later extracting") % pypack.name) - self.queue.append(pid) - else: - self.manager.startThread(self.extract, [pid]) - - - @threaded - def allDownloadsProcessed(self, thread): - local = copy(self.queue) - del self.queue[:] - if self.extract(local, thread): #: check only if all gone fine, no failed reporting for now - self.manager.dispatchEvent("all_archives-extracted") - self.manager.dispatchEvent("all_archives-processed") - - - def extract(self, ids, thread=None): - processed = [] - extracted = [] - failed = [] - - destination = self.getConfig("destination") - subfolder = self.getConfig("subfolder") - fullpath = self.getConfig("fullpath") - overwrite = self.getConfig("overwrite") - excludefiles = self.getConfig("excludefiles") - renice = self.getConfig("renice") - recursive = self.getConfig("recursive") - - # reload from txt file - self.reloadPasswords() - - # dl folder - dl = self.config['general']['download_folder'] - - #iterate packages -> plugins -> targets - for pid in ids: - p = self.core.files.getPackage(pid) - self.logInfo(_("Check package %s") % p.name) - if not p: - continue - - # determine output folder - out = safe_join(dl, p.folder, "") - - out = safe_join(dl, p.folder, self.getConfig("destination"), "") - if subfolder: - out = safe_join(out, fs_encode(p.folder)) - - if not exists(out): - makedirs(out) - - files_ids = [(safe_join(dl, p.folder, x['name']), x['id']) for x in p.getChildren().itervalues()] - matched = False - success = True - - # check as long there are unseen files - while files_ids: - new_files_ids = [] - - for plugin in self.plugins: - targets = plugin.getTargets(files_ids) - if targets: - self.logDebug("Targets for %s: %s" % (plugin.__name, targets)) - matched = True - for target, fid in targets: - if target in processed: - self.logDebug(basename(target), "skipped") - continue - - processed.append(target) # prevent extracting same file twice - - self.logInfo(basename(target), _("Extract to %s") % out) - try: - klass = plugin(self, target, out, fullpath, overwrite, excludefiles, renice) - klass.init() - password = p.password.strip().splitlines() - new_files = self._extract(klass, fid, password, thread) - except Exception, e: - self.logError(basename(target), e) - success = False - continue - - self.logDebug("Extracted", new_files) - self.setPermissions(new_files) - - for file in new_files: - if not exists(file): - self.logDebug("New file %s does not exists" % file) - continue - if recursive and isfile(file): - new_files_ids.append((file, fid)) # append as new target - - files_ids = new_files_ids # also check extracted files - - if matched: - if success: - extracted.append(pid) - self.manager.dispatchEvent("package-extracted", p) - else: - failed.append(pid) - self.manager.dispatchEvent("package-extract_failed", p) - else: - self.logInfo(_("No files found to extract")) - - return True if not failed else False - - - def _extract(self, plugin, fid, passwords, thread): - pyfile = self.core.files.getFile(fid) - deletearchive = self.getConfig("deletearchive") - - pyfile.setCustomStatus(_("extracting")) - thread.addActive(pyfile) # keep this file until everything is done - - try: - progress = lambda x: pyfile.setProgress(x) - success = False - - if not plugin.checkArchive(): - plugin.extract(progress) - success = True - else: - self.logInfo(basename(plugin.file), _("Password protected")) - self.logDebug("Passwords", passwords) - - pwlist = copy(self.getPasswords()) - # remove already supplied pws from list (only local) - for pw in passwords: - if pw in pwlist: - pwlist.remove(pw) - - for pw in passwords + pwlist: - try: - self.logDebug("Try password", pw) - if plugin.checkPassword(pw): - plugin.extract(progress, pw) - self.addPassword(pw) - success = True - break - except WrongPassword: - self.logDebug("Password was wrong") - - if not success: - raise Exception(_("Wrong password")) - - if self.core.debug: - self.logDebug("Would delete", ", ".join(plugin.getDeleteFiles())) - - if deletearchive: - files = plugin.getDeleteFiles() - self.logInfo(_("Deleting %s files") % len(files)) - for f in files: - if exists(f): - remove(f) - else: - self.logDebug("%s does not exists" % f) - - self.logInfo(basename(plugin.file), _("Extracting finished")) - - extracted_files = plugin.getExtractedFiles() - self.manager.dispatchEvent("archive-extracted", pyfile, plugin.out, plugin.file, extracted_files) - - return extracted_files - - except ArchiveError, e: - self.logError(basename(plugin.file), _("Archive Error"), e) - except CRCError: - self.logError(basename(plugin.file), _("CRC Mismatch")) - except Exception, e: - if self.core.debug: - print_exc() - self.logError(basename(plugin.file), _("Unknown Error"), e) - - self.manager.dispatchEvent("archive-extract_failed", pyfile) - raise Exception(_("Extract failed")) - - - @Expose - def getPasswords(self): - """ List of saved passwords """ - return self.passwords - - - def reloadPasswords(self): - passwordfile = self.getConfig("passwordfile") - - try: - passwords = [] - with open(passwordfile, "a+") as f: - for pw in f.read().splitlines(): - passwords.append(pw) - - except IOError, e: - self.logError(e) - - else: - self.passwords = passwords - - - @Expose - def addPassword(self, pw): - """ Adds a password to saved list""" - passwordfile = self.getConfig("passwordfile") - - if pw in self.passwords: - self.passwords.remove(pw) - - self.passwords.insert(0, pw) - - try: - with open(passwordfile, "wb") as f: - for pw in self.passwords: - f.write(pw + "\n") - except IOError, e: - self.logError(e) - - - def setPermissions(self, files): - for f in files: - if not exists(f): - continue - try: - if self.config['permission']['change_file']: - if isfile(f): - chmod(f, int(self.config['permission']['file'], 8)) - elif isdir(f): - chmod(f, int(self.config['permission']['folder'], 8)) - - if self.config['permission']['change_dl'] and os.name != "nt": - uid = getpwnam(self.config['permission']['user'])[2] - gid = getgrnam(self.config['permission']['group'])[2] - chown(f, uid, gid) - except Exception, e: - self.logWarning(_("Setting User and Group failed"), e) diff --git a/pyload/plugins/addon/HotFolder.py b/pyload/plugins/addon/HotFolder.py deleted file mode 100644 index 297a06c5a..000000000 --- a/pyload/plugins/addon/HotFolder.py +++ /dev/null @@ -1,70 +0,0 @@ -# -*- coding: utf-8 -*- - -from __future__ import with_statement - -import time - -from os import listdir, makedirs -from os.path import exists, isfile, join -from shutil import move - -from pyload.plugins.Addon import Addon -from pyload.utils import fs_encode, safe_join - - -class HotFolder(Addon): - __name = "HotFolder" - __type = "addon" - __version = "0.12" - - __config = [("folder" , "str" , "Folder to observe" , "container"), - ("watch_file", "bool", "Observe link file" , False ), - ("keep" , "bool", "Keep added containers", True ), - ("file" , "str" , "Link file" , "links.txt")] - - __description = """Observe folder and file for changes and add container and links""" - __license = "GPLv3" - __authors = [("RaNaN", "RaNaN@pyload.de")] - - - def setup(self): - self.interval = 10 - - - def activate(self): - self.initPeriodical() - - - def periodical(self): - folder = fs_encode(self.getConfig("folder")) - - try: - if not exists(join(folder, "finished")): - makedirs(join(folder, "finished")) - - if self.getConfig("watch_file"): - with open(fs_encode(self.getConfig("file")), "a+") as f: - content = f.read().strip() - - if content: - name = "%s_%s.txt" % (self.getConfig("file"), time.strftime("%H-%M-%S_%d%b%Y")) - - with open(safe_join(folder, "finished", name), "wb") as f: - f.write(content) - - self.core.api.addPackage(f.name, [f.name], 1) - - for f in listdir(folder): - path = join(folder, f) - - if not isfile(path) or f.endswith("~") or f.startswith("#") or f.startswith("."): - continue - - newpath = join(folder, "finished", f if self.getConfig("keep") else "tmp_" + f) - move(path, newpath) - - self.logInfo(_("Added %s from HotFolder") % f) - self.core.api.addPackage(f, [newpath], 1) - - except IOError, e: - self.logError(e) diff --git a/pyload/plugins/addon/IRCInterface.py b/pyload/plugins/addon/IRCInterface.py deleted file mode 100644 index e7a905bf7..000000000 --- a/pyload/plugins/addon/IRCInterface.py +++ /dev/null @@ -1,431 +0,0 @@ -# -*- coding: utf-8 -*- - -import re -import socket -import ssl -import time - -from pycurl import FORM_FILE -from select import select -from threading import Thread -from time import sleep -from traceback import print_exc - -from pyload.api import PackageDoesNotExists, FileDoesNotExists -from pyload.network.RequestFactory import getURL -from pyload.plugins.Addon import Addon -from pyload.utils import formatSize - - -class IRCInterface(Thread, Addon): - __name = "IRCInterface" - __type = "addon" - __version = "0.13" - - __config = [("host" , "str" , "IRC-Server Address" , "Enter your server here!"), - ("port" , "int" , "IRC-Server Port" , 6667 ), - ("ident" , "str" , "Clients ident" , "pyload-irc" ), - ("realname" , "str" , "Realname" , "pyload-irc" ), - ("ssl" , "bool", "Use SSL" , False ), - ("nick" , "str" , "Nickname the Client will take" , "pyLoad-IRC" ), - ("owner" , "str" , "Nickname the Client will accept commands from", "Enter your nick here!" ), - ("info_file", "bool", "Inform about every file finished" , False ), - ("info_pack", "bool", "Inform about every package finished" , True ), - ("captcha" , "bool", "Send captcha requests" , True )] - - __description = """Connect to irc and let owner perform different tasks""" - __license = "GPLv3" - __authors = [("Jeix", "Jeix@hasnomail.com")] - - - def __init__(self, core, manager): - Thread.__init__(self) - Addon.__init__(self, core, manager) - self.setDaemon(True) - - - def activate(self): - self.abort = False - self.more = [] - self.new_package = {} - - self.start() - - - def packageFinished(self, pypack): - try: - if self.getConfig("info_pack"): - self.response(_("Package finished: %s") % pypack.name) - except Exception: - pass - - - def downloadFinished(self, pyfile): - try: - if self.getConfig("info_file"): - self.response( - _("Download finished: %(name)s @ %(plugin)s ") % {"name": pyfile.name, "plugin": pyfile.pluginname}) - except Exception: - pass - - - def captchaTask(self, task): - if self.getConfig("captcha") and task.isTextual(): - task.handler.append(self) - task.setWaiting(60) - - page = getURL("http://www.freeimagehosting.net/upload.php", - post={"attached": (FORM_FILE, task.captchaFile)}, multipart=True) - - url = re.search(r"\[img\]([^\[]+)\[/img\]\[/url\]", page).group(1) - self.response(_("New Captcha Request: %s") % url) - self.response(_("Answer with 'c %s text on the captcha'") % task.id) - - - def run(self): - # connect to IRC etc. - self.sock = socket.socket() - host = self.getConfig("host") - self.sock.connect((host, self.getConfig("port"))) - - if self.getConfig("ssl"): - self.sock = ssl.wrap_socket(self.sock, cert_reqs=ssl.CERT_NONE) #@TODO: support custom certificate - - nick = self.getConfig("nick") - self.sock.send("NICK %s\r\n" % nick) - self.sock.send("USER %s %s bla :%s\r\n" % (nick, host, nick)) - for t in self.getConfig("owner").split(): - if t.strip().startswith("#"): - self.sock.send("JOIN %s\r\n" % t.strip()) - self.logInfo(_("Connected to"), host) - self.logInfo(_("Switching to listening mode!")) - try: - self.main_loop() - - except IRCError, ex: - self.sock.send("QUIT :byebye\r\n") - print_exc() - self.sock.close() - - - def main_loop(self): - readbuffer = "" - while True: - sleep(1) - fdset = select([self.sock], [], [], 0) - if self.sock not in fdset[0]: - continue - - if self.abort: - raise IRCError("quit") - - readbuffer += self.sock.recv(1024) - temp = readbuffer.split("\n") - readbuffer = temp.pop() - - for line in temp: - line = line.rstrip() - first = line.split() - - if first[0] == "PING": - self.sock.send("PONG %s\r\n" % first[1]) - - if first[0] == "ERROR": - raise IRCError(line) - - msg = line.split(None, 3) - if len(msg) < 4: - continue - - msg = { - "origin": msg[0][1:], - "action": msg[1], - "target": msg[2], - "text": msg[3][1:] - } - - self.handle_events(msg) - - - def handle_events(self, msg): - if not msg['origin'].split("!", 1)[0] in self.getConfig("owner").split(): - return - - if msg['target'].split("!", 1)[0] != self.getConfig("nick"): - return - - if msg['action'] != "PRIVMSG": - return - - # HANDLE CTCP ANTI FLOOD/BOT PROTECTION - if msg['text'] == "\x01VERSION\x01": - self.logDebug("Sending CTCP VERSION") - self.sock.send("NOTICE %s :%s\r\n" % (msg['origin'], "pyLoad! IRC Interface")) - return - elif msg['text'] == "\x01TIME\x01": - self.logDebug("Sending CTCP TIME") - self.sock.send("NOTICE %s :%d\r\n" % (msg['origin'], time.time())) - return - elif msg['text'] == "\x01LAG\x01": - self.logDebug("Received CTCP LAG") #: don't know how to answer - return - - trigger = "pass" - args = None - - try: - temp = msg['text'].split() - trigger = temp[0] - if len(temp) > 1: - args = temp[1:] - except Exception: - pass - - handler = getattr(self, "event_%s" % trigger, self.event_pass) - try: - res = handler(args) - for line in res: - self.response(line, msg['origin']) - except Exception, e: - self.logError(e) - - - def response(self, msg, origin=""): - if origin == "": - for t in self.getConfig("owner").split(): - self.sock.send("PRIVMSG %s :%s\r\n" % (t.strip(), msg)) - else: - self.sock.send("PRIVMSG %s :%s\r\n" % (origin.split("!", 1)[0], msg)) - - - #### Events - - def event_pass(self, args): - return [] - - - def event_status(self, args): - downloads = self.core.api.statusDownloads() - if not downloads: - return ["INFO: There are no active downloads currently."] - - temp_progress = "" - lines = ["ID - Name - Status - Speed - ETA - Progress"] - for data in downloads: - - if data.status == 5: - temp_progress = data.format_wait - else: - temp_progress = "%d%% (%s)" % (data.percent, data.format_size) - - lines.append("#%d - %s - %s - %s - %s - %s" % - ( - data.fid, - data.name, - data.statusmsg, - "%s/s" % formatSize(data.speed), - "%s" % data.format_eta, - temp_progress - )) - return lines - - - def event_queue(self, args): - ps = self.core.api.getQueueData() - - if not ps: - return ["INFO: There are no packages in queue."] - - lines = [] - for pack in ps: - lines.append('PACKAGE #%s: "%s" with %d links.' % (pack.pid, pack.name, len(pack.links))) - - return lines - - - def event_collector(self, args): - ps = self.core.api.getCollectorData() - if not ps: - return ["INFO: No packages in collector!"] - - lines = [] - for pack in ps: - lines.append('PACKAGE #%s: "%s" with %d links.' % (pack.pid, pack.name, len(pack.links))) - - return lines - - - def event_info(self, args): - if not args: - return ["ERROR: Use info like this: info <id>"] - - info = None - try: - info = self.core.api.getFileData(int(args[0])) - - except FileDoesNotExists: - return ["ERROR: Link doesn't exists."] - - return ['LINK #%s: %s (%s) [%s][%s]' % (info.fid, info.name, info.format_size, info.statusmsg, info.plugin)] - - - def event_packinfo(self, args): - if not args: - return ["ERROR: Use packinfo like this: packinfo <id>"] - - lines = [] - pack = None - try: - pack = self.core.api.getPackageData(int(args[0])) - - except PackageDoesNotExists: - return ["ERROR: Package doesn't exists."] - - id = args[0] - - self.more = [] - - lines.append('PACKAGE #%s: "%s" with %d links' % (id, pack.name, len(pack.links))) - for pyfile in pack.links: - self.more.append('LINK #%s: %s (%s) [%s][%s]' % (pyfile.fid, pyfile.name, pyfile.format_size, - pyfile.statusmsg, pyfile.plugin)) - - if len(self.more) < 6: - lines.extend(self.more) - self.more = [] - else: - lines.extend(self.more[:6]) - self.more = self.more[6:] - lines.append("%d more links do display." % len(self.more)) - - return lines - - - def event_more(self, args): - if not self.more: - return ["No more information to display."] - - lines = self.more[:6] - self.more = self.more[6:] - lines.append("%d more links do display." % len(self.more)) - - return lines - - - def event_start(self, args): - self.core.api.unpauseServer() - return ["INFO: Starting downloads."] - - - def event_stop(self, args): - self.core.api.pauseServer() - return ["INFO: No new downloads will be started."] - - - def event_add(self, args): - if len(args) < 2: - return ['ERROR: Add links like this: "add <packagename|id> links". ', - "This will add the link <link> to to the package <package> / the package with id <id>!"] - - pack = args[0].strip() - links = [x.strip() for x in args[1:]] - - count_added = 0 - count_failed = 0 - try: - id = int(pack) - pack = self.core.api.getPackageData(id) - if not pack: - return ["ERROR: Package doesn't exists."] - - #TODO add links - - return ["INFO: Added %d links to Package %s [#%d]" % (len(links), pack['name'], id)] - - except Exception: - # create new package - id = self.core.api.addPackage(pack, links, 1) - return ["INFO: Created new Package %s [#%d] with %d links." % (pack, id, len(links))] - - - def event_del(self, args): - if len(args) < 2: - return ["ERROR: Use del command like this: del -p|-l <id> [...] (-p indicates that the ids are from packages, -l indicates that the ids are from links)"] - - if args[0] == "-p": - ret = self.core.api.deletePackages(map(int, args[1:])) - return ["INFO: Deleted %d packages!" % len(args[1:])] - - elif args[0] == "-l": - ret = self.core.api.delLinks(map(int, args[1:])) - return ["INFO: Deleted %d links!" % len(args[1:])] - - else: - return ["ERROR: Use del command like this: del <-p|-l> <id> [...] (-p indicates that the ids are from packages, -l indicates that the ids are from links)"] - - - def event_push(self, args): - if not args: - return ["ERROR: Push package to queue like this: push <package id>"] - - id = int(args[0]) - try: - info = self.core.api.getPackageInfo(id) - except PackageDoesNotExists: - return ["ERROR: Package #%d does not exist." % id] - - self.core.api.pushToQueue(id) - return ["INFO: Pushed package #%d to queue." % id] - - - def event_pull(self, args): - if not args: - return ["ERROR: Pull package from queue like this: pull <package id>."] - - id = int(args[0]) - if not self.core.api.getPackageData(id): - return ["ERROR: Package #%d does not exist." % id] - - self.core.api.pullFromQueue(id) - return ["INFO: Pulled package #%d from queue to collector." % id] - - - def event_c(self, args): - """ captcha answer """ - if not args: - return ["ERROR: Captcha ID missing."] - - task = self.core.captchaManager.getTaskByID(args[0]) - if not task: - return ["ERROR: Captcha Task with ID %s does not exists." % args[0]] - - task.setResult(" ".join(args[1:])) - return ["INFO: Result %s saved." % " ".join(args[1:])] - - - def event_help(self, args): - lines = ["The following commands are available:", - "add <package|packid> <links> [...] Adds link to package. (creates new package if it does not exist)", - "queue Shows all packages in the queue", - "collector Shows all packages in collector", - "del -p|-l <id> [...] Deletes all packages|links with the ids specified", - "info <id> Shows info of the link with id <id>", - "packinfo <id> Shows info of the package with id <id>", - "more Shows more info when the result was truncated", - "start Starts all downloads", - "stop Stops the download (but not abort active downloads)", - "push <id> Push package to queue", - "pull <id> Pull package from queue", - "status Show general download status", - "help Shows this help message"] - return lines - - -class IRCError(Exception): - - def __init__(self, value): - self.value = value - - - def __str__(self): - return repr(self.value) diff --git a/pyload/plugins/addon/MergeFiles.py b/pyload/plugins/addon/MergeFiles.py deleted file mode 100644 index 71ad7a39d..000000000 --- a/pyload/plugins/addon/MergeFiles.py +++ /dev/null @@ -1,85 +0,0 @@ -# -*- coding: utf-8 -*- - -from __future__ import with_statement - -import os -import re - -from traceback import print_exc - -from pyload.plugins.Addon import Addon, threaded -from pyload.utils import safe_join, fs_encode - - -class MergeFiles(Addon): - __name = "MergeFiles" - __type = "addon" - __version = "0.13" - - __config = [("activated", "bool", "Activated", True)] - - __description = """Merges parts splitted with hjsplit""" - __license = "GPLv3" - __authors = [("and9000", "me@has-no-mail.com")] - - - BUFFER_SIZE = 4096 - - - def setup(self): - pass - - - @threaded - def packageFinished(self, pack): - files = {} - fid_dict = {} - for fid, data in pack.getChildren().iteritems(): - if re.search("\.\d{3}$", data['name']): - if data['name'][:-4] not in files: - files[data['name'][:-4]] = [] - files[data['name'][:-4]].append(data['name']) - files[data['name'][:-4]].sort() - fid_dict[data['name']] = fid - - download_folder = self.config['general']['download_folder'] - - if self.config['general']['folder_per_package']: - download_folder = safe_join(download_folder, pack.folder) - - for name, file_list in files.iteritems(): - self.logInfo(_("Starting merging of"), name) - - final_file = open(safe_join(download_folder, name), "wb") - for splitted_file in file_list: - self.logDebug("Merging part", splitted_file) - - pyfile = self.core.files.getFile(fid_dict[splitted_file]) - - pyfile.setStatus("processing") - - try: - with open(os.path.join(download_folder, splitted_file), "rb") as s_file: - size_written = 0 - s_file_size = int(os.path.getsize(os.path.join(download_folder, splitted_file))) - - while True: - f_buffer = s_file.read(self.BUFFER_SIZE) - if f_buffer: - final_file.write(f_buffer) - size_written += self.BUFFER_SIZE - pyfile.setProgress((size_written * 100) / s_file_size) - else: - break - - self.logDebug("Finished merging part", splitted_file) - - except Exception, e: - print_exc() - - finally: - pyfile.setProgress(100) - pyfile.setStatus("finished") - pyfile.release() - - self.logInfo(_("Finished merging of"), name) diff --git a/pyload/plugins/addon/MultiHome.py b/pyload/plugins/addon/MultiHome.py deleted file mode 100644 index f9c9e1cef..000000000 --- a/pyload/plugins/addon/MultiHome.py +++ /dev/null @@ -1,81 +0,0 @@ -# -*- coding: utf-8 -*- - -from time import time - -from pyload.plugins.Addon import Addon - - -class MultiHome(Addon): - __name = "MultiHome" - __type = "addon" - __version = "0.12" - - __config = [("interfaces", "str", "Interfaces", "None")] - - __description = """Ip address changer""" - __license = "GPLv3" - __authors = [("mkaay", "mkaay@mkaay.de")] - - - def setup(self): - self.register = {} - self.interfaces = [] - self.parseInterfaces(self.getConfig("interfaces").split(";")) - if not self.interfaces: - self.parseInterfaces([self.config['download']['interface']]) - self.setConfig("interfaces", self.toConfig()) - - - def toConfig(self): - return ";".join([i.adress for i in self.interfaces]) - - - def parseInterfaces(self, interfaces): - for interface in interfaces: - if not interface or str(interface).lower() == "none": - continue - self.interfaces.append(Interface(interface)) - - - def activate(self): - requestFactory = self.core.requestFactory - oldGetRequest = requestFactory.getRequest - - def getRequest(pluginName, account=None): - iface = self.bestInterface(pluginName, account) - if iface: - iface.useFor(pluginName, account) - requestFactory.iface = lambda: iface.adress - self.logDebug("Using address", iface.adress) - return oldGetRequest(pluginName, account) - - requestFactory.getRequest = getRequest - - - def bestInterface(self, pluginName, account): - best = None - for interface in self.interfaces: - if not best or interface.lastPluginAccess(pluginName, account) < best.lastPluginAccess(pluginName, account): - best = interface - return best - - -class Interface(object): - - def __init__(self, adress): - self.adress = adress - self.history = {} - - - def lastPluginAccess(self, pluginName, account): - if (pluginName, account) in self.history: - return self.history[(pluginName, account)] - return 0 - - - def useFor(self, pluginName, account): - self.history[(pluginName, account)] = time() - - - def __repr__(self): - return "<Interface - %s>" % self.adress diff --git a/pyload/plugins/addon/RestartFailed.py b/pyload/plugins/addon/RestartFailed.py deleted file mode 100644 index ffb305e71..000000000 --- a/pyload/plugins/addon/RestartFailed.py +++ /dev/null @@ -1,45 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.Addon import Addon - - -class RestartFailed(Addon): - __name = "RestartFailed" - __type = "addon" - __version = "1.57" - - __config = [("activated", "bool", "Activated" , True), - ("interval" , "int" , "Check interval in minutes", 90 )] - - __description = """Periodically restart all failed downloads in queue""" - __license = "GPLv3" - __authors = [("Walter Purcaro", "vuolter@gmail.com")] - - - # event_list = ["pluginConfigChanged"] - - MIN_INTERVAL = 15 * 60 #: 15m minimum check interval (value is in seconds) - - - def pluginConfigChanged(self, plugin, name, value): - if name == "interval": - interval = value * 60 - if self.MIN_INTERVAL <= interval != self.interval: - self.core.scheduler.removeJob(self.cb) - self.interval = interval - self.initPeriodical() - else: - self.logDebug("Invalid interval value, kept current") - - - def periodical(self): - self.logDebug(_("Restart failed downloads")) - self.core.api.restartFailed() - - - def setup(self): - self.interval = 0 - - - def activate(self): - self.pluginConfigChanged(self.__name, "interval", self.getConfig("interval")) diff --git a/pyload/plugins/addon/RestartSlow.py b/pyload/plugins/addon/RestartSlow.py deleted file mode 100644 index 61d842b7d..000000000 --- a/pyload/plugins/addon/RestartSlow.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: utf-8 -*- - -import pycurl - -from pyload.plugins.Addon import Addon - - -class RestartSlow(Addon): - __name = "RestartSlow" - __type = "addon" - __version = "0.02" - - __config = [("free_limit" , "int" , "Transfer speed threshold in kilobytes" , 100 ), - ("free_time" , "int" , "Sample interval in minutes" , 5 ), - ("premium_limit", "int" , "Transfer speed threshold for premium download in kilobytes", 300 ), - ("premium_time" , "int" , "Sample interval for premium download in minutes" , 2 ), - ("safe_mode" , "bool", "Don't restart if download is not resumable" , True)] - - __description = """Restart slow downloads""" - __license = "GPLv3" - __authors = [("Walter Purcaro", "vuolter@gmail.com")] - - - event_map = {'download-start': "downloadStarts"} - - - def setup(self): - self.info = {'chunk': {}} - - - def periodical(self): - if not self.pyfile.req.dl: - return - - if self.getConfig("safe_mode") and not self.pyfile.plugin.resumeDownload: - time = 30 - limit = 5 - else: - type = "premium" if self.pyfile.plugin.premium else "free" - time = max(30, self.getConfig("%s_time" % type) * 60) - limit = max(5, self.getConfig("%s_limit" % type) * 1024) - - chunks = [chunk for chunk in self.pyfile.req.dl.chunks \ - if chunk.id not in self.info['chunk'] or self.info['chunk'][chunk.id] not is (time, limit)] - - for chunk in chunks: - chunk.c.setopt(pycurl.LOW_SPEED_TIME , time) - chunk.c.setopt(pycurl.LOW_SPEED_LIMIT, limit) - - self.info['chunk'][chunk.id] = (time, limit) - - - def downloadStarts(self, pyfile, url, filename): - if self.cb or (self.getConfig("safe_mode") and not pyfile.plugin.resumeDownload): - return - - self.initPeriodical() diff --git a/pyload/plugins/addon/SkipRev.py b/pyload/plugins/addon/SkipRev.py deleted file mode 100644 index 90544959e..000000000 --- a/pyload/plugins/addon/SkipRev.py +++ /dev/null @@ -1,77 +0,0 @@ -# -*- coding: utf-8 -*- - -from urllib import unquote -from urlparse import urlparse - -from pyload.plugins.Addon import Addon -from pyload.plugins.Plugin import SkipDownload - - -class SkipRev(Adoon): - __name = "SkipRev" - __type = "addon" - __version = "0.15" - - __config = [("tokeep", "int", "Number of rev files to keep for package (-1 to auto)", -1)] - - __description = """Skip files ending with extension rev""" - __license = "GPLv3" - __authors = [("Walter Purcaro", "vuolter@gmail.com")] - - - def _setup(self): - super(self.pyfile.plugin, self).setup() - if self.pyfile.hasStatus("skipped"): - raise SkipDownload(self.pyfile.getStatusName() or self.pyfile.pluginname) - - - def pyname(self, pyfile): - url = pyfile.url - plugin = pyfile.plugin - - if hasattr(plugin, "info") and 'name' in plugin.info and plugin.info['name']: - name = plugin.info['name'] - - elif hasattr(plugin, "parseInfos"): - name = next(plugin.parseInfos([url]))['name'] - - elif hasattr(plugin, "getInfo"): #@NOTE: if parseInfos was not found, getInfo should be missing too - name = plugin.getInfo(url)['name'] - - else: - self.logWarning("Unable to grab file name") - name = urlparse(unquote(url)).path.split('/')[-1]) - - return name - - - def downloadPreparing(self, pyfile): - if pyfile.getStatusName() is "unskipped" or not pyname(pyfile).endswith(".rev"): - return - - tokeep = self.getConfig("tokeep") - - if tokeep: - saved = [True for link in pyfile.package().getChildren() \ - if link.name.endswith(".rev") and (link.hasStatus("finished") or link.hasStatus("downloading"))].count(True) - - if not saved or saved < tokeep: #: keep one rev at least in auto mode - return - - pyfile.setCustomStatus("SkipRev", "skipped") - pyfile.plugin.setup = _setup #: work-around: inject status checker inside the preprocessing routine of the plugin - - - def downloadFailed(self, pyfile): - tokeep = self.getConfig("tokeep") - - if not tokeep: - return - - for link in pyfile.package().getChildren(): - if link.hasStatus("skipped") and link.name.endswith(".rev"): - if tokeep > -1 or pyfile.name.endswith(".rev"): - link.setStatus("queued") - else: - link.setCustomStatus("unskipped", "queued") - return diff --git a/pyload/plugins/addon/UnSkipOnFail.py b/pyload/plugins/addon/UnSkipOnFail.py deleted file mode 100644 index 15c0dfa4a..000000000 --- a/pyload/plugins/addon/UnSkipOnFail.py +++ /dev/null @@ -1,87 +0,0 @@ -# -*- coding: utf-8 -*- - -from os.path import basename - -from pyload.datatype.PyFile import PyFile -from pyload.plugins.Addon import Addon -from pyload.utils import fs_encode - - -class UnSkipOnFail(Addon): - __name = "UnSkipOnFail" - __type = "addon" - __version = "0.02" - - __config = [("activated", "bool", "Activated", True)] - - __description = """When a download fails, restart skipped duplicates""" - __license = "GPLv3" - __authors = [("hagg", "")] - - - def downloadFailed(self, pyfile): - pyfile_name = basename(pyfile.name) - pid = pyfile.package().id - msg = _('look for skipped duplicates for %s (pid:%s)') - self.logInfo(msg % (pyfile_name, pid)) - dups = self.findDuplicates(pyfile) - for link in dups: - # check if link is "skipped"(=4) - if link.status == 4: - lpid = link.packageID - self.logInfo(_('restart "%s" (pid:%s)') % (pyfile_name, lpid)) - self.setLinkStatus(link, "queued") - - - def findDuplicates(self, pyfile): - """ Search all packages for duplicate links to "pyfile". - Duplicates are links that would overwrite "pyfile". - To test on duplicity the package-folder and link-name - of twolinks are compared (basename(link.name)). - So this method returns a list of all links with equal - package-folders and filenames as "pyfile", but except - the data for "pyfile" iotselöf. - It does MOT check the link's status. - """ - dups = [] - pyfile_name = fs_encode(basename(pyfile.name)) - # get packages (w/o files, as most file data is useless here) - queue = self.core.api.getQueue() - for package in queue: - # check if package-folder equals pyfile's package folder - if fs_encode(package.folder) == fs_encode(pyfile.package().folder): - # now get packaged data w/ files/links - pdata = self.core.api.getPackageData(package.pid) - if pdata.links: - for link in pdata.links: - link_name = fs_encode(basename(link.name)) - # check if link name collides with pdata's name - if link_name == pyfile_name: - # at last check if it is not pyfile itself - if link.fid != pyfile.id: - dups.append(link) - return dups - - - def setLinkStatus(self, link, new_status): - """ Change status of "link" to "new_status". - "link" has to be a valid FileData object, - "new_status" has to be a valid status name - (i.e. "queued" for this Plugin) - It creates a temporary PyFile object using - "link" data, changes its status, and tells - the core.files-manager to save its data. - """ - pyfile = PyFile(self.core.files, - link.fid, - link.url, - link.name, - link.size, - link.status, - link.error, - link.plugin, - link.packageID, - link.order) - pyfile.setStatus(new_status) - self.core.files.save() - pyfile.release() diff --git a/pyload/plugins/addon/UpdateManager.py b/pyload/plugins/addon/UpdateManager.py deleted file mode 100644 index 05197f15d..000000000 --- a/pyload/plugins/addon/UpdateManager.py +++ /dev/null @@ -1,305 +0,0 @@ -# -*- coding: utf-8 -*- - -from __future__ import with_statement - -import re -import sys - -from operator import itemgetter -from os import path, remove, stat - -from pyload.network.RequestFactory import getURL -from pyload.plugins.Addon import Expose, Addon, threaded -from pyload.utils import safe_join - - -class UpdateManager(Addon): - __name = "UpdateManager" - __type = "addon" - __version = "0.42" - - __config = [("activated" , "bool" , "Activated" , True ), - ("mode" , "pyLoad + plugins;plugins only", "Check updates for" , "pyLoad + plugins"), - ("interval" , "int" , "Check interval in hours" , 8 ), - ("autorestart" , "bool" , "Automatically restart pyLoad when required" , True ), - ("reloadplugins", "bool" , "Monitor plugins for code changes in debug mode", True ), - ("nodebugupdate", "bool" , "Don't check for updates in debug mode" , True )] - - __description = """Check for updates""" - __license = "GPLv3" - __authors = [("Walter Purcaro", "vuolter@gmail.com")] - - - # event_list = ["pluginConfigChanged"] - - SERVER_URL = "http://updatemanager.pyload.org" - VERSION = re.compile(r'__version.*=.*("|\')([\d.]+)') - MIN_INTERVAL = 3 * 60 * 60 #: 3h minimum check interval (value is in seconds) - - - def pluginConfigChanged(self, plugin, name, value): - if name == "interval": - interval = value * 60 * 60 - if self.MIN_INTERVAL <= interval != self.interval: - self.core.scheduler.removeJob(self.cb) - self.interval = interval - self.initPeriodical() - else: - self.logDebug("Invalid interval value, kept current") - - elif name == "reloadplugins": - if self.cb2: - self.core.scheduler.removeJob(self.cb2) - if value is True and self.core.debug: - self.periodical2() - - - def activate(self): - self.pluginConfigChanged(self.__name, "interval", self.getConfig("interval")) - x = lambda: self.pluginConfigChanged(self.__name, "reloadplugins", self.getConfig("reloadplugins")) - self.core.scheduler.addJob(10, x, threaded=False) - - - def deactivate(self): - self.pluginConfigChanged(self.__name, "reloadplugins", False) - - - def setup(self): - self.cb2 = None - self.interval = 0 - self.updating = False - self.info = {'pyload': False, 'version': None, 'plugins': False} - self.mtimes = {} #: store modification time for each plugin - - - def periodical2(self): - if not self.updating: - self.autoreloadPlugins() - - self.cb2 = self.core.scheduler.addJob(4, self.periodical2, threaded=False) - - - @Expose - def autoreloadPlugins(self): - """ reload and reindex all modified plugins """ - modules = filter( - lambda m: m and (m.__name.startswith("pyload.plugins.") or - m.__name.startswith("userplugins.")) and - m.__name.count(".") >= 2, sys.modules.itervalues() - ) - - reloads = [] - - for m in modules: - root, type, name = m.__name.rsplit(".", 2) - id = (type, name) - if type in self.core.pluginManager.plugins: - f = m.__file__.replace(".pyc", ".py") - if not path.isfile(f): - continue - - mtime = stat(f).st_mtime - - if id not in self.mtimes: - self.mtimes[id] = mtime - elif self.mtimes[id] < mtime: - reloads.append(id) - self.mtimes[id] = mtime - - return True if self.core.pluginManager.reloadPlugins(reloads) else False - - - def periodical(self): - if self.info['pyload'] or self.getConfig("nodebugupdate") and self.core.debug: - return - - self.updateThread() - - - def server_request(self): - try: - return getURL(self.SERVER_URL, get={'v': self.core.api.getServerVersion()}).splitlines() - except Exception: - self.logWarning(_("Unable to contact server to get updates")) - - - @threaded - def updateThread(self): - self.updating = True - - status = self.update(onlyplugin=self.getConfig("mode") == "plugins only") - - if status is 2 and self.getConfig("autorestart"): - self.core.api.restart() - else: - self.updating = False - - - @Expose - def updatePlugins(self): - """ simple wrapper for calling plugin update quickly """ - return self.update(onlyplugin=True) - - - @Expose - def update(self, onlyplugin=False): - """ check for updates """ - data = self.server_request() - - if not data: - exitcode = 0 - - elif data[0] == "None": - self.logInfo(_("No new pyLoad version available")) - updates = data[1:] - exitcode = self._updatePlugins(updates) - - elif onlyplugin: - exitcode = 0 - - else: - newversion = data[0] - self.logInfo(_("*** New pyLoad Version %s available ***") % newversion) - self.logInfo(_("*** Get it here: https://github.com/pyload/pyload/releases ***")) - exitcode = 3 - self.info['pyload'] = True - self.info['version'] = newversion - - return exitcode #: 0 = No plugins updated; 1 = Plugins updated; 2 = Plugins updated, but restart required; 3 = No plugins updated, new pyLoad version available - - - def _updatePlugins(self, updates): - """ check for plugin updates """ - - if self.info['plugins']: - return False #: plugins were already updated - - exitcode = 0 - updated = [] - - url = updates[0] - schema = updates[1].split('|') - - if "BLACKLIST" in updates: - blacklist = updates[updates.index('BLACKLIST') + 1:] - updates = updates[2:updates.index('BLACKLIST')] - else: - blacklist = None - updates = updates[2:] - - upgradable = [dict(zip(schema, x.split('|'))) for x in updates] - blacklisted = [(x.split('|')[0], x.split('|')[1].rsplit('.', 1)[0]) for x in blacklist] if blacklist else [] - - if blacklist: - # Protect internal plugins against removing - for i, t, n in enumerate(blacklisted): - if t == "internal": - blacklisted.pop(i) - continue - - for idx, plugin in enumerate(upgradable): - if n == plugin['name'] and t == plugin['type']: - upgradable.pop(idx) - break - - for t, n in self.removePlugins(sorted(blacklisted)): - self.logInfo(_("Removed blacklisted plugin [%(type)s] %(name)s") % { - 'type': t, - 'name': n, - }) - - for plugin in sorted(upgradable, key=itemgetter("type", "name")): - filename = plugin['name'] - type = plugin['type'] - version = plugin['version'] - - if filename.endswith(".pyc"): - name = filename[:filename.find("_")] - else: - name = filename.replace(".py", "") - - plugins = getattr(self.core.pluginManager, "%sPlugins" % type) - - oldver = float(plugins[name]['version']) if name in plugins else None - newver = float(version) - - if not oldver: - msg = "New plugin: [%(type)s] %(name)s (v%(newver).2f)" - elif newver > oldver: - msg = "New version of plugin: [%(type)s] %(name)s (v%(oldver).2f -> v%(newver).2f)" - else: - continue - - self.logInfo(_(msg) % {'type' : type, - 'name' : name, - 'oldver': oldver, - 'newver': newver}) - try: - content = getURL(url % plugin) - m = self.VERSION.search(content) - - if m and m.group(2) == version: - with open(safe_join("userplugins", prefix, filename), "wb") as f: - f.write(content) - - updated.append((prefix, name)) - else: - raise Exception, _("Version mismatch") - - except Exception, e: - self.logError(_("Error updating plugin: %s") % filename, str(e)) - - if updated: - reloaded = self.core.pluginManager.reloadPlugins(updated) - if reloaded: - self.logInfo(_("Plugins updated and reloaded")) - exitcode = 1 - else: - self.logInfo(_("*** Plugins have been updated, but need a pyLoad restart to be reloaded ***")) - self.info['plugins'] = True - exitcode = 2 - else: - self.logInfo(_("No plugin updates available")) - - return exitcode #: 0 = No plugins updated; 1 = Plugins updated; 2 = Plugins updated, but restart required - - - @Expose - def removePlugins(self, type_plugins): - """ delete plugins from disk """ - - if not type_plugins: - return - - self.logDebug("Requested deletion of plugins: %s" % type_plugins) - - removed = [] - - for type, name in type_plugins: - err = False - file = name + ".py" - - for root in ("userplugins", path.join(pypath, "pyload", "plugins")): - - filename = safe_join(root, type, file) - try: - remove(filename) - except Exception, e: - self.logDebug("Error deleting: %s" % path.basename(filename), e) - err = True - - filename += "c" - if path.isfile(filename): - try: - if type == "addon": - self.manager.deactivateAddon(name) - remove(filename) - except Exception, e: - self.logDebug("Error deleting: %s" % path.basename(filename), e) - err = True - - if not err: - id = (type, name) - removed.append(id) - - return removed #: return a list of the plugins successfully removed diff --git a/pyload/plugins/addon/WindowsPhoneToastNotify.py b/pyload/plugins/addon/WindowsPhoneToastNotify.py deleted file mode 100644 index b12ed96d1..000000000 --- a/pyload/plugins/addon/WindowsPhoneToastNotify.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: utf-8 -*- - -import httplib -import time - -from pyload.plugins.Addon import Addon - - -class WindowsPhoneToastNotify(Addon): - __name = "WindowsPhoneToastNotify" - __type = "addon" - __version = "0.03" - - __config = [("force" , "bool", "Force even if client is connected" , False), - ("pushId" , "str" , "pushId" , "" ), - ("pushUrl" , "str" , "pushUrl" , "" ), - ("pushTimeout", "int" , "Timeout between notifications in seconds", 0 )] - - __description = """Send push notifications to Windows Phone""" - __license = "GPLv3" - __authors = [("Andy Voigt", "phone-support@hotmail.de")] - - - def getXmlData(self): - myxml = ("<?xml version='1.0' encoding='utf-8'?> <wp:Notification xmlns:wp='WPNotification'> " - "<wp:Toast> <wp:Text1>Pyload Mobile</wp:Text1> <wp:Text2>Captcha waiting!</wp:Text2> " - "</wp:Toast> </wp:Notification>") - return myxml - - - def doRequest(self): - URL = self.getConfig("pushUrl") - request = self.getXmlData() - webservice = httplib.HTTP(URL) - webservice.putrequest("POST", self.getConfig("pushId")) - webservice.putheader("Host", URL) - webservice.putheader("Content-type", "text/xml") - webservice.putheader("X-NotificationClass", "2") - webservice.putheader("X-WindowsPhone-Target", "toast") - webservice.putheader("Content-length", "%d" % len(request)) - webservice.endheaders() - webservice.send(request) - webservice.close() - self.setStorage("LAST_NOTIFY", time.time()) - - - def captchaTask(self, task): - if not self.getConfig("pushId") or not self.getConfig("pushUrl"): - return False - - if self.core.isClientConnected() and not self.getConfig("force"): - return False - - if (time.time() - float(self.getStorage("LAST_NOTIFY", 0))) < self.getConf("pushTimeout"): - return False - - self.doRequest() diff --git a/pyload/plugins/addon/XMPPInterface.py b/pyload/plugins/addon/XMPPInterface.py deleted file mode 100644 index 51e904008..000000000 --- a/pyload/plugins/addon/XMPPInterface.py +++ /dev/null @@ -1,252 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyxmpp import streamtls -from pyxmpp.all import JID, Message -from pyxmpp.interface import implements -from pyxmpp.interfaces import * -from pyxmpp.jabber.client import JabberClient - -from pyload.plugins.addon.IRCInterface import IRCInterface - - -class XMPPInterface(IRCInterface, JabberClient): - __name = "XMPPInterface" - __type = "addon" - __version = "0.11" - - __config = [("jid" , "str" , "Jabber ID" , "user@exmaple-jabber-server.org" ), - ("pw" , "str" , "Password" , "" ), - ("tls" , "bool", "Use TLS" , False ), - ("owners" , "str" , "List of JIDs accepting commands from", "me@icq-gateway.org;some@msn-gateway.org"), - ("info_file", "bool", "Inform about every file finished" , False ), - ("info_pack", "bool", "Inform about every package finished" , True ), - ("captcha" , "bool", "Send captcha requests" , True )] - - __description = """Connect to jabber and let owner perform different tasks""" - __license = "GPLv3" - __authors = [("RaNaN", "RaNaN@pyload.org")] - - - implements(IMessageHandlersProvider) - - - def __init__(self, core, manager): - IRCInterface.__init__(self, core, manager) - - self.jid = JID(self.getConfig("jid")) - password = self.getConfig("pw") - - # if bare JID is provided add a resource -- it is required - if not self.jid.resource: - self.jid = JID(self.jid.node, self.jid.domain, "pyLoad") - - if self.getConfig("tls"): - tls_settings = streamtls.TLSSettings(require=True, verify_peer=False) - auth = ("sasl:PLAIN", "sasl:DIGEST-MD5") - else: - tls_settings = None - auth = ("sasl:DIGEST-MD5", "digest") - - # setup client with provided connection information - # and identity data - JabberClient.__init__(self, self.jid, password, - disco_name="pyLoad XMPP Client", disco_type="bot", - tls_settings=tls_settings, auth_methods=auth) - - self.interface_providers = [ - VersionHandler(self), - self, - ] - - - def activate(self): - self.new_package = {} - - self.start() - - - def packageFinished(self, pypack): - try: - if self.getConfig("info_pack"): - self.announce(_("Package finished: %s") % pypack.name) - except Exception: - pass - - - def downloadFinished(self, pyfile): - try: - if self.getConfig("info_file"): - self.announce( - _("Download finished: %(name)s @ %(plugin)s") % {"name": pyfile.name, "plugin": pyfile.pluginname}) - except Exception: - pass - - - def run(self): - # connect to IRC etc. - self.connect() - try: - self.loop() - except Exception, ex: - self.logError(ex) - - - def stream_state_changed(self, state, arg): - """This one is called when the state of stream connecting the component - to a server changes. This will usually be used to let the user - know what is going on.""" - self.logDebug("*** State changed: %s %r ***" % (state, arg)) - - - def disconnected(self): - self.logDebug("Client was disconnected") - - - def stream_closed(self, stream): - self.logDebug("Stream was closed", stream) - - - def stream_error(self, err): - self.logDebug("Stream Error", err) - - - def get_message_handlers(self): - """Return list of (message_type, message_handler) tuples. - - The handlers returned will be called when matching message is received - in a client session.""" - return [("normal", self.message)] - - - def message(self, stanza): - """Message handler for the component.""" - subject = stanza.get_subject() - body = stanza.get_body() - t = stanza.get_type() - self.logDebug("Message from %s received." % unicode(stanza.get_from())) - self.logDebug("Body: %s Subject: %s Type: %s" % (body, subject, t)) - - if t == "headline": - # 'headline' messages should never be replied to - return True - if subject: - subject = u"Re: " + subject - - to_jid = stanza.get_from() - from_jid = stanza.get_to() - - #j = JID() - to_name = to_jid.as_utf8() - from_name = from_jid.as_utf8() - - names = self.getConfig("owners").split(";") - - if to_name in names or to_jid.node + "@" + to_jid.domain in names: - messages = [] - - trigger = "pass" - args = None - - try: - temp = body.split() - trigger = temp[0] - if len(temp) > 1: - args = temp[1:] - except Exception: - pass - - handler = getattr(self, "event_%s" % trigger, self.event_pass) - try: - res = handler(args) - for line in res: - m = Message( - to_jid=to_jid, - from_jid=from_jid, - stanza_type=stanza.get_type(), - subject=subject, - body=line) - - messages.append(m) - except Exception, e: - self.logError(e) - - return messages - - else: - return True - - - def response(self, msg, origin=""): - return self.announce(msg) - - - def announce(self, message): - """ send message to all owners""" - for user in self.getConfig("owners").split(";"): - self.logDebug("Send message to", user) - - to_jid = JID(user) - - m = Message(from_jid=self.jid, - to_jid=to_jid, - stanza_type="chat", - body=message) - - stream = self.get_stream() - if not stream: - self.connect() - stream = self.get_stream() - - stream.send(m) - - - def beforeReconnecting(self, ip): - self.disconnect() - - - def afterReconnecting(self, ip): - self.connect() - - -class VersionHandler(object): - """Provides handler for a version query. - - This class will answer version query and announce 'jabber:iq:version' namespace - in the client's disco#info results.""" - - implements(IIqHandlersProvider, IFeaturesProvider) - - - def __init__(self, client): - """Just remember who created this.""" - self.client = client - - - def get_features(self): - """Return namespace which should the client include in its reply to a - disco#info query.""" - return ["jabber:iq:version"] - - - def get_iq_get_handlers(self): - """Return list of tuples (element_name, namespace, handler) describing - handlers of <iq type='get'/> stanzas""" - return [("query", "jabber:iq:version", self.get_version)] - - - def get_iq_set_handlers(self): - """Return empty list, as this class provides no <iq type='set'/> stanza handler.""" - return [] - - - def get_version(self, iq): - """Handler for jabber:iq:version queries. - - jabber:iq:version queries are not supported directly by PyXMPP, so the - XML node is accessed directly through the libxml2 API. This should be - used very carefully!""" - iq = iq.make_result_response() - q = iq.new_query("jabber:iq:version") - q.newTextChild(q.ns(), "name", "Echo component") - q.newTextChild(q.ns(), "version", "1.0") - return iq diff --git a/pyload/plugins/addon/__init__.py b/pyload/plugins/addon/__init__.py deleted file mode 100644 index 40a96afc6..000000000 --- a/pyload/plugins/addon/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# -*- coding: utf-8 -*- diff --git a/pyload/plugins/captcha/AdYouLike.py b/pyload/plugins/captcha/AdYouLike.py deleted file mode 100644 index be688e65d..000000000 --- a/pyload/plugins/captcha/AdYouLike.py +++ /dev/null @@ -1,107 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from pyload.plugins.Captcha import Captcha -from pyload.utils import json_loads - - -class AdYouLike(Captcha): - __name = "AdYouLike" - __type = "captcha" - __version = "0.02" - - __description = """AdYouLike captcha service plugin""" - __license = "GPLv3" - __authors = [("Walter Purcaro", "vuolter@gmail.com")] - - - AYL_PATTERN = r'Adyoulike\.create\s*\((.+?)\)' - CALLBACK_PATTERN = r'(Adyoulike\.g\._jsonp_\d+)' - - - def detect_key(self, html=None): - if not html: - if hasattr(self.plugin, "html") and self.plugin.html: - html = self.plugin.html - else: - errmsg = _("AdYouLike html not found") - self.plugin.fail(errmsg) - raise TypeError(errmsg) - - m = re.search(self.AYL_PATTERN, html) - n = re.search(self.CALLBACK_PATTERN, html) - if m and n: - self.key = (m.group(1).strip(), n.group(1).strip()) - self.plugin.logDebug("AdYouLike ayl|callback: %s | %s" % self.key) - return self.key #: key is the tuple(ayl, callback) - else: - self.plugin.logDebug("AdYouLike ayl or callback not found") - return None - - - def challenge(self, key=None): - if not key: - if self.detect_key(): - key = self.key - else: - errmsg = _("AdYouLike key not found") - self.plugin.fail(errmsg) - raise TypeError(errmsg) - - ayl, callback = key - - # {"adyoulike":{"key":"P~zQ~O0zV0WTiAzC-iw0navWQpCLoYEP"}, - # "all":{"element_id":"ayl_private_cap_92300","lang":"fr","env":"prod"}} - ayl = json_loads(ayl) - - html = self.plugin.req.load("http://api-ayl.appspot.com/challenge", - get={'key' : ayl['adyoulike']['key'], - 'env' : ayl['all']['env'], - 'callback': callback}) - try: - challenge = json_loads(re.search(callback + r'\s*\((.+?)\)', html).group(1)) - except Exception: - errmsg = _("AdYouLike challenge pattern not found") - self.plugin.error(errmsg) - raise ValueError(errmsg) - - self.plugin.logDebug("AdYouLike challenge: %s" % challenge) - - return self.result(ayl, challenge) - - - def result(self, server, challenge): - # Adyoulike.g._jsonp_5579316662423138 - # ({"translations":{"fr":{"instructions_visual":"Recopiez « Soonnight » ci-dessous :"}}, - # "site_under":true,"clickable":true,"pixels":{"VIDEO_050":[],"DISPLAY":[],"VIDEO_000":[],"VIDEO_100":[], - # "VIDEO_025":[],"VIDEO_075":[]},"medium_type":"image/adyoulike", - # "iframes":{"big":"<iframe src=\"http://www.soonnight.com/campagn.html\" scrolling=\"no\" - # height=\"250\" width=\"300\" frameborder=\"0\"></iframe>"},"shares":{},"id":256, - # "token":"e6QuI4aRSnbIZJg02IsV6cp4JQ9~MjA1","formats":{"small":{"y":300,"x":0,"w":300,"h":60}, - # "big":{"y":0,"x":0,"w":300,"h":250},"hover":{"y":440,"x":0,"w":300,"h":60}}, - # "tid":"SqwuAdxT1EZoi4B5q0T63LN2AkiCJBg5"}) - - if isinstance(server, basestring): - server = json_loads(server) - - if isinstance(challenge, basestring): - challenge = json_loads(challenge) - - try: - instructions_visual = challenge['translations'][server['all']['lang']]['instructions_visual'] - result = re.search(u'«(.+?)»', instructions_visual).group(1).strip() - except Exception: - errmsg = _("AdYouLike result not found") - self.plugin.error(errmsg) - raise ValueError(errmsg) - - result = {'_ayl_captcha_engine' : "adyoulike", - '_ayl_env' : server['all']['env'], - '_ayl_tid' : challenge['tid'], - '_ayl_token_challenge': challenge['token'], - '_ayl_response' : response} - - self.plugin.logDebug("AdYouLike result: %s" % result) - - return result diff --git a/pyload/plugins/captcha/AdsCaptcha.py b/pyload/plugins/captcha/AdsCaptcha.py deleted file mode 100644 index 8655e4f7b..000000000 --- a/pyload/plugins/captcha/AdsCaptcha.py +++ /dev/null @@ -1,77 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from random import random - -from pyload.plugins.Captcha import Captcha - - -class AdsCaptcha(Captcha): - __name = "AdsCaptcha" - __type = "captcha" - __version = "0.06" - - __description = """AdsCaptcha captcha service plugin""" - __license = "GPLv3" - __authors = [("pyLoad Team", "admin@pyload.org")] - - - CAPTCHAID_PATTERN = r'api\.adscaptcha\.com/Get\.aspx\?[^"\']*CaptchaId=(\d+)' - PUBLICKEY_PATTERN = r'api\.adscaptcha\.com/Get\.aspx\?[^"\']*PublicKey=([\w-]+)' - - - def detect_key(self, html=None): - if not html: - if hasattr(self.plugin, "html") and self.plugin.html: - html = self.plugin.html - else: - errmsg = _("AdsCaptcha html not found") - self.plugin.fail(errmsg) - raise TypeError(errmsg) - - m = re.search(self.PUBLICKEY_PATTERN, html) - n = re.search(self.CAPTCHAID_PATTERN, html) - if m and n: - self.key = (m.group(1).strip(), n.group(1).strip()) #: key is the tuple(PublicKey, CaptchaId) - self.plugin.logDebug("AdsCaptcha key|id: %s | %s" % self.key) - return self.key - else: - self.plugin.logDebug("AdsCaptcha key or id not found") - return None - - - def challenge(self, key=None): - if not key: - if self.detect_key(): - key = self.key - else: - errmsg = _("AdsCaptcha key not found") - self.plugin.fail(errmsg) - raise TypeError(errmsg) - - PublicKey, CaptchaId = key - - html = self.plugin.req.load("http://api.adscaptcha.com/Get.aspx", get={'CaptchaId': CaptchaId, 'PublicKey': PublicKey}) - try: - challenge = re.search("challenge: '(.+?)',", html).group(1) - server = re.search("server: '(.+?)',", html).group(1) - except Exception: - errmsg = _("AdsCaptcha challenge pattern not found") - self.plugin.error(errmsg) - raise ValueError(errmsg) - - self.plugin.logDebug("AdsCaptcha challenge: %s" % challenge) - - return challenge, self.result(server, challenge) - - - def result(self, server, challenge): - result = self.plugin.decryptCaptcha("%sChallenge.aspx" % server, - get={'cid': challenge, 'dummy': random()}, - cookies=True, - imgtype="jpg") - - self.plugin.logDebug("AdsCaptcha result: %s" % result) - - return result diff --git a/pyload/plugins/captcha/ReCaptcha.py b/pyload/plugins/captcha/ReCaptcha.py deleted file mode 100644 index e12aba36d..000000000 --- a/pyload/plugins/captcha/ReCaptcha.py +++ /dev/null @@ -1,73 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from pyload.plugins.Captcha import Captcha - - -class ReCaptcha(Captcha): - __name = "ReCaptcha" - __type = "captcha" - __version = "0.08" - - __description = """ReCaptcha captcha service plugin""" - __license = "GPLv3" - __authors = [("pyLoad Team", "admin@pyload.org")] - - - KEY_PATTERN = r'recaptcha(?:/api|\.net)/(?:challenge|noscript)\?k=([\w-]+)' - KEY_AJAX_PATTERN = r'Recaptcha\.create\s*\(\s*["\']([\w-]+)' - - - def detect_key(self, html=None): - if not html: - if hasattr(self.plugin, "html") and self.plugin.html: - html = self.plugin.html - else: - errmsg = _("ReCaptcha html not found") - self.plugin.fail(errmsg) - raise TypeError(errmsg) - - m = re.search(self.KEY_PATTERN, html) or re.search(self.KEY_AJAX_PATTERN, html) - if m: - self.key = m.group(1).strip() - self.plugin.logDebug("ReCaptcha key: %s" % self.key) - return self.key - else: - self.plugin.logDebug("ReCaptcha key not found") - return None - - - def challenge(self, key=None): - if not key: - if self.detect_key(): - key = self.key - else: - errmsg = _("ReCaptcha key not found") - self.plugin.fail(errmsg) - raise TypeError(errmsg) - - html = self.plugin.req.load("http://www.google.com/recaptcha/api/challenge", get={'k': key}) - try: - challenge = re.search("challenge : '(.+?)',", html).group(1) - server = re.search("server : '(.+?)',", html).group(1) - except Exception: - errmsg = _("ReCaptcha challenge pattern not found") - self.plugin.error(errmsg) - raise ValueError(errmsg) - - self.plugin.logDebug("ReCaptcha challenge: %s" % challenge) - - return challenge, self.result(server, challenge) - - - def result(self, server, challenge): - result = self.plugin.decryptCaptcha("%simage" % server, - get={'c': challenge}, - cookies=True, - forceUser=True, - imgtype="jpg") - - self.plugin.logDebug("ReCaptcha result: %s" % result) - - return result diff --git a/pyload/plugins/captcha/SolveMedia.py b/pyload/plugins/captcha/SolveMedia.py deleted file mode 100644 index cc48c801b..000000000 --- a/pyload/plugins/captcha/SolveMedia.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from pyload.plugins.Captcha import Captcha - - -class SolveMedia(Captcha): - __name = "SolveMedia" - __type = "captcha" - __version = "0.06" - - __description = """SolveMedia captcha service plugin""" - __license = "GPLv3" - __authors = [("pyLoad Team", "admin@pyload.org")] - - - KEY_PATTERN = r'api\.solvemedia\.com/papi/challenge\.(?:no)?script\?k=(.+?)["\']' - - - def challenge(self, key=None): - if not key: - if self.detect_key(): - key = self.key - else: - errmsg = _("SolveMedia key not found") - self.plugin.fail(errmsg) - raise TypeError(errmsg) - - html = self.plugin.req.load("http://api.solvemedia.com/papi/challenge.noscript", get={'k': key}) - try: - challenge = re.search(r'<input type=hidden name="adcopy_challenge" id="adcopy_challenge" value="([^"]+)">', - html).group(1) - server = "http://api.solvemedia.com/papi/media" - except Exception: - errmsg = _("SolveMedia challenge pattern not found") - self.plugin.error(errmsg) - raise ValueError(errmsg) - - self.plugin.logDebug("SolveMedia challenge: %s" % challenge) - - return challenge, self.result(server, challenge) - - - def result(self, server, challenge): - result = self.plugin.decryptCaptcha(server, get={'c': challenge}, imgtype="gif") - - self.plugin.logDebug("SolveMedia result: %s" % result) - - return result diff --git a/pyload/plugins/captcha/__init__.py b/pyload/plugins/captcha/__init__.py deleted file mode 100644 index 40a96afc6..000000000 --- a/pyload/plugins/captcha/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# -*- coding: utf-8 -*- diff --git a/pyload/plugins/container/CCF.py b/pyload/plugins/container/CCF.py deleted file mode 100644 index 9488d75f9..000000000 --- a/pyload/plugins/container/CCF.py +++ /dev/null @@ -1,43 +0,0 @@ -# -*- coding: utf-8 -*- - -from __future__ import with_statement - -import re - -from os import makedirs -from os.path import exists -from urllib2 import build_opener - -from MultipartPostHandler import MultipartPostHandler - -from pyload.plugins.Container import Container -from pyload.utils import safe_join - - -class CCF(Container): - __name = "CCF" - __version = "0.20" - - __pattern = r'.+\.ccf' - - __description = """CCF container decrypter plugin""" - __license = "GPLv3" - __authors = [("Willnix", "Willnix@pyload.org")] - - - def decrypt(self, pyfile): - infile = pyfile.url.replace("\n", "") - - opener = build_opener(MultipartPostHandler) - params = {"src": "ccf", - "filename": "test.ccf", - "upload": open(infile, "rb")} - tempdlc_content = opener.open('http://service.jdownloader.net/dlcrypt/getDLC.php', params).read() - - download_folder = self.config['general']['download_folder'] - - tempdlc_name = safe_join(download_folder, "tmp_%s.dlc" % pyfile.name) - with open(tempdlc_name, "w") as tempdlc: - tempdlc.write(re.search(r'<dlc>(.*)</dlc>', tempdlc_content, re.S).group(1)) - - self.urls = [tempdlc_name] diff --git a/pyload/plugins/container/LinkList.py b/pyload/plugins/container/LinkList.py deleted file mode 100644 index f80eecd4d..000000000 --- a/pyload/plugins/container/LinkList.py +++ /dev/null @@ -1,71 +0,0 @@ -# -*- coding: utf-8 -*- - -import codecs - -from pyload.plugins.Container import Container -from pyload.utils import fs_encode - - -class LinkList(Container): - __name = "LinkList" - __version = "0.12" - - __pattern = r'.+\.txt' - __config = [("clear", "bool", "Clear Linklist after adding", False), - ("encoding", "string", "File encoding (default utf-8)", "")] - - __description = """Read link lists in txt format""" - __license = "GPLv3" - __authors = [("spoob", "spoob@pyload.org"), - ("jeix", "jeix@hasnomail.com")] - - - def decrypt(self, pyfile): - try: - file_enc = codecs.lookup(self.getConfig("encoding")).name - except Exception: - file_enc = "utf-8" - - file_name = fs_encode(pyfile.url) - - txt = codecs.open(file_name, 'r', file_enc) - links = txt.readlines() - curPack = "Parsed links from %s" % pyfile.name - - packages = {curPack:[],} - - for link in links: - link = link.strip() - if not link: - continue - - if link.startswith(";"): - continue - if link.startswith("[") and link.endswith("]"): - # new package - curPack = link[1:-1] - packages[curPack] = [] - continue - packages[curPack].append(link) - txt.close() - - # empty packages fix - - delete = [] - - for key,value in packages.iteritems(): - if not value: - delete.append(key) - - for key in delete: - del packages[key] - - if self.getConfig("clear"): - try: - txt = open(file_name, 'wb') - txt.close() - except Exception: - self.logWarning(_("LinkList could not be cleared")) - - for name, links in packages.iteritems(): - self.packages.append((name, links, name)) diff --git a/pyload/plugins/container/RSDF.py b/pyload/plugins/container/RSDF.py deleted file mode 100644 index 001b64bbc..000000000 --- a/pyload/plugins/container/RSDF.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- - -from __future__ import with_statement - -import base64 -import binascii -import re - -from pyload.plugins.Container import Container -from pyload.utils import fs_encode - - -class RSDF(Container): - __name = "RSDF" - __version = "0.24" - - __pattern = r'.+\.rsdf' - - __description = """RSDF container decrypter plugin""" - __license = "GPLv3" - __authors = [("RaNaN", "RaNaN@pyload.org"), - ("spoob", "spoob@pyload.org")] - - - def decrypt(self, pyfile): - - from Crypto.Cipher import AES - - infile = fs_encode(pyfile.url.replace("\n", "")) - Key = binascii.unhexlify('8C35192D964DC3182C6F84F3252239EB4A320D2500000000') - - IV = binascii.unhexlify('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF') - IV_Cipher = AES.new(Key, AES.MODE_ECB) - IV = IV_Cipher.encrypt(IV) - - obj = AES.new(Key, AES.MODE_CFB, IV) - - try: - with open(infile, 'r') as rsdf: - data = rsdf.read() - except IOError, e: - self.fail(str(e)) - - if re.search(r"<title>404 - Not Found", data) is None: - data = binascii.unhexlify(''.join(data.split())) - data = data.splitlines() - - for link in data: - if not link: - continue - link = base64.b64decode(link) - link = obj.decrypt(link) - decryptedUrl = link.replace('CCF: ', '') - self.urls.append(decryptedUrl) - - self.logDebug("Adding package %s with %d links" % (pyfile.package().name, len(self.urls))) diff --git a/pyload/plugins/container/__init__.py b/pyload/plugins/container/__init__.py deleted file mode 100644 index 40a96afc6..000000000 --- a/pyload/plugins/container/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# -*- coding: utf-8 -*- diff --git a/pyload/plugins/crypter/BitshareCom.py b/pyload/plugins/crypter/BitshareCom.py deleted file mode 100644 index 226cd043f..000000000 --- a/pyload/plugins/crypter/BitshareCom.py +++ /dev/null @@ -1,21 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.internal.SimpleCrypter import SimpleCrypter - - -class BitshareCom(SimpleCrypter): - __name = "BitshareCom" - __type = "crypter" - __version = "0.03" - - __pattern = r'http://(?:www\.)?bitshare\.com/\?d=\w+' - __config = [("use_subfolder", "bool", "Save package to subfolder", True), - ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] - - __description = """Bitshare.com folder decrypter plugin""" - __license = "GPLv3" - __authors = [("stickell", "l.stickell@yahoo.it")] - - - LINK_PATTERN = r'.+' - NAME_PATTERN = r'View public folder "(?P.+)"' diff --git a/pyload/plugins/crypter/C1neonCom.py b/pyload/plugins/crypter/C1neonCom.py deleted file mode 100644 index 39eac5ee7..000000000 --- a/pyload/plugins/crypter/C1neonCom.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.internal.DeadCrypter import DeadCrypter, create_getInfo - - -class C1neonCom(DeadCrypter): - __name = "C1neonCom" - __type = "crypter" - __version = "0.05" - - __pattern = r'http://(?:www\.)?c1neon\.com/.*?' - __config = [] - - __description = """C1neon.com decrypter plugin""" - __license = "GPLv3" - __authors = [("godofdream", "soilfiction@gmail.com")] - - -getInfo = create_getInfo(C1neonCom) diff --git a/pyload/plugins/crypter/ChipDe.py b/pyload/plugins/crypter/ChipDe.py deleted file mode 100644 index 6bb879f35..000000000 --- a/pyload/plugins/crypter/ChipDe.py +++ /dev/null @@ -1,29 +0,0 @@ -# -*- coding: utf-8 -*- - -import re -from pyload.plugins.Crypter import Crypter - - -class ChipDe(Crypter): - __name = "ChipDe" - __type = "crypter" - __version = "0.10" - - __pattern = r'http://(?:www\.)?chip\.de/video/.*\.html' - __config = [("use_subfolder", "bool", "Save package to subfolder", True), - ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] - - __description = """Chip.de decrypter plugin""" - __license = "GPLv3" - __authors = [("4Christopher", "4Christopher@gmx.de")] - - - def decrypt(self, pyfile): - self.html = self.load(pyfile.url) - try: - f = re.search(r'"(http://video\.chip\.de/.+)"', self.html) - except Exception: - self.fail(_("Failed to find the URL")) - else: - self.urls = [f.group(1)] - self.logDebug("The file URL is %s" % self.urls[0]) diff --git a/pyload/plugins/crypter/CrockoCom.py b/pyload/plugins/crypter/CrockoCom.py deleted file mode 100644 index c8268173a..000000000 --- a/pyload/plugins/crypter/CrockoCom.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.internal.SimpleCrypter import SimpleCrypter - - -class CrockoCom(SimpleCrypter): - __name = "CrockoCom" - __type = "crypter" - __version = "0.01" - - __pattern = r'http://(?:www\.)?crocko\.com/f/.*' - __config = [("use_subfolder", "bool", "Save package to subfolder", True), - ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] - - __description = """Crocko.com folder decrypter plugin""" - __license = "GPLv3" - __authors = [("zoidberg", "zoidberg@mujmail.cz")] - - - LINK_PATTERN = r'download' diff --git a/pyload/plugins/crypter/CryptItCom.py b/pyload/plugins/crypter/CryptItCom.py deleted file mode 100644 index c82cb3f0a..000000000 --- a/pyload/plugins/crypter/CryptItCom.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.internal.DeadCrypter import DeadCrypter, create_getInfo - - -class CryptItCom(DeadCrypter): - __name = "CryptItCom" - __type = "crypter" - __version = "0.11" - - __pattern = r'http://(?:www\.)?crypt-it\.com/(s|e|d|c)/\w+' - __config = [] - - __description = """Crypt-it.com decrypter plugin""" - __license = "GPLv3" - __authors = [("jeix", "jeix@hasnomail.de")] - - -getInfo = create_getInfo(CryptItCom) diff --git a/pyload/plugins/crypter/CzshareCom.py b/pyload/plugins/crypter/CzshareCom.py deleted file mode 100644 index 4b8646fb6..000000000 --- a/pyload/plugins/crypter/CzshareCom.py +++ /dev/null @@ -1,32 +0,0 @@ -# -*- coding: utf-8 -*- - -import re -from pyload.plugins.Crypter import Crypter - - -class CzshareCom(Crypter): - __name = "CzshareCom" - __type = "crypter" - __version = "0.20" - - __pattern = r'http://(?:www\.)?(czshare|sdilej)\.(com|cz)/folders/.*' - __config = [("use_subfolder", "bool", "Save package to subfolder", True), - ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] - - __description = """Czshare.com folder decrypter plugin, now Sdilej.cz""" - __license = "GPLv3" - __authors = [("zoidberg", "zoidberg@mujmail.cz")] - - - FOLDER_PATTERN = r'\s*\s*(.*?)
    ' - LINK_PATTERN = r'info' - - - def decrypt(self, pyfile): - html = self.load(pyfile.url) - - m = re.search(self.FOLDER_PATTERN, html, re.S) - if m is None: - self.error(_("FOLDER_PATTERN not found")) - - self.urls.extend(re.findall(self.LINK_PATTERN, m.group(1))) diff --git a/pyload/plugins/crypter/DDLMusicOrg.py b/pyload/plugins/crypter/DDLMusicOrg.py deleted file mode 100644 index 6500fe5e6..000000000 --- a/pyload/plugins/crypter/DDLMusicOrg.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from time import sleep - -from pyload.plugins.Crypter import Crypter - - -class DDLMusicOrg(Crypter): - __name = "DDLMusicOrg" - __type = "crypter" - __version = "0.30" - - __pattern = r'http://(?:www\.)?ddl-music\.org/captcha/ddlm_cr\d\.php\?\d+\?\d+' - __config = [("use_subfolder", "bool", "Save package to subfolder", True), - ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] - - __description = """Ddl-music.org decrypter plugin""" - __license = "GPLv3" - __authors = [("mkaay", "mkaay@mkaay.de")] - - - def setup(self): - self.multiDL = False - - - def decrypt(self, pyfile): - html = self.load(pyfile.url, cookies=True) - - if re.search(r"Wer dies nicht rechnen kann", html) is not None: - self.offline() - - math = re.search(r"(\d+) ([+-]) (\d+) =\s+", htmlwithlink) - if m: - self.urls = [m.group(1)] - else: - self.retry() diff --git a/pyload/plugins/crypter/DailymotionBatch.py b/pyload/plugins/crypter/DailymotionBatch.py deleted file mode 100644 index 3ea59bc75..000000000 --- a/pyload/plugins/crypter/DailymotionBatch.py +++ /dev/null @@ -1,106 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from urlparse import urljoin - -from pyload.utils import json_loads -from pyload.plugins.Crypter import Crypter -from pyload.utils import safe_join - - -class DailymotionBatch(Crypter): - __name = "DailymotionBatch" - __type = "crypter" - __version = "0.01" - - __pattern = r'https?://(?:www\.)?dailymotion\.com/((playlists/)?(?Pplaylist|user)/)?(?P[\w^_]+)(?(TYPE)|#)' - __config = [("use_subfolder", "bool", "Save package to subfolder", True), - ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] - - __description = """Dailymotion.com channel & playlist decrypter""" - __license = "GPLv3" - __authors = [("Walter Purcaro", "vuolter@gmail.com")] - - - def api_response(self, ref, req=None): - url = urljoin("https://api.dailymotion.com/", ref) - page = self.load(url, get=req) - return json_loads(page) - - - def getPlaylistInfo(self, id): - ref = "playlist/" + id - req = {"fields": "name,owner.screenname"} - playlist = self.api_response(ref, req) - - if "error" in playlist: - return - - name = playlist['name'] - owner = playlist['owner.screenname'] - return name, owner - - - def _getPlaylists(self, user_id, page=1): - ref = "user/%s/playlists" % user_id - req = {"fields": "id", "page": page, "limit": 100} - user = self.api_response(ref, req) - - if "error" in user: - return - - for playlist in user['list']: - yield playlist['id'] - - if user['has_more']: - for item in self._getPlaylists(user_id, page + 1): - yield item - - - def getPlaylists(self, user_id): - return [(id,) + self.getPlaylistInfo(id) for id in self._getPlaylists(user_id)] - - - def _getVideos(self, id, page=1): - ref = "playlist/%s/videos" % id - req = {"fields": "url", "page": page, "limit": 100} - playlist = self.api_response(ref, req) - - if "error" in playlist: - return - - for video in playlist['list']: - yield video['url'] - - if playlist['has_more']: - for item in self._getVideos(id, page + 1): - yield item - - - def getVideos(self, playlist_id): - return list(self._getVideos(playlist_id))[::-1] - - - def decrypt(self, pyfile): - m = re.match(self.__pattern, pyfile.url) - m_id = m.group("ID") - m_type = m.group("TYPE") - - if m_type == "playlist": - self.logDebug("Url recognized as Playlist") - p_info = self.getPlaylistInfo(m_id) - playlists = [(m_id,) + p_info] if p_info else None - else: - self.logDebug("Url recognized as Channel") - playlists = self.getPlaylists(m_id) - self.logDebug("%s playlist\s found on channel \"%s\"" % (len(playlists), m_id)) - - if not playlists: - self.fail(_("No playlist available")) - - for p_id, p_name, p_owner in playlists: - p_videos = self.getVideos(p_id) - p_folder = safe_join(self.config['general']['download_folder'], p_owner, p_name) - self.logDebug("%s video\s found on playlist \"%s\"" % (len(p_videos), p_name)) - self.packages.append((p_name, p_videos, p_folder)) #: folder is NOT recognized by pyload 0.4.9! diff --git a/pyload/plugins/crypter/DataHu.py b/pyload/plugins/crypter/DataHu.py deleted file mode 100644 index 96129d53a..000000000 --- a/pyload/plugins/crypter/DataHu.py +++ /dev/null @@ -1,40 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from pyload.plugins.internal.SimpleCrypter import SimpleCrypter - - -class DataHu(SimpleCrypter): - __name = "DataHu" - __type = "crypter" - __version = "0.06" - - __pattern = r'http://(?:www\.)?data\.hu/dir/\w+' - __config = [("use_subfolder", "bool", "Save package to subfolder", True), - ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] - - __description = """Data.hu folder decrypter plugin""" - __license = "GPLv3" - __authors = [("crash", ""), - ("stickell", "l.stickell@yahoo.it")] - - - LINK_PATTERN = r'\1' - NAME_PATTERN = ur'(?P<N>.+) Let\xf6lt\xe9se' - - - def prepare(self): - super(DataHu, self).prepare() - - if u'K\xe9rlek add meg a jelsz\xf3t' in self.html: # Password protected - password = self.getPassword() - if not password: - self.fail(_("Password required")) - - self.logDebug("The folder is password protected', 'Using password: " + password) - - self.html = self.load(self.pyfile.url, post={'mappa_pass': password}, decode=True) - - if u'Hib\xe1s jelsz\xf3' in self.html: # Wrong password - self.fail(_("Wrong password")) diff --git a/pyload/plugins/crypter/DdlstorageCom.py b/pyload/plugins/crypter/DdlstorageCom.py deleted file mode 100644 index a7b69da1d..000000000 --- a/pyload/plugins/crypter/DdlstorageCom.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.internal.DeadCrypter import DeadCrypter, create_getInfo - - -class DdlstorageCom(DeadCrypter): - __name = "DdlstorageCom" - __type = "crypter" - __version = "0.03" - - __pattern = r'https?://(?:www\.)?ddlstorage\.com/folder/\w+' - __config = [] - - __description = """DDLStorage.com folder decrypter plugin""" - __license = "GPLv3" - __authors = [("godofdream", "soilfiction@gmail.com"), - ("stickell", "l.stickell@yahoo.it")] - - -getInfo = create_getInfo(DdlstorageCom) diff --git a/pyload/plugins/crypter/DepositfilesCom.py b/pyload/plugins/crypter/DepositfilesCom.py deleted file mode 100644 index c2aa14239..000000000 --- a/pyload/plugins/crypter/DepositfilesCom.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.internal.SimpleCrypter import SimpleCrypter - - -class DepositfilesCom(SimpleCrypter): - __name = "DepositfilesCom" - __type = "crypter" - __version = "0.01" - - __pattern = r'http://(?:www\.)?depositfiles\.com/folders/\w+' - __config = [("use_subfolder", "bool", "Save package to subfolder", True), - ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] - - __description = """Depositfiles.com folder decrypter plugin""" - __license = "GPLv3" - __authors = [("zoidberg", "zoidberg@mujmail.cz")] - - - LINK_PATTERN = r'
    ]*>\s*' diff --git a/pyload/plugins/crypter/Dereferer.py b/pyload/plugins/crypter/Dereferer.py deleted file mode 100644 index 325bfa912..000000000 --- a/pyload/plugins/crypter/Dereferer.py +++ /dev/null @@ -1,26 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from urllib import unquote - -from pyload.plugins.Crypter import Crypter - - -class Dereferer(Crypter): - __name = "Dereferer" - __type = "crypter" - __version = "0.10" - - __pattern = r'https?://([^/]+)/.*?(?P(ht|f)tps?(://|%3A%2F%2F).*)' - __config = [("use_subfolder", "bool", "Save package to subfolder", True), - ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] - - __description = """Crypter for dereferers""" - __license = "GPLv3" - __authors = [("zoidberg", "zoidberg@mujmail.cz")] - - - def decrypt(self, pyfile): - link = re.match(self.__pattern, pyfile.url).group('url') - self.urls = [unquote(link).rstrip('+')] diff --git a/pyload/plugins/crypter/DevhostStFolder.py b/pyload/plugins/crypter/DevhostStFolder.py deleted file mode 100644 index 942dc6b59..000000000 --- a/pyload/plugins/crypter/DevhostStFolder.py +++ /dev/null @@ -1,58 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Test links: -# http://d-h.st/users/shine/?fld_id=37263#files - -import re - -from urlparse import urljoin - -from pyload.plugins.internal.SimpleCrypter import SimpleCrypter - - -class DevhostStFolder(SimpleCrypter): - __name = "DevhostStFolder" - __type = "crypter" - __version = "0.03" - - __pattern = r'http://(?:www\.)?d-h\.st/users/(?P\w+)(/\?fld_id=(?P\d+))?' - __config = [("use_subfolder", "bool", "Save package to subfolder", True), - ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] - - __description = """d-h.st folder decrypter plugin""" - __license = "GPLv3" - __authors = [("zapp-brannigan", "fuerst.reinje@web.de"), - ("Walter Purcaro", "vuolter@gmail.com")] - - - LINK_PATTERN = r'(?:/> |;">)Back to \w+<)' - OFFLINE_PATTERN = r'"/cHP">test\.png<' - - - def getFileInfo(self): - if re.search(self.OFFLINE_PATTERN, self.html): - self.offline() - - try: - id = re.match(self.__pattern, self.pyfile.url).group('ID') - if id == "0": - raise - - p = r'href="(.+?)">Back to \w+<' - m = re.search(p, self.html) - html = self.load(urljoin("http://d-h.st", m.group(1)), - cookies=False) - - p = '\?fld_id=%s.*?">(.+?)<' % id - m = re.search(p, html) - name = folder = m.group(1) - - except Exception, e: - self.logDebug(e) - name = folder = re.match(self.__pattern, self.pyfile.url).group('USER') - - return {'name': name, 'folder': folder} - - - def getLinks(self): - return [urljoin("http://d-h.st", link) for link in re.findall(self.LINK_PATTERN, self.html)] diff --git a/pyload/plugins/crypter/DlProtectCom.py b/pyload/plugins/crypter/DlProtectCom.py deleted file mode 100644 index b386caa3f..000000000 --- a/pyload/plugins/crypter/DlProtectCom.py +++ /dev/null @@ -1,65 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from base64 import urlsafe_b64encode -from time import time - -from pyload.plugins.internal.SimpleCrypter import SimpleCrypter - - -class DlProtectCom(SimpleCrypter): - __name = "DlProtectCom" - __type = "crypter" - __version = "0.01" - - __pattern = r'http://(?:www\.)?dl-protect\.com/((en|fr)/)?(?P\w+)' - __config = [("use_subfolder", "bool", "Save package to subfolder", True), - ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] - - __description = """Dl-protect.com decrypter plugin""" - __license = "GPLv3" - __authors = [("Walter Purcaro", "vuolter@gmail.com")] - - - OFFLINE_PATTERN = r'>Unfortunately, the link you are looking for is not found' - - - def getLinks(self): - # Direct link with redirect - if not re.match(r"http://(?:www\.)?dl-protect\.com", self.req.http.lastEffectiveURL): - return [self.req.http.lastEffectiveURL] - - #id = re.match(self.__pattern, self.pyfile.url).group("ID") - key = re.search(r'name="id_key" value="(.+?)"', self.html).group(1) - - post_req = {"id_key": key, "submitform": ""} - - if self.OFFLINE_PATTERN in self.html: - self.offline() - elif ">Please click on continue to see the content" in self.html: - post_req.update({"submitform": "Continue"}) - else: - mstime = int(round(time() * 1000)) - b64time = "_" + urlsafe_b64encode(str(mstime)).replace("=", "%3D") - - post_req.update({"i": b64time, "submitform": "Decrypt+link"}) - - if ">Password :" in self.html: - post_req['pwd'] = self.getPassword() - - if ">Security Code" in self.html: - captcha_id = re.search(r'/captcha\.php\?uid=(.+?)"', self.html).group(1) - captcha_url = "http://www.dl-protect.com/captcha.php?uid=" + captcha_id - captcha_code = self.decryptCaptcha(captcha_url, imgtype="gif") - - post_req['secure'] = captcha_code - - self.html = self.load(self.pyfile.url, post=post_req) - - for errmsg in (">The password is incorrect", ">The security code is incorrect"): - if errmsg in self.html: - self.fail(_(errmsg[1:])) - - pattern = r'' - return re.findall(pattern, self.html) diff --git a/pyload/plugins/crypter/DontKnowMe.py b/pyload/plugins/crypter/DontKnowMe.py deleted file mode 100644 index e40e3292f..000000000 --- a/pyload/plugins/crypter/DontKnowMe.py +++ /dev/null @@ -1,29 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from urllib import unquote - -from pyload.plugins.Crypter import Crypter - - -class DontKnowMe(Crypter): - __name = "DontKnowMe" - __type = "crypter" - __version = "0.10" - - __pattern = r'http://(?:www\.)?dontknow\.me/at/\?.+$' - __config = [("use_subfolder", "bool", "Save package to subfolder", True), - ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] - - __description = """DontKnow.me decrypter plugin""" - __license = "GPLv3" - __authors = [("selaux", "")] - - - LINK_PATTERN = r'http://dontknow\.me/at/\?(.+)$' - - - def decrypt(self, pyfile): - link = re.findall(self.LINK_PATTERN, pyfile.url)[0] - self.urls = [unquote(link)] diff --git a/pyload/plugins/crypter/DuckCryptInfo.py b/pyload/plugins/crypter/DuckCryptInfo.py deleted file mode 100644 index 2188949bb..000000000 --- a/pyload/plugins/crypter/DuckCryptInfo.py +++ /dev/null @@ -1,59 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from BeautifulSoup import BeautifulSoup - -from pyload.plugins.Crypter import Crypter - - -class DuckCryptInfo(Crypter): - __name = "DuckCryptInfo" - __type = "crypter" - __version = "0.02" - - __pattern = r'http://(?:www\.)?duckcrypt\.info/(folder|wait|link)/(\w+)/?(\w*)' - __config = [("use_subfolder", "bool", "Save package to subfolder", True), - ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] - - __description = """DuckCrypt.info decrypter plugin""" - __license = "GPLv3" - __authors = [("godofdream", "soilfiction@gmail.com")] - - - TIMER_PATTERN = r'(.*)' - - - def decrypt(self, pyfile): - url = pyfile.url - - m = re.match(self.__pattern, url) - if m is None: - self.fail(_("Weird error in link")) - if str(m.group(1)) == "link": - self.handleLink(url) - else: - self.handleFolder(m) - - - def handleFolder(self, m): - html = self.load("http://duckcrypt.info/ajax/auth.php?hash=" + str(m.group(2))) - m = re.match(self.__pattern, html) - self.logDebug("Redirectet to " + str(m.group(0))) - html = self.load(str(m.group(0))) - soup = BeautifulSoup(html) - cryptlinks = soup.findAll("div", attrs={"class": "folderbox"}) - self.logDebug("Redirectet to " + str(cryptlinks)) - if not cryptlinks: - self.error(_("No link found")) - for clink in cryptlinks: - if clink.find("a"): - self.handleLink(clink.find("a")['href']) - - - def handleLink(self, url): - html = self.load(url) - soup = BeautifulSoup(html) - self.urls = [soup.find("iframe")['src']] - if not self.urls: - self.logInfo(_("No link found")) diff --git a/pyload/plugins/crypter/DuploadOrg.py b/pyload/plugins/crypter/DuploadOrg.py deleted file mode 100644 index 0365cbe8a..000000000 --- a/pyload/plugins/crypter/DuploadOrg.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.internal.DeadCrypter import DeadCrypter, create_getInfo - - -class DuploadOrg(DeadCrypter): - __name = "DuploadOrg" - __type = "crypter" - __version = "0.02" - - __pattern = r'http://(?:www\.)?dupload\.org/folder/\d+' - __config = [] - - __description = """Dupload.org folder decrypter plugin""" - __license = "GPLv3" - __authors = [("stickell", "l.stickell@yahoo.it")] - - -getInfo = create_getInfo(DuploadOrg) diff --git a/pyload/plugins/crypter/EasybytezCom.py b/pyload/plugins/crypter/EasybytezCom.py deleted file mode 100644 index 2f0d29ec7..000000000 --- a/pyload/plugins/crypter/EasybytezCom.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.internal.XFSCrypter import XFSCrypter - - -class EasybytezCom(XFSCrypter): - __name = "EasybytezCom" - __type = "crypter" - __version = "0.10" - - __pattern = r'http://(?:www\.)?easybytez\.com/users/\d+/\d+' - __config = [("use_subfolder", "bool", "Save package to subfolder", True), - ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] - - __description = """Easybytez.com folder decrypter plugin""" - __license = "GPLv3" - __authors = [("stickell", "l.stickell@yahoo.it")] - - - HOSTER_DOMAIN = "easybytez.com" - - LOGIN_ACCOUNT = True diff --git a/pyload/plugins/crypter/EmbeduploadCom.py b/pyload/plugins/crypter/EmbeduploadCom.py deleted file mode 100644 index 9b37417be..000000000 --- a/pyload/plugins/crypter/EmbeduploadCom.py +++ /dev/null @@ -1,60 +0,0 @@ -# -*- coding: utf-8 -*- - -import re -from pyload.plugins.Crypter import Crypter -from pyload.network.HTTPRequest import BadHeader - - -class EmbeduploadCom(Crypter): - __name = "EmbeduploadCom" - __type = "crypter" - __version = "0.02" - - __pattern = r'http://(?:www\.)?embedupload\.com/\?d=.*' - __config = [("use_subfolder", "bool", "Save package to subfolder", True), - ("subfolder_per_package", "bool", "Create a subfolder for each package", True), - ("preferedHoster", "str", "Prefered hoster list (bar-separated)", "embedupload"), - ("ignoredHoster", "str", "Ignored hoster list (bar-separated)", "")] - - __description = """EmbedUpload.com decrypter plugin""" - __license = "GPLv3" - __authors = [("zoidberg", "zoidberg@mujmail.cz")] - - - LINK_PATTERN = r'
    ]*>\s*' - - - def decrypt(self, pyfile): - self.html = self.load(pyfile.url, decode=True) - tmp_links = [] - - m = re.findall(self.LINK_PATTERN, self.html) - if m: - prefered_set = set(self.getConfig("preferedHoster").split('|')) - prefered_set = map(lambda s: s.lower().split('.')[0], prefered_set) - - self.logDebug("PF: %s" % prefered_set) - - tmp_links.extend([x[1] for x in m if x[0] in prefered_set]) - self.urls = self.getLocation(tmp_links) - - if not self.urls: - ignored_set = set(self.getConfig("ignoredHoster").split('|')) - ignored_set = map(lambda s: s.lower().split('.')[0], ignored_set) - - self.logDebug("IG: %s" % ignored_set) - - tmp_links.extend([x[1] for x in m if x[0] not in ignored_set]) - self.urls = self.getLocation(tmp_links) - - - def getLocation(self, tmp_links): - new_links = [] - for link in tmp_links: - try: - header = self.load(link, just_header=True) - if 'location' in header: - new_links.append(header['location']) - except BadHeader: - pass - return new_links diff --git a/pyload/plugins/crypter/FilebeerInfo.py b/pyload/plugins/crypter/FilebeerInfo.py deleted file mode 100644 index 51925a3ad..000000000 --- a/pyload/plugins/crypter/FilebeerInfo.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.internal.DeadCrypter import DeadCrypter, create_getInfo - - -class FilebeerInfo(DeadCrypter): - __name = "FilebeerInfo" - __type = "crypter" - __version = "0.02" - - __pattern = r'http://(?:www\.)?filebeer\.info/(\d+~f).*' - __config = [] - - __description = """Filebeer.info folder decrypter plugin""" - __license = "GPLv3" - __authors = [("zoidberg", "zoidberg@mujmail.cz")] - - -getInfo = create_getInfo(FilebeerInfo) diff --git a/pyload/plugins/crypter/FilecloudIo.py b/pyload/plugins/crypter/FilecloudIo.py deleted file mode 100644 index a637eefdd..000000000 --- a/pyload/plugins/crypter/FilecloudIo.py +++ /dev/null @@ -1,21 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.plugins.internal.SimpleCrypter import SimpleCrypter - - -class FilecloudIo(SimpleCrypter): - __name = "FilecloudIo" - __type = "crypter" - __version = "0.03" - - __pattern = r'https?://(?:www\.)?(filecloud\.io|ifile\.it)/_\w+' - __config = [("use_subfolder", "bool", "Save package to subfolder", True), - ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] - - __description = """Filecloud.io folder decrypter plugin""" - __license = "GPLv3" - __authors = [("Walter Purcaro", "vuolter@gmail.com")] - - - LINK_PATTERN = r'href="(http://filecloud\.io/\w+)" title' - NAME_PATTERN = r'>(?P.+?) - filecloud\.io<' diff --git a/pyload/plugins/crypter/FilecryptCc.py b/pyload/plugins/crypter/FilecryptCc.py deleted file mode 100644 index ca81c8fa2..000000000 --- a/pyload/plugins/crypter/FilecryptCc.py +++ /dev/null @@ -1,148 +0,0 @@ -# -*- coding: utf-8 -*- - -import base64 -import binascii -import re - -from Crypto.Cipher import AES - -from pyload.plugins.Crypter import Crypter - - -class FilecryptCc(Crypter): - __name = "FilecryptCc" - __type = "crypter" - __version = "0.05" - - __pattern = r'https?://(?:www\.)?filecrypt\.cc/Container/\w+' - - __description = """Filecrypt.cc decrypter plugin""" - __license = "GPLv3" - __authors = [("zapp-brannigan", "fuerst.reinje@web.de")] - - - # URL_REPLACEMENTS = [(r'.html$', ""), (r'$', ".html")] #@TODO: Extend SimpleCrypter - - DLC_LINK_PATTERN = r'