Просмотр исходного кода

add new function Find AV Code in URL.

unknown 10 лет назад
Родитель
Сommit
723d17ab23

+ 23 - 0
Entity/ClassDiagram1.cd

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<ClassDiagram MajorVersion="1" MinorVersion="1">
+  <Class Name="AVSORTER.SearchItem">
+    <Position X="2.5" Y="0.5" Width="2.5" />
+    <NestedTypes>
+      <Class Name="AVSORTER.SearchItem.StatusChangeEventArgs" Collapsed="true">
+        <TypeIdentifier>
+          <NewMemberFileName>SearchItem.cs</NewMemberFileName>
+        </TypeIdentifier>
+      </Class>
+      <Delegate Name="AVSORTER.SearchItem.StatusChangeEvent" Collapsed="true">
+        <TypeIdentifier>
+          <NewMemberFileName>SearchItem.cs</NewMemberFileName>
+        </TypeIdentifier>
+      </Delegate>
+    </NestedTypes>
+    <TypeIdentifier>
+      <HashCode>AEAAQAAEAQAgEABoQAAAQJAAAgFBgAIAAAIgQAAACAA=</HashCode>
+      <FileName>SearchItem.cs</FileName>
+    </TypeIdentifier>
+  </Class>
+  <Font Name="Microsoft YaHei UI" Size="9" />
+</ClassDiagram>

+ 3 - 0
Entity/Entity.csproj

@@ -70,6 +70,9 @@
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>
   </ItemGroup>
+  <ItemGroup>
+    <None Include="ClassDiagram1.cd" />
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.

+ 2 - 2
Entity/SearchItem.cs

@@ -43,7 +43,6 @@ namespace AVSORTER
         /// </summary>
         public List<MovieBasic> MovieBasicList { get; set; }
 
-
         private QStatus _status = QStatus.未开始;
 
         public QStatus Status
@@ -185,6 +184,7 @@ namespace AVSORTER
                 OnStatusChange(this,new StatusChangeEventArgs(b,aft,msg));
             }
         }
+
         public event StatusChangeEvent OnStatusChange;
 
         private int chooseIndex = -1;
@@ -199,7 +199,6 @@ namespace AVSORTER
         {
             if (this.Getor!=null)
             {
-                
                 //this.MovieBasicList = Getor.Query(SeedString);
                 Func<string, List<MovieBasic>> fuc = new Func<string, List<MovieBasic>>(Getor.Query);
                 fuc.BeginInvoke(SeedString, queryFinishCallBack, fuc);
@@ -255,6 +254,7 @@ namespace AVSORTER
                 this.Message = _msg;
             }
         }
+
         public delegate void StatusChangeEvent(object sender, StatusChangeEventArgs e);
         /// <summary>
         /// 是否自动下载封面

+ 20 - 9
PicSo/Form1.Designer.cs

@@ -66,8 +66,9 @@
             this.btn_LocalSearch = new System.Windows.Forms.Button();
             this.txt_LocalSearchKeyWord = new System.Windows.Forms.TextBox();
             this.tabPage3 = new System.Windows.Forms.TabPage();
-            this.txt_url = new System.Windows.Forms.TextBox();
             this.btnFind = new System.Windows.Forms.Button();
+            this.txt_url = new System.Windows.Forms.TextBox();
+            this.txt_FindStatus = new System.Windows.Forms.TextBox();
             this.bc = new AVSORTER.BasicContainer();
             this.movieContainer1 = new PicSo.MovieContainer();
             this.contextMenuStrip1.SuspendLayout();
@@ -441,6 +442,7 @@
             // 
             // tabPage3
             // 
+            this.tabPage3.Controls.Add(this.txt_FindStatus);
             this.tabPage3.Controls.Add(this.btnFind);
             this.tabPage3.Controls.Add(this.txt_url);
             this.tabPage3.Location = new System.Drawing.Point(4, 22);
@@ -451,16 +453,9 @@
             this.tabPage3.Text = "tabPage3";
             this.tabPage3.UseVisualStyleBackColor = true;
             // 
-            // txt_url
-            // 
-            this.txt_url.Location = new System.Drawing.Point(6, 6);
-            this.txt_url.Name = "txt_url";
-            this.txt_url.Size = new System.Drawing.Size(414, 21);
-            this.txt_url.TabIndex = 0;
-            // 
             // btnFind
             // 
-            this.btnFind.Location = new System.Drawing.Point(426, 6);
+            this.btnFind.Location = new System.Drawing.Point(6, 33);
             this.btnFind.Name = "btnFind";
             this.btnFind.Size = new System.Drawing.Size(75, 23);
             this.btnFind.TabIndex = 1;
@@ -468,6 +463,21 @@
             this.btnFind.UseVisualStyleBackColor = true;
             this.btnFind.Click += new System.EventHandler(this.btnFind_Click);
             // 
+            // txt_url
+            // 
+            this.txt_url.Location = new System.Drawing.Point(6, 6);
+            this.txt_url.Name = "txt_url";
+            this.txt_url.Size = new System.Drawing.Size(953, 21);
+            this.txt_url.TabIndex = 0;
+            // 
+            // txt_FindStatus
+            // 
+            this.txt_FindStatus.Location = new System.Drawing.Point(6, 62);
+            this.txt_FindStatus.Multiline = true;
+            this.txt_FindStatus.Name = "txt_FindStatus";
+            this.txt_FindStatus.Size = new System.Drawing.Size(953, 187);
+            this.txt_FindStatus.TabIndex = 2;
+            // 
             // bc
             // 
             this.bc.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
@@ -562,6 +572,7 @@
         private System.Windows.Forms.TabPage tabPage3;
         private System.Windows.Forms.Button btnFind;
         private System.Windows.Forms.TextBox txt_url;
+        private System.Windows.Forms.TextBox txt_FindStatus;
     }
 }
 

+ 76 - 2
PicSo/Form1.cs

@@ -428,16 +428,90 @@ namespace PicSo
         #endregion
 
         #region Page3
+        
 
         private void btnFind_Click(object sender, EventArgs e)
         {
+            BackgroundWorker worker = new BackgroundWorker();
+            worker.WorkerReportsProgress = true;
+            worker.ProgressChanged += worker_ProgressChanged;
+            worker.DoWork += worker_DoWork;
+            worker.RunWorkerCompleted += worker_RunWorkerCompleted;
+            worker.RunWorkerAsync(worker);
+        }
+
+        void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
+        {
+            //throw new NotImplementedException();
+        }
+
+        void worker_DoWork(object sender, DoWorkEventArgs e)
+        {
+            var worker =  (e.Argument as BackgroundWorker);
+            List<AVSORTER.Movie> list = new List<AVSORTER.Movie>();
             var mvbs = arzon.FindInURL(txt_url.Text);
-            MessageBox.Show("Test");
+            worker.ReportProgress(0, "共找到影片:" + mvbs.Count.ToString());
+            int no = 0;
+            int totalNo = mvbs.Count;
+            foreach (var mvb in mvbs)
+            {
+                var fi = arzon.Clone() as AVSORTER.IGetable;
+                var mv = fi.GetMovie(mvb);
+                no++;
+                worker.ReportProgress(0, no.ToString() + "/" + totalNo.ToString());
+                worker.ReportProgress(0,mv.AVCode + "\t" + mv.Title);
+                Gets.MyWebClient wc = new Gets.MyWebClient();
+                wc.ReferURL = mvb.ItemURL;
+                string fn = mvb.Title + ".jpg";
+                fn = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SmallImageFindInURL", Path.ChangeExtension(fn, "jpg"));
+                try
+                {
+                    if (!Directory.Exists(Path.GetDirectoryName(fn)))
+                    {
+                        Directory.CreateDirectory(Path.GetDirectoryName(fn));
+                    }
+                    if (!File.Exists(fn))
+                    {
+                        wc.DownloadFile(mvb.Img_s, fn);
+                    }
+                    else
+                    {
+                        Console.WriteLine("已有封面" + fn);
+                    }
+                    worker.ReportProgress(0, mv.AVCode + "\t封面OK!");
+
+                }
+                catch (Exception s)
+                {
+                    throw new Exception("下载缩略图失败!");
+                }
+                mv.CoverFile = fn;
+                list.Add(mv);
+            }
+            StringBuilder sb = new StringBuilder();
+            foreach (AVSORTER.Movie item in list)
+            {
+                sb.Append("<div id = \"" + item.AVCode + "\" class = \"item\"><img src = \"" + item.CoverFile + "\" /><input type=\"checkbox\" />" + item.AVCode + "</div>");
+            }
+            var htmlResult = Properties.Resources.htmlResultStart + sb + Properties.Resources.htmlResultEnd;
+            System.IO.File.WriteAllText("temp.html", htmlResult);
+            System.Diagnostics.Process.Start("temp.html");
         }
 
-        #endregion
+        void worker_ProgressChanged(object sender, ProgressChangedEventArgs e)
+        {
+            if (e.ProgressPercentage==0)
+            {
+                txt_FindStatus.AppendText(e.UserState as string + "\r\n");
+            }
+        }
 
+        #endregion
 
 
+        
     }
+
+    
+
 }

+ 1 - 1
PicSo/Program.cs

@@ -11,7 +11,7 @@ namespace PicSo
         /// 应用程序的主入口点。
         /// </summary>
         [STAThread]
-        static void Main()
+        static void Main(string[] args)
         {
             Application.EnableVisualStyles();
             Application.SetCompatibleTextRenderingDefault(false);

+ 35 - 1
PicSo/Properties/Resources.Designer.cs

@@ -1,7 +1,7 @@
 //------------------------------------------------------------------------------
 // <auto-generated>
 //     此代码由工具生成。
-//     运行时版本:4.0.30319.18444
+//     运行时版本:4.0.30319.34014
 //
 //     对此文件的更改可能会导致不正确的行为,并且如果
 //     重新生成代码,这些更改将会丢失。
@@ -59,5 +59,39 @@ namespace PicSo.Properties {
                 resourceCulture = value;
             }
         }
+        
+        /// <summary>
+        ///   查找类似 &lt;/div&gt;
+        ///&lt;/body&gt;
+        ///&lt;/html&gt; 的本地化字符串。
+        /// </summary>
+        internal static string htmlResultEnd {
+            get {
+                return ResourceManager.GetString("htmlResultEnd", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   查找类似 &lt;!DOCTYPE html&gt;
+        ///&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
+        ///&lt;head&gt;
+        ///    &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
+        ///    &lt;title&gt;&lt;/title&gt;
+        ///&lt;/head&gt;
+        ///
+        ///&lt;body&gt;
+        ///    &lt;script type=&quot;text/javascript&quot;&gt;
+        ///        window.onload = function () {
+        ///            oIMGs = document.getElementsByClassName(&quot;item&quot;);
+        ///            for (var i = 0; i &lt; oIMGs.length; i++) {
+        ///                oIMGs[i].onclick = function (e) {
+        ///                    if (e.srcElement.nextElementSibling.checked) {
+        ///                 [字符串的其余部分被截断]&quot;; 的本地化字符串。
+        /// </summary>
+        internal static string htmlResultStart {
+            get {
+                return ResourceManager.GetString("htmlResultStart", resourceCulture);
+            }
+        }
     }
 }

+ 85 - 5
PicSo/Properties/Resources.resx

@@ -46,7 +46,7 @@
     
     mimetype: application/x-microsoft.net.object.binary.base64
     value   : The object must be serialized with 
-            : System.Serialization.Formatters.Binary.BinaryFormatter
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
             : and then encoded with base64 encoding.
     
     mimetype: application/x-microsoft.net.object.soap.base64
@@ -60,6 +60,7 @@
             : and then encoded with base64 encoding.
     -->
   <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
     <xsd:element name="root" msdata:IsDataSet="true">
       <xsd:complexType>
         <xsd:choice maxOccurs="unbounded">
@@ -68,9 +69,10 @@
               <xsd:sequence>
                 <xsd:element name="value" type="xsd:string" minOccurs="0" />
               </xsd:sequence>
-              <xsd:attribute name="name" type="xsd:string" />
+              <xsd:attribute name="name" use="required" type="xsd:string" />
               <xsd:attribute name="type" type="xsd:string" />
               <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
             </xsd:complexType>
           </xsd:element>
           <xsd:element name="assembly">
@@ -85,9 +87,10 @@
                 <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
                 <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
               </xsd:sequence>
-              <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
               <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
               <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
             </xsd:complexType>
           </xsd:element>
           <xsd:element name="resheader">
@@ -109,9 +112,86 @@
     <value>2.0</value>
   </resheader>
   <resheader name="reader">
-    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
   <resheader name="writer">
-    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
+  <data name="htmlResultEnd" xml:space="preserve">
+    <value>&lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;</value>
+  </data>
+  <data name="htmlResultStart" xml:space="preserve">
+    <value>&lt;!DOCTYPE html&gt;
+&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
+&lt;head&gt;
+    &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
+    &lt;title&gt;&lt;/title&gt;
+&lt;/head&gt;
+
+&lt;body&gt;
+    &lt;script type="text/javascript"&gt;
+        window.onload = function () {
+            oIMGs = document.getElementsByClassName("item");
+            for (var i = 0; i &lt; oIMGs.length; i++) {
+                oIMGs[i].onclick = function (e) {
+                    if (e.srcElement.nextElementSibling.checked) {
+                        e.srcElement.nextElementSibling.checked = false;
+                    }
+                    else {
+                        e.srcElement.nextElementSibling.checked = true;
+                    }
+                    genbtn();
+                }
+            }
+        }
+        function genbtn() {
+            var sb = " ";
+            for (var i = 0; i &lt; oIMGs.length; i++) {
+                if (oIMGs[i].childNodes[1].checked==true) {
+                    sb += " " + oIMGs[i].id.toString();
+                }
+            }
+
+            var oh = document.getElementById("res");
+            oh.innerText = sb;
+        }
+
+    &lt;/script&gt;
+    &lt;style type="text/css"&gt;
+        #gen {
+             width:150px;
+             height:50px;
+             color:green;
+             clear:both;
+             float:left;
+        }
+        #bigdiv{
+            margin:0;
+            clear:both;
+        }
+        div {
+            float: left;
+        }
+
+        img {
+            width: 130px;
+            height: 180px;
+            display: block;
+        }
+
+        input {
+            position: relative;
+            top: 0;
+            margin: 0 auto;
+        }
+    &lt;/style&gt;
+    &lt;p&gt;
+        &lt;h1 id="res"&gt;
+            Click!
+        &lt;/h1&gt;
+    &lt;/p&gt;
+    &lt;div id="bigdiv"&gt;</value>
+  </data>
 </root>

BIN
PicSo/obj/x86/Debug/DesignTimeResolveAssemblyReferences.cache


BIN
PicSo/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache


+ 1 - 0
PicSo/obj/x86/Debug/PicSo.csproj.FileListAbsolute.txt

@@ -35,3 +35,4 @@ C:\Users\jojo\Desktop\codes\avsorter\PicSo\bin\Debug\Gets.pdb
 C:\Users\jojo\Desktop\codes\avsorter\PicSo\bin\Debug\Entity.pdb
 C:\Users\jojo\Desktop\codes\avsorter\PicSo\obj\x86\Debug\PicSo.exe
 C:\Users\jojo\Desktop\codes\avsorter\PicSo\obj\x86\Debug\PicSo.pdb
+E:\Codes\AVsorter\AVsorter\PicSo\bin\Debug\HtmlAgilityPack.dll

BIN
PicSo/obj/x86/Debug/TempPE/Properties.Resources.Designer.cs.dll